From mboxrd@z Thu Jan 1 00:00:00 1970 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 56634C433F5 for ; Wed, 4 May 2022 18:29:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE68D6B0088; Wed, 4 May 2022 14:29:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B8596B0087; Wed, 4 May 2022 14:29:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 394416B007E; Wed, 4 May 2022 14:29:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D4D796B0082 for ; Wed, 4 May 2022 14:29:04 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A7D652A5B6 for ; Wed, 4 May 2022 18:29:04 +0000 (UTC) X-FDA: 79428897408.06.6104DE6 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id 6DDA4A008A for ; Wed, 4 May 2022 18:28:55 +0000 (UTC) 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=VouUEevqAJoImC1PsqzC77NF117LJuXxB1hfk11vLmg=; b=uGU6mybcJfY5e5dbeJfGJfLSdC YUPvy3JiqRqhX+qfD+jXSjKVuk5SCoVhas7wsMhfzBUmDaz5zf6SpOZJaiUi29oE5VvvB56iiiBnv PVVbzxwDOIYOuwqfQCbWqwX4XadBGuqcBsxxYouB6s4fygXItllWxVEtvz7mX5Sbqp0CkTeGBaIi+ mGdKFJZqGMFU6XCvakfnLOF8Gx+ILMQYoUg/eQZKHV7sBH2Aa2Ln/qQltOW/BuhF2Hnt+sINT0aAe z47PJWYNoWCZm7MgoqY+2DGxfS9wKvjL5j3PpwJOvLFtG9DeoEumBWVMu5eLjPb3+qgI7FW4TXgc0 ALArphmQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nmJkE-00Gq6h-Po; Wed, 04 May 2022 18:29:02 +0000 From: "Matthew Wilcox (Oracle)" To: akpm@linuxfoundation.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH v2 10/26] vmscan: Convert page buffer handling to use folios Date: Wed, 4 May 2022 19:28:41 +0100 Message-Id: <20220504182857.4013401-11-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220504182857.4013401-1-willy@infradead.org> References: <20220504182857.4013401-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 6DDA4A008A Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=uGU6mybc; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspam-User: X-Stat-Signature: m6hqerer1ooet9sin5frjmnexqkyd1nw X-HE-Tag: 1651688935-663856 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: This mostly just removes calls to compound_head() although nr_reclaimed should be incremented by the number of pages, not just 1. Signed-off-by: Matthew Wilcox (Oracle) --- mm/vmscan.c | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 950eeb2f759b..cda43f0bb285 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1840,42 +1840,44 @@ static unsigned int shrink_page_list(struct list_head *page_list, } /* - * If the page has buffers, try to free the buffer mappings - * associated with this page. If we succeed we try to free - * the page as well. + * If the folio has buffers, try to free the buffer + * mappings associated with this folio. If we succeed + * we try to free the folio as well. * - * We do this even if the page is PageDirty(). - * try_to_release_page() does not perform I/O, but it is - * possible for a page to have PageDirty set, but it is actually - * clean (all its buffers are clean). This happens if the - * buffers were written out directly, with submit_bh(). ext3 - * will do this, as well as the blockdev mapping. - * try_to_release_page() will discover that cleanness and will - * drop the buffers and mark the page clean - it can be freed. + * We do this even if the folio is dirty. + * filemap_release_folio() does not perform I/O, but it + * is possible for a folio to have the dirty flag set, + * but it is actually clean (all its buffers are clean). + * This happens if the buffers were written out directly, + * with submit_bh(). ext3 will do this, as well as + * the blockdev mapping. filemap_release_folio() will + * discover that cleanness and will drop the buffers + * and mark the folio clean - it can be freed. * - * Rarely, pages can have buffers and no ->mapping. These are - * the pages which were not successfully invalidated in - * truncate_cleanup_page(). We try to drop those buffers here - * and if that worked, and the page is no longer mapped into - * process address space (page_count == 1) it can be freed. - * Otherwise, leave the page on the LRU so it is swappable. + * Rarely, folios can have buffers and no ->mapping. + * These are the folios which were not successfully + * invalidated in truncate_cleanup_folio(). We try to + * drop those buffers here and if that worked, and the + * folio is no longer mapped into process address space + * (refcount == 1) it can be freed. Otherwise, leave + * the folio on the LRU so it is swappable. */ - if (page_has_private(page)) { - if (!try_to_release_page(page, sc->gfp_mask)) + if (folio_has_private(folio)) { + if (!filemap_release_folio(folio, sc->gfp_mask)) goto activate_locked; - if (!mapping && page_count(page) == 1) { - unlock_page(page); - if (put_page_testzero(page)) + if (!mapping && folio_ref_count(folio) == 1) { + folio_unlock(folio); + if (folio_put_testzero(folio)) goto free_it; else { /* * rare race with speculative reference. * the speculative reference will free - * this page shortly, so we may + * this folio shortly, so we may * increment nr_reclaimed here (and * leave it off the LRU). */ - nr_reclaimed++; + nr_reclaimed += nr_pages; continue; } } -- 2.34.1