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 9D3FBC433F5 for ; Wed, 4 May 2022 18:29:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65E906B007B; Wed, 4 May 2022 14:29:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D1066B0078; 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 012456B0080; Wed, 4 May 2022 14:29:04 -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 B3FF86B0081 for ; Wed, 4 May 2022 14:29:04 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8B9AC165C for ; Wed, 4 May 2022 18:29:04 +0000 (UTC) X-FDA: 79428897408.20.0928565 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf20.hostedemail.com (Postfix) with ESMTP id 96C3F1C009D for ; Wed, 4 May 2022 18:28:57 +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=cn5OhfkY+HX3+evyy98EyBGWIVQZySLtCMdQHTOXi3c=; b=rNGiayjY7HGU5hxzL2bRwgMVCk 96umsa/mlfTByY6Y+HsziEN88ghY8gAie9U/mfe8X3P4vniSl567C6h7Ig2W1D4Cq7IAWEmMIPoYx IglCQMFp0erlY/D4xaHUYbHoSlETrXuKEK7nBkumC20YYeOLOJXN47qDsC2FOWQdNF6aJCLzyZPx7 Ocsj+0F6+pkcR1UnhY4/MoX0+qpnjCcNhY7H1pfNrjrSC4iDCpW3y2EMEgQ2LgkAy17uEikAwPckQ bWbjXof3R0td+uGAdWJZLps8C9CPIj+MpaUWO9COYPoBDnKOZ0YK+c1GoV+yoCS65sxp1VXN+KhcO fwffVDdw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nmJkE-00Gq6Z-KN; 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 09/26] vmscan: Convert dirty page handling to folios Date: Wed, 4 May 2022 19:28:40 +0100 Message-Id: <20220504182857.4013401-10-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-Stat-Signature: xkhyaoqy8eu6nyq9y4q8n5k7maqenjwu X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 96C3F1C009D Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=rNGiayjY; spf=none (imf20.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-HE-Tag: 1651688937-659130 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: Mostly this just eliminates calls to compound_head(), but NR_VMSCAN_IMMEDIATE was being incremented by 1 instead of by nr_pages. Signed-off-by: Matthew Wilcox (Oracle) --- mm/vmscan.c | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 8f7c32b3d65e..950eeb2f759b 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1768,28 +1768,31 @@ static unsigned int shrink_page_list(struct list_head *page_list, } } - if (PageDirty(page)) { + if (folio_test_dirty(folio)) { /* - * Only kswapd can writeback filesystem pages + * Only kswapd can writeback filesystem folios * to avoid risk of stack overflow. But avoid - * injecting inefficient single-page IO into + * injecting inefficient single-folio I/O into * flusher writeback as much as possible: only - * write pages when we've encountered many - * dirty pages, and when we've already scanned - * the rest of the LRU for clean pages and see - * the same dirty pages again (PageReclaim). + * write folios when we've encountered many + * dirty folios, and when we've already scanned + * the rest of the LRU for clean folios and see + * the same dirty folios again (with the reclaim + * flag set). */ - if (page_is_file_lru(page) && - (!current_is_kswapd() || !PageReclaim(page) || + if (folio_is_file_lru(folio) && + (!current_is_kswapd() || + !folio_test_reclaim(folio) || !test_bit(PGDAT_DIRTY, &pgdat->flags))) { /* * Immediately reclaim when written back. - * Similar in principal to deactivate_page() - * except we already have the page isolated + * Similar in principle to deactivate_page() + * except we already have the folio isolated * and know it's dirty */ - inc_node_page_state(page, NR_VMSCAN_IMMEDIATE); - SetPageReclaim(page); + node_stat_mod_folio(folio, NR_VMSCAN_IMMEDIATE, + nr_pages); + folio_set_reclaim(folio); goto activate_locked; } @@ -1802,8 +1805,8 @@ static unsigned int shrink_page_list(struct list_head *page_list, goto keep_locked; /* - * Page is dirty. Flush the TLB if a writable entry - * potentially exists to avoid CPU writes after IO + * Folio is dirty. Flush the TLB if a writable entry + * potentially exists to avoid CPU writes after I/O * starts and then write it out here. */ try_to_unmap_flush_dirty(); @@ -1815,23 +1818,24 @@ static unsigned int shrink_page_list(struct list_head *page_list, case PAGE_SUCCESS: stat->nr_pageout += nr_pages; - if (PageWriteback(page)) + if (folio_test_writeback(folio)) goto keep; - if (PageDirty(page)) + if (folio_test_dirty(folio)) goto keep; /* * A synchronous write - probably a ramdisk. Go - * ahead and try to reclaim the page. + * ahead and try to reclaim the folio. */ - if (!trylock_page(page)) + if (!folio_trylock(folio)) goto keep; - if (PageDirty(page) || PageWriteback(page)) + if (folio_test_dirty(folio) || + folio_test_writeback(folio)) goto keep_locked; - mapping = page_mapping(page); + mapping = folio_mapping(folio); fallthrough; case PAGE_CLEAN: - ; /* try to free the page below */ + ; /* try to free the folio below */ } } -- 2.34.1