From patchwork Wed Jun 21 16:45:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13287668 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 B2AA2EB64DD for ; Wed, 21 Jun 2023 16:46:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 800F58D0006; Wed, 21 Jun 2023 12:46:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13A268D000D; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 926628D0006; Wed, 21 Jun 2023 12:46:06 -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 452768D000A for ; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0F328B02CA for ; Wed, 21 Jun 2023 16:46:06 +0000 (UTC) X-FDA: 80927332332.24.01CA071 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf21.hostedemail.com (Postfix) with ESMTP id 212C61C0006 for ; Wed, 21 Jun 2023 16:46:03 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=SA7wCjqc; spf=none (imf21.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=1687365964; 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=/u3R6ommui0jzmNm5KqQbCKjAYY2UMYMLfe/n8/4JuI=; b=atDuVY91wX/2cMHPZZ3HAB5ulPf/dIYGGOF/hZEiLgxKW1GguDlqTcSc5wAOHGCA2VbFP6 /q4MHUwid2rdVxVxbBOHJ9cPQQmGWETusdLmxMDm34i4aihlnvBdhqGlBmebx3q3Q6lziS JHXRoJicxf+GGf/L1QGdBGQDakwXUD4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=SA7wCjqc; spf=none (imf21.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=1687365964; a=rsa-sha256; cv=none; b=e8PB+MJREmPoIeCK6zrm2x+9ecDJ2JkOrtUyQDnGJqumSMPBBErBtVN0N8YdCRfLa5UDX+ tN0TNs8bXLwldoJrFa9tAAMhzt0QbNXIXcZUVvH7FjFJ2MxPuK+hPT2NsD2DkUrym1w/7M G5/0PLuRo+sv/VVkOIG/kIJ8Szg0j3g= 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=/u3R6ommui0jzmNm5KqQbCKjAYY2UMYMLfe/n8/4JuI=; b=SA7wCjqcWMwZI6QRZjnXU4BdsS H2NVvLwwEgWYTdDfqbIir6UM//Pdysn6BSpEU5tQrwXLiUi9lYRn6b1kZ9qx1fAUBvXd7kLDwwkhY 5AAQLBbNy1luSMqNDTeWh+iK0WGYWrfqKDGYqZciSOpheoDHNVBuHpWm43NXX9E4ZJXfruCyIH/UW HB+wG8b8HwLzzjf53mwVPcA53m7cznZE0yRcrwmRkU0fOjoCKs9ya07eXP9QmjjMztGSPQSsClls5 jOcuaSGUbCg3/YuJMblU2LvWjfE9SoN7h5k2L6Zq6mpZcMsd5xCOJiy9+fCqNLsH/jrQq/u4kXAFF K/koQlnw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qC0y2-00EjEX-9H; Wed, 21 Jun 2023 16:46:02 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 10/13] mm: Remove struct pagevec Date: Wed, 21 Jun 2023 17:45:54 +0100 Message-Id: <20230621164557.3510324-11-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230621164557.3510324-1-willy@infradead.org> References: <20230621164557.3510324-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 212C61C0006 X-Rspam-User: X-Stat-Signature: rq97zf9dfzf7r8c4jbgo7tnep5don83f X-Rspamd-Server: rspam01 X-HE-Tag: 1687365963-469386 X-HE-Meta: U2FsdGVkX1/5+cQtt8W17/AwehMKLtvOuyqbpGTOfB1Ycg0qGlLCJHT5s0ewKGKfkCaU3/KBCqgWwzyZuT904vOfDjCBCH0juWrQDBvJveIyvn1/upDfC8DT1weaIorPtw5oXc0dT6Ie0mPr7JdMIL8Ij4rejeOBRIivMz/SUpPPJRDO7BffbjEC3vn52bsQHp7kfEcTvKhICBR+pUJGOE7ldzo0K/TpKzxt7VuwtUDH/D9bplz9JqqQf+IAOAem9XFUauHLukfT0Y245i/s/hvlRNk9VynkB4e1zejnQoMFqRkK7+ZooeTcR8kmcipRRGCBnR3AEVXzK4O/CxqEB097gguWmv9XjRTRhkD6JsViR/ldEGhY3GhBeCAiuHUUXO4cvkLeKmp9Jq/1OH6u12CfxsBj2LlolIASZO1Wq+mSUQDC/SJtbE4b5yvFkBzpbGY9+2Xaqib3iGc8WaS+NxpuL9gW9CzvKtfAaq/syOGHUWGfSzPtiE8SAIalAjEzH+ekFPvCBh3h2N/90VERuK3sn1uF2Amt1yOhP2Ys6RHqqpOpLYOZCduxVD0k1OsigUjIf1wZqrDwvQ8LaFNHI4ofqNYkOeEDgam0G33pShKhcGLDIjjf5rcqbBUWS2PkNB69GRBvgEwOtJlqWF/OUXxQLW4YijZlp/upTeNmOxXAz6znrAPdvQRI7AlTxeWLVYxkN0hwlo700fEDlkmp0zaIMcREiEgPrsTqJwlvkXOw+PcKYq78m2MaNp1IxzC5blyeCXtN3VGC2YnT/6ELGIUpQplGfXxygvgqfBJRffmdNsSjiqN5bRfCqvNHG8AH0Fw2FuBW5AC4WBLNo75Z22ZtWc6vYrdjJUVpfWpqAAQm2lpQltHs7Akvy6oAAJcCD8XavD6L/nWLzPJBwEgkR9LeQqhzfot4XMajaWkK3o5T5cWJkY2JG+s+HTf8ueC6FszKqhZ+sybaUOq1WI0 irPkHDDH u22WtPrb14hfAatLrelZxEsezVNdmeeKDP7UGY9WbPGKuWcYmCIJSky01y/+yYq0VybfXI1KNxJaLb+2U1uZRGAotQN4hgH/TDQPxwr/MbrQ1gDXhhvSvFyOlBaJBALKPGWIUOr4+F30hqjZQY9JiGB3oc96wrM9qsUZNAkd/JdlaDHg5ml3OUJidfg== 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: All users are now converted to use the folio_batch so we can get rid of this data structure. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagevec.h | 63 +++-------------------------------------- mm/swap.c | 18 ++++++------ 2 files changed, 13 insertions(+), 68 deletions(-) diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 3a9d29dd28a3..87cc678adc85 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -3,65 +3,18 @@ * include/linux/pagevec.h * * In many places it is efficient to batch an operation up against multiple - * pages. A pagevec is a multipage container which is used for that. + * folios. A folio_batch is a container which is used for that. */ #ifndef _LINUX_PAGEVEC_H #define _LINUX_PAGEVEC_H -#include +#include -/* 15 pointers + header align the pagevec structure to a power of two */ +/* 15 pointers + header align the folio_batch structure to a power of two */ #define PAGEVEC_SIZE 15 -struct page; struct folio; -struct address_space; - -/* Layout must match folio_batch */ -struct pagevec { - unsigned char nr; - bool percpu_pvec_drained; - struct page *pages[PAGEVEC_SIZE]; -}; - -void __pagevec_release(struct pagevec *pvec); - -static inline void pagevec_init(struct pagevec *pvec) -{ - pvec->nr = 0; - pvec->percpu_pvec_drained = false; -} - -static inline void pagevec_reinit(struct pagevec *pvec) -{ - pvec->nr = 0; -} - -static inline unsigned pagevec_count(struct pagevec *pvec) -{ - return pvec->nr; -} - -static inline unsigned pagevec_space(struct pagevec *pvec) -{ - return PAGEVEC_SIZE - pvec->nr; -} - -/* - * Add a page to a pagevec. Returns the number of slots still available. - */ -static inline unsigned pagevec_add(struct pagevec *pvec, struct page *page) -{ - pvec->pages[pvec->nr++] = page; - return pagevec_space(pvec); -} - -static inline void pagevec_release(struct pagevec *pvec) -{ - if (pagevec_count(pvec)) - __pagevec_release(pvec); -} /** * struct folio_batch - A collection of folios. @@ -78,11 +31,6 @@ struct folio_batch { struct folio *folios[PAGEVEC_SIZE]; }; -/* Layout must match pagevec */ -static_assert(sizeof(struct pagevec) == sizeof(struct folio_batch)); -static_assert(offsetof(struct pagevec, pages) == - offsetof(struct folio_batch, folios)); - /** * folio_batch_init() - Initialise a batch of folios * @fbatch: The folio batch. @@ -127,10 +75,7 @@ static inline unsigned folio_batch_add(struct folio_batch *fbatch, return folio_batch_space(fbatch); } -static inline void __folio_batch_release(struct folio_batch *fbatch) -{ - __pagevec_release((struct pagevec *)fbatch); -} +void __folio_batch_release(struct folio_batch *pvec); static inline void folio_batch_release(struct folio_batch *fbatch) { diff --git a/mm/swap.c b/mm/swap.c index 423199ee8478..10348c1cf9c5 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -1044,25 +1044,25 @@ void release_pages(release_pages_arg arg, int nr) EXPORT_SYMBOL(release_pages); /* - * The pages which we're about to release may be in the deferred lru-addition + * The folios which we're about to release may be in the deferred lru-addition * queues. That would prevent them from really being freed right now. That's - * OK from a correctness point of view but is inefficient - those pages may be + * OK from a correctness point of view but is inefficient - those folios may be * cache-warm and we want to give them back to the page allocator ASAP. * - * So __pagevec_release() will drain those queues here. + * So __folio_batch_release() will drain those queues here. * folio_batch_move_lru() calls folios_put() directly to avoid * mutual recursion. */ -void __pagevec_release(struct pagevec *pvec) +void __folio_batch_release(struct folio_batch *fbatch) { - if (!pvec->percpu_pvec_drained) { + if (!fbatch->percpu_pvec_drained) { lru_add_drain(); - pvec->percpu_pvec_drained = true; + fbatch->percpu_pvec_drained = true; } - release_pages(pvec->pages, pagevec_count(pvec)); - pagevec_reinit(pvec); + release_pages(fbatch->folios, folio_batch_count(fbatch)); + folio_batch_reinit(fbatch); } -EXPORT_SYMBOL(__pagevec_release); +EXPORT_SYMBOL(__folio_batch_release); /** * folio_batch_remove_exceptionals() - Prune non-folios from a batch.