From patchwork Mon Aug 21 20:44:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13359802 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 4523AEE49A5 for ; Mon, 21 Aug 2023 20:44:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD571940010; Mon, 21 Aug 2023 16:44:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C6F21940015; Mon, 21 Aug 2023 16:44:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D343940013; Mon, 21 Aug 2023 16:44:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 741F8940010 for ; Mon, 21 Aug 2023 16:44:41 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4E7301A06EF for ; Mon, 21 Aug 2023 20:44:41 +0000 (UTC) X-FDA: 81149290362.25.7FB6CEE Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf17.hostedemail.com (Postfix) with ESMTP id A289840002 for ; Mon, 21 Aug 2023 20:44:39 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tLZ3qEXl; 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=1692650679; 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=XRi9y87QqXh4JZ1r/Njdw8M+xnng3qBCOABUAXt/gvk=; b=F9QZCe3IodspcV6gYezfHdNwgLZi2p0/rfLNH2GU+kRFqw1o99a7D7OkLwlSDmLJ043Bbq PS0zAGStUz8UxomNJ0ZHpm0BcX6l76ql5x0pZR3RmVdlzv5nd9LbYxW7aZEQimpKNZf6d8 9DQcWWPiX6lEpkBoDcGg8M/56vbCtFQ= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tLZ3qEXl; 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692650679; a=rsa-sha256; cv=none; b=Cm77Cw3MZoKOaKPcQkn98/9z4qE5qO8+4emSCZZGLcr9SrikxCxlKEQP669XQovR711diE n7NP5Hdq9oXk+XTxBxYk+QMRlAqLwL+TXDbvZn5GzB8g2GBgKKTs3CJN3Mk4FH1cqg9CaB uwGdSQA5qJDn/hobnTTxJ4w30DeORgk= 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=XRi9y87QqXh4JZ1r/Njdw8M+xnng3qBCOABUAXt/gvk=; b=tLZ3qEXllptACApUZPH235uOkb aThCwnrkMLDWUHcF9GtWTqx3jKpPdBX4/PfR8p0avHhtlsbSI7K0SOA87zZo19o0xFiisQoDR9zmy yukem8YeS7ZPMv1v/XH3oCQIO+Ch64oLqjVTBRjuL2ACD2r1fKNxBjovhH16h42r28DEl5pzvNwUR NcfxgknnO1iWC0NnDPkrK+5gqa6mFnQx5bN8HMY7Uu2ZNlNK6X4WjGNubRiac+NWyzcijOPUcV4eH NBphd5Z7PmwM1uyl/DYOTuxF+ZwSJDUI99VbMKZbbtJsX3fSJlZT8pINjV0KwTHd0mARG+4f0LapW dRaj01nw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qYBlF-00CL0U-Mc; Mon, 21 Aug 2023 20:44:29 +0000 From: "Matthew Wilcox (Oracle)" To: Mateusz Guzik , linux-kernel@vger.kernel.org, dennis@kernel.org, tj@kernel.org, cl@linux.com, akpm@linux-foundation.org, shakeelb@google.com, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 6/7] mm: Remove use of folio list from folios_put() Date: Mon, 21 Aug 2023 21:44:24 +0100 Message-Id: <20230821204425.2940496-6-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230821204425.2940496-1-willy@infradead.org> References: <20230821204425.2940496-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: A289840002 X-Rspam-User: X-Stat-Signature: msfbjfnz3tk4fzefokhioqhxsw9cma5r X-Rspamd-Server: rspam01 X-HE-Tag: 1692650679-724317 X-HE-Meta: U2FsdGVkX18MBQM9eaF8/45+hpxk1GicmJ+PWNnF+FVecyUNJ56XlosJln3dGQHTTppDJgXYD+4IT8CEpQAz8A+dINl76DTH8MK+Jwm0lgXRuF8He08/CExiTpGO2PsXPXclyttkxc3EpkULkZ5IGzKwvkgpVXHtDCqAg8JO2lg78/efb3W8BxVThjfwtk9MWoGnHgeO6W7zgUth63gVCytvhIeJJqFIRxIiFZuJYNRME3EZyWSiYd0enbdmlWJR47gqwDlNTZhqU7hG6tARGJFKfks7mZ2305P6G3NIsa/hrgWDTV5sKEMbm8GXvsB1rfXnDngFwW5digzg4aSYiAuGBFjP2HRsDdUYXy33efPaoRkZq1Oeg8JpFjeGKh0bD5TuV/P6MTVoZDdAlQohncpNJmg0zSnpD83EEDAiPo2zzKcSom3WZ87cyat7ryFTM3gPMIDmUMvsK/hQwSAyAg6bcwufKYicx/gTJC2rkJa+PlngVJodS33pqe5g3iKVBbAxZiJOz/nhcVDhP435z9dGFtUh01AM+d1akRExCOBn1yrYrwll6aFMKVjav6yTZFXU2XgA7s4btqXdzQRan7SfS50Q7sImQXFH7SomNC9cVkwBZ5sLiwdOMpDjEtUdveoyJJ//zQgr1DpyJniOcAR4zewoa1K3SpLxi6Audfr0RbUPUPXUY9I5mT5CrMgX12VZF3//a8vlryvoZj95Z6ag9RR2S9LPW9EkqrFPqbzArZG6FAmIO8KINgYWphqorR1fllmW6RDqdaBWrSEzgtm5A3rI7KMk9802gvUc0kTXpimxvSsLaU0vgHYMki8wX7pLsqUO+ctWFPh6Cj3XltKduIttsxx07W24C5wpmaa9fqmE/JPQ1kDTU3aiBAk1csHyLolTfe0LGd93wE7RN6Xrg955VUuMWwBkr9U8Z/qCoXN6tiAnWQsHQQitMpBvelN/7vfhsz+Lzv9k5XB xRUtlXBl p6NxuvfA+nhMXe+QkDfzIV5PFuRFFn5vaMpZpGEKuG92SNf3sWRh6G8M7qBG0RR2z2zgA9HVrxW7DuOtzBBAZRcAs7NGCK9Y8mHs39Xvb3L+V3ovtN6Y7wGOuCe0A1Qf4OBvPX8IdiA8P2gXHOvxairfUWo7NSERzUFjwXfhIexM3uXdrUX0/BA/n206o3NgpSfh+AeBZmMLGAnnxvqSgzdX3VvzrvunzwwXc 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) --- mm/swap.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index 9d31185dc27b..8ebb10d44de7 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -958,12 +958,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)) @@ -1012,13 +1011,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); + mem_cgroup_uncharge_batch(folios); + free_unref_folios(folios); } EXPORT_SYMBOL(folios_put);