From patchwork Fri Aug 25 13:59:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13365795 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 AD40FC3DA6F for ; Fri, 25 Aug 2023 13:59:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B90E48E0015; Fri, 25 Aug 2023 09:59:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94F492800BC; Fri, 25 Aug 2023 09:59:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44C8A2800C1; Fri, 25 Aug 2023 09:59:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EEABD2800BC for ; Fri, 25 Aug 2023 09:59:25 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C0A14140680 for ; Fri, 25 Aug 2023 13:59:25 +0000 (UTC) X-FDA: 81162784290.18.9FCB7DF Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id 4A336C0009 for ; Fri, 25 Aug 2023 13:59:23 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=n3bum2yu; spf=none (imf22.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=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=avt2avNOh89/3L7dWAiTvZAWsRknkyYwpYTeBU8nK8A=; b=2fwmseYbxw9j3h62vH/O1rhIbmD++dQCfmxkHyqRWJJn/QRUQYthAl09LtCm7Pz3rIBrN4 agyMsSKVuZFY1tDQvnlm89Bo19Lbcmepu7BUba/TYTJuo8JN8438gtbJBfeNoTwSKWMWm6 gVOLjQF/UChsczNIUsUcmKpHJAiLIK0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692971964; a=rsa-sha256; cv=none; b=ZUpOXnMDICUXSkoCX+Dw0JojVObJ7Z+Dlxc6lan+T2cnJRH+6rE6EWTMMELV0pCTsLUJ2X vmhc3S56eima8BA8BV3prisMZg0UT5FFdDqJbSNY4mLxpt847mH8jP84a1gXM7YbTIVP3o asmrEBZ1rA8GeDUeN9tRKJ9BrQ7oB9E= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=n3bum2yu; spf=none (imf22.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=avt2avNOh89/3L7dWAiTvZAWsRknkyYwpYTeBU8nK8A=; b=n3bum2yuaVGsB7EMC21buK0yN5 MTiBmF5JNn1VFyBAc6xbTTOmAcvMN6S0ja0m2e8i19i6axSwawaEyVejEtE131mx1q/4NU6aWQ5Ta KKCQMlNKi3PYJMfuUiml6Byx1sF+5PxnHn8E/fK1Kz+1dRpNA9HmDGxsDmmmwY5JGaWYCq2BykKVO iGGiGl+/KniQjRyszqmlxxhseTOZtfZzzFSTilTo/zhFJkDT8cM4niVsum41KhsQHWr9+6UPFIzZ5 0I8c5JQ44ROCmc714b1DnONHgxpHwGoPv97SvVTqBM0ABAYFHW1KAnsrsmxJcP0LX5E2Vo3WaXqR4 JgzR6T4w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qZXLN-00HTQy-Mt; Fri, 25 Aug 2023 13:59:21 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [RFC PATCH 07/14] mm: Use free_unref_folios() in put_pages_list() Date: Fri, 25 Aug 2023 14:59:11 +0100 Message-Id: <20230825135918.4164671-8-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-Rspamd-Queue-Id: 4A336C0009 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: g3tucf7q55hnnapxcgykepeewrbrd37c X-HE-Tag: 1692971963-43808 X-HE-Meta: U2FsdGVkX184gttDHtsrA3kv4o0ZlmPNb5VDcauynR8xNRpciYHqom7CHOTJUQ8xxN+4AOhU2NQvyWWMr/+3pWxtXpB2W9qG5YK7qyP19Ri6WlXv6xyjuJUOFHwPhAkReEjJ3nUbojiJRh+YMUIzPn4++MdSCSGAZ4Bo9a0YiW8Iorw5up6EpU/RSFs0z5WtbMS6EInum9kPjin7aaT/AMJiUnhOUmHB6S2re/5Hr/+jO36ErImxmNyZ2Fn5ki4uNB7g3cLKi1EDmpnx1dlXlYYEcGyyf9KVVJblZveXieb060QB96gpTLRW608MAqnf6sjObmIIbZTf4JDflfRcG7pabf66NBbzyF7SkM6o1fgblv7/zophLBINGob1pO8d2NqwImtdS0XisQBMzqeFQL5p/xtxhBKsz5wZ11sB008PzT7xnYwqVT8Bdon3rWp10tSMsiw2ZcMhfJHr+CMtPeaqTenyS6cI4oDQm124LomETPogk5SkS/iRbN50GJiiTF1LRDHeBD8nH/Ht9D1w5X7K0+UhvfoIHOF6uhDI1QkgKh1DA9qvCcuaOwd/jf+3SUc6Y466EDGwLR/XVIp901TsKMgar71Z2PWTTlt7GYIMsLs2hDsavQ2CF9fw0DWoTj5LDGnkPWNH0Zeb2g24FlvMwA/RHJ5LalZhxSjh/HmK/UJcj1x2CdRfjoLgQKgfKPMzDQN1C9gTpf+reBmIHhF36zbHVNFfUcURhzyqWZJxceA6lhAoL93hGEpi9b/hRPd9ui/J6LU67DPLoeez1CxvyKzu5BjB9jV9vyyyoEsp4ijIvOMaP44Ieplc7ox2wOTkK4dlt2pFEDbec6p/xp/hAEk7sxaQDsWsNj2lgasXBxA4BfT3t3LNzBF4w1H7NNCMmUcspVACP5z0mYlT9J5+W1Tgwy6lDhZpzzsdfSj4j+6x/ZL95YSayCjV/Uz860ciDhAphEXH4f426ME uoQARnRD bhq9u/cbNHM/4tduCCQ5RNPFM9ax5kpE0zqvoS/em9NAhj4+GhnK8zQ6YYlHwHO5sm7XahHyhWPOljjaVMp0iC/9PlsZEMxxLg4txFSLFa4BhiC8X6QFPC+YaEGDVUhWrTMSUhRci2NxoMyr9jH91vakqwMssASUGJ9KZGX8E+HlLvcM53fzOxw/9SOxW+DiSMFZH2J7cPLzvbmFSEQJAfbRbpmH3XQ9djwZD 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: 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 6b2f3f77450c..fffdb48cfbf9 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);