From patchwork Tue Feb 27 17:42:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13574202 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 B1920C54E41 for ; Tue, 27 Feb 2024 17:43:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C3626B00E5; Tue, 27 Feb 2024 12:43:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D705E6B00E6; Tue, 27 Feb 2024 12:43:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CBA86B00EF; Tue, 27 Feb 2024 12:43:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1BCB06B00E4 for ; Tue, 27 Feb 2024 12:43:04 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DC813A0947 for ; Tue, 27 Feb 2024 17:43:03 +0000 (UTC) X-FDA: 81838304646.04.7B613AC Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf17.hostedemail.com (Postfix) with ESMTP id 173324001D for ; Tue, 27 Feb 2024 17:42:59 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=sk28ikhP; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709055782; 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=hW1lKddwChCwhgOj8zOdkpVbhWbm50HPXPJZ8BtEokk=; b=i/GOTXebRmdm2x/kVqRfRTuIeFWAwAp85mBauhs0RxMAZsnVDHjrMHJS4tgrd3XKWBTEPn 733ShdRty+0Zbi2Tn43WwF4UqgksQXHTXhleTNo4mZrooSUq+0boHxtEiGnG7v3rxdkf+h tXfDym+AlEEC3am+nkCL12qQRgGMkys= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709055782; a=rsa-sha256; cv=none; b=llRwOnlYetPpO/eUUlP//570jJMvYsIcz6dg0C+7kM3LKzDLlkkjq+aVDNBxaZNPq6ZfLS plfVFCIx7rx+Ob9P0Maum935mYU69VcMST+shjrbQNXqBn5RpzyaS2dfw6qD4i45Zdpgk4 Nakg64P835oqkQHn+ygcUgnmS/rPMYE= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=sk28ikhP; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none 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=hW1lKddwChCwhgOj8zOdkpVbhWbm50HPXPJZ8BtEokk=; b=sk28ikhPtxlulqjzsEEhm6+rFc iI0jjNEg5txxUm2cOc8pcPTIzgs7Ki1gFzebZnoZujX3/NP7t6aRwKuxaxi9uPHogI3FRXXM0bHFD YprkMjmXWQLiO1E8bfNpoPDzOTuf/mKu0ZSS/tNzoizUfOLJeFCw98taEI/pvhVpe/ZFGokxb99jL TsW1xOby9au9D5VK5lqgtD1Ee/a6/WTqTR1geaxsRjrBtApCd9304anGZPCL9QI09jISeWWOK4j7g LVVALZQd1xZv5euFluHmeCLfQCstr2OJq6/LIF1TrSxRS/2oBWywcfbSblgvq47G+N74sK7M8UQUm 7lUH4v/A==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rf1Tm-00000002yrC-2av5; Tue, 27 Feb 2024 17:42:58 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v3 07/18] mm: Use free_unref_folios() in put_pages_list() Date: Tue, 27 Feb 2024 17:42:41 +0000 Message-ID: <20240227174254.710559-8-willy@infradead.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240227174254.710559-1-willy@infradead.org> References: <20240227174254.710559-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 173324001D X-Rspam-User: X-Stat-Signature: yjhgfofy7bjm767wtuy3g3moiqopq6ab X-Rspamd-Server: rspam03 X-HE-Tag: 1709055779-206010 X-HE-Meta: U2FsdGVkX18p9pN2B2jsFWSi6j05f37gNOX+lED7TKLXwG5DqsQ7b2VRZeNBYrZRz4GrSZ30N0rhQxaBMYJZ9PWeAa0b68lG/198WaHx1MteJpwy4oIhPbA8M4coaopeofPXPYtddKR5521d/eVyW0VKQ1gfawSSG2bL+5rQxTKzANXCeI8xLQFIyEC4Xn/8K3Fn7JsEFDbGcYEA+H/YUzYmdsUIifbWHavItkruaafCqO2Fatnf61i1pWBKqbaFuEG/puXWfGPXd3ogR5lrO8E/EyRvM2VqrMZ0esoqIXDs9A4Mpb0Q3FyCa1FSyRVB0qP5LU8bqvPTmZXPP/IQbrS9J4S0bNp3xwWZuzUdav8ug1EnIrY4CzGpv4PrQeLuUKOTxofg9YPRSJFaLUjWPIcwmVPhOJGVsFhWuaFaqoU/TFFTsl6r39NqLaLye7Bi1TBlUkvMKvy63NhJtTGqWPEKb4LhUnf7SD+89NbqE9GXjUc2nCXmpC3w4lzCiyNx18Wql4jpzj4pxifvOiCyoI1tnF8yOcfzRTmyPMM3bjKuBGYxSiSzmoThSc0siV2TXPTZ0Wr6NrOlaCiAJusZDF4s8JmVlQ1sDx76VKfq69UMhq15MsZnU5lYO456rnp7qYlVnvUmaYN7RBNd9DqtBLRmGegl8XXOwf69HbktTKHEDVNYoWBVtrhhTbg6kcYQuKCwWyWqpe3U0zT50RG4utkw6FF17EurxRzOL3RkliT5qJL7zNr9lDn7D7D1EV1HlH6+YDVD1+LG417lkak0AuPub/nXo3+bvp6vnGoBMqv+zpb7Qsqk3+88CGddwe7wSNzksujgKuJ7LjWSPxrvUwqSr8egzrc9WUX2ePhdB34pu1DB81IuiIh1AVsnprkuG3cGfhN6DXp1vn4+q/1LKsRA4b0OZTaQ 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: List-Subscribe: List-Unsubscribe: Break up the list of folios into batches here so that the folios are more likely to be cache hot when doing the rest of the processing. Signed-off-by: Matthew Wilcox (Oracle) --- mm/swap.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index ee8b131bf32c..ad3f2e9448a4 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -138,22 +138,25 @@ EXPORT_SYMBOL(__folio_put); */ void put_pages_list(struct list_head *pages) { - struct folio *folio, *next; + struct folio_batch fbatch; + struct folio *folio; - list_for_each_entry_safe(folio, next, pages, lru) { - if (!folio_put_testzero(folio)) { - list_del(&folio->lru); + folio_batch_init(&fbatch); + list_for_each_entry(folio, pages, lru) { + if (!folio_put_testzero(folio)) continue; - } if (folio_test_large(folio)) { - list_del(&folio->lru); __folio_put_large(folio); continue; } /* LRU flag must be clear because it's passed using the lru */ + if (folio_batch_add(&fbatch, folio) > 0) + continue; + free_unref_folios(&fbatch); } - free_unref_page_list(pages); + if (fbatch.nr) + free_unref_folios(&fbatch); INIT_LIST_HEAD(pages); } EXPORT_SYMBOL(put_pages_list);