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 55B6AC433FE for ; Fri, 29 Apr 2022 19:24:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 319676B0096; Fri, 29 Apr 2022 15:24:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A2CA6B0098; Fri, 29 Apr 2022 15:24:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A6F36B0099; Fri, 29 Apr 2022 15:24:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id E22066B0096 for ; Fri, 29 Apr 2022 15:24:03 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9349425E64 for ; Fri, 29 Apr 2022 19:24:03 +0000 (UTC) X-FDA: 79410891966.13.8D56052 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP id 770D180075 for ; Fri, 29 Apr 2022 19:23:59 +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=UygGnB9sQ4Q/ZF3i0wXjwJgME7 P1fkYi8ntKHNnqxwQ8SfD5Qr3/qFqY2HN/6h8rNuEujmhBvIeFV/84hTmgq6XOW/cWT5QRVCDHD60 r+DZ4e/R9jbF6sj4MbV3HlMueLcB2maoidGijaHkMmJZzq5pW7kwJ3jbiDIT7am+zPp/sYUrbO1lz SKpKGCzxV1ZcdpUa7vVAqlmx9s4kQIMKPOTm0aSR2BsyIFtndT8CseImms5ieQ7EzkDygKJiIizK1 Ftcu4XPZ7IXo5LC2G0t3UO/+Prrfh6QOMzuojCSsJHYrjt+Po80oQ69SYHhySbxSA9fI3KxPdmbsE P1xbe9Ug==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nkWDJ-00CjOz-N3; Fri, 29 Apr 2022 19:23:37 +0000 From: "Matthew Wilcox (Oracle)" To: akpm@linuxfoundation.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 09/21] vmscan: Convert page buffer handling to use folios Date: Fri, 29 Apr 2022 20:23:17 +0100 Message-Id: <20220429192329.3034378-10-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220429192329.3034378-1-willy@infradead.org> References: <20220429192329.3034378-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 770D180075 X-Stat-Signature: 8jnpo3b6ry14dc854e6icap7jzewcbn9 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=UygGnB9s; dmarc=none; spf=none (imf02.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspam-User: X-HE-Tag: 1651260239-528211 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