From patchwork Fri Aug 25 13:59:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13365798 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BD10C71133 for ; Fri, 25 Aug 2023 13:59:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 816722800C6; Fri, 25 Aug 2023 09:59:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3AA792800C4; Fri, 25 Aug 2023 09:59:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 88ADF2800BE; Fri, 25 Aug 2023 09:59:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 29F062800BC for ; Fri, 25 Aug 2023 09:59:26 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F144AB2671 for ; Fri, 25 Aug 2023 13:59:25 +0000 (UTC) X-FDA: 81162784290.15.2C4DC7B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP id 3ACEC1A0009 for ; Fri, 25 Aug 2023 13:59:23 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ioYJ9ZBa; dmarc=none; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692971964; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5c7x1kFuKVswGl86DNxqX0EgO6SdlR0zTwx5NPZJoVM=; b=Lt6pIHOHf8TKISBnx/OrOSkTQTXq7h5FbG6gz1xO2kHm+uyGP9dIUoV4E3+5cVSrM3F67q rfghStLCEvNA6N/+TRfmiT38NMJyeJulsjdXSWOxwjWXTMgJKoxq9d7GDWQO3ksldMAawm 510PD4n2qsBhmsAx6C7RhjUAlhpc/Sc= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ioYJ9ZBa; dmarc=none; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692971964; a=rsa-sha256; cv=none; b=wARNHYagudVmjbKU8d6+Wo0vdUFy9HNDKezTQgCQxA/K0UcI2mqqr0aAvfFy8PvcJWprZS rwZRVpHwjnQYoIo4+j4UN6Qp/soPrGITZcGyAMjwgC1be9YwHpmNRZGr8fLK1SUuX4Ejp6 sfJapczplNY5wShbZ+m1km5uQah0Zio= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=5c7x1kFuKVswGl86DNxqX0EgO6SdlR0zTwx5NPZJoVM=; b=ioYJ9ZBaG5iSJwtN2Q1RH/Ym/T 5XaS24qb1p2fVO9kC4OIAUVffmsOfQIFApsa0EUS9E3nqZfvnCmJXGKH/gXOlSbPZueY1mG8wDtHr yCbX7A8PHLvpUW2WyW+3xRYHOtNJAo2eke5P0vzW9KS18tahjNOc693mRbOLlXzAK0zovAZXskLMs Xzmza1eYOkta2Jy9vA5yXXtO5b6EzeQmgn4BjaO2l5x6uAlEsMHXxwhkDBSK7qGTGmTWFva3yLr6O mvkqdrYox15CUZlxJRjf/xmVekdXNqo/SHhUSVzLpeIO4MQ5NOqszbxz1bJZLj2cQfWHzteYsLaaS fD6kUU0w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qZXLN-00HTQt-Ix; Fri, 25 Aug 2023 13:59:21 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [RFC PATCH 06/14] mm: Remove use of folio list from folios_put() Date: Fri, 25 Aug 2023 14:59:10 +0100 Message-Id: <20230825135918.4164671-7-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230825135918.4164671-1-willy@infradead.org> References: <20230825135918.4164671-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: f4ch4cntoypmq4ngzooyzsrmj9q8hsom X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3ACEC1A0009 X-HE-Tag: 1692971963-689031 X-HE-Meta: U2FsdGVkX19DwZHFDO+Ao7E1VtP/aiWEyexCQMbQCUKhFk9cJxFnoCh+E+4pkEN6BlzOW04D01pWRlYSJKry8RNfs5PV9EXzZ0kt79N4wdOyve6MVTFiXPPQR4pyB+rc+EPth7iF/lPJPJ8gL96lb9/WFXUn0cuupHN6tyft8DPHSkb+/YGn8MmHP7klUr8gIjW9wBLb/8zHFDFbBRKmAYOvRDjfKcaOPw5ohHZNNbzvDuG7ByImiRUxB899gU8SOubxnY6ereWURvO/l7t3DPPxNI6O6sPTxFGaR7BMYGOyLHpavEAEsefBdmA/SHiu1wiuOKeBP1HBt6FLYg12NrVN9b7yuA1hL/prmZl7iNqUTjtJKxN0XtIsJWGtaxbCv1uHWPyn2bTfaLWJ7FYJbbJWrHiv0rlqXsrGbYpri/n4TSb/zgAzOnkrrg7sOLVWgkiU3TEpEJv4zbXb6xmzUFYXwEyCTp/ASzUclnA9YJnKsYkkgvf7ibwrprxl1igXTLy+VzCRaepUcAcrgjAAViBQScradNUO42RDytAyWSSTnPjM+PwtXAMRmSpwLd07YBPmdXUN7yGV3iLTaP43u43wc7XqCWN5k1ebr20OPyHkytUylsg/WFzaEnfzJtkrzYM2i8zOfSC53R0pTG04cwN7ZYNZS20wXeCH5SjzVZaUoeef7sgVVsT3xo332h/xRRGxQrE8OpTcAHmbLSmFuDSmVabYwKfllL2sIfBju63gRKYGR/5Xa/0M1TeRswulRKGlDzBV66e4vcvQIDGiSg5mA8HIHmnFRLB52XISh9cwF9JdZo1rGte+oFq36fjgFyjiKfGWSXAtC8mF/FZsDM6q7J1+BjP9rvD/cZH7z3011OGGaHOg0W+DP6Nn67N5gFn8tGLQDb+5SzwpYSJhH0jowszyZEqW1LVWQ74kQbeb3Ru57vo/yfgBRSdhvGT/C/g/FjMfhwTTCoEXeJH AU/u6+Pz XERuTIMSbV3AzGqhNYWEJ+06XRoHtKEBp2u9a0cw1dvYZS5KPtUUD8/jT8wzy5ndilJdVoMgRQl9Ql1PHoycd62E/s4ilD/3KGL+f73fiYYJ72u0fSMopVdKf9W/OHsVNcGrNXHlFgdbDMQ0rwpu7+/qSdgtLvedbkaOsS+lQzlAk3CKT4/i+zVBWqNfVgs5qX6O5GDeDbQyD6h/4aCv8JwDlk7mwwqIQYTAY X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Instead of putting the interesting folios on a list, delete the uninteresting one from the folio_batch. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Ryan Roberts --- mm/swap.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index c5ea0c6669e7..6b2f3f77450c 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -959,12 +959,11 @@ void lru_cache_disable(void) */ void folios_put(struct folio_batch *folios) { - int i; - LIST_HEAD(pages_to_free); + int i, j; struct lruvec *lruvec = NULL; unsigned long flags = 0; - for (i = 0; i < folios->nr; i++) { + for (i = 0, j = 0; i < folios->nr; i++) { struct folio *folio = folios->folios[i]; if (is_huge_zero_page(&folio->page)) @@ -1013,14 +1012,18 @@ void folios_put(struct folio_batch *folios) count_vm_event(UNEVICTABLE_PGCLEARED); } - list_add(&folio->lru, &pages_to_free); + if (j != i) + folios->folios[j] = folio; + j++; } if (lruvec) unlock_page_lruvec_irqrestore(lruvec, flags); + folios->nr = j; + if (!j) + return; - mem_cgroup_uncharge_list(&pages_to_free); - free_unref_page_list(&pages_to_free); - folios->nr = 0; + mem_cgroup_uncharge_folios(folios); + free_unref_folios(folios); } EXPORT_SYMBOL(folios_put);