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 3CF94C43334 for ; Fri, 17 Jun 2022 15:43:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C95096B0096; Fri, 17 Jun 2022 11:43:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C448D6B0098; Fri, 17 Jun 2022 11:43:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0CD46B0099; Fri, 17 Jun 2022 11:43:04 -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 9ECB16B0096 for ; Fri, 17 Jun 2022 11:43:04 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 70C1F35040 for ; Fri, 17 Jun 2022 15:43:04 +0000 (UTC) X-FDA: 79588146288.26.40AA34D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 168A7180086 for ; Fri, 17 Jun 2022 15:43:03 +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=tP911piPgchHpikeDPLHcbSC30+KA06kleWPz/AymWg=; b=VQpm0tVtNLh6P0OkFyhnqtJFuY /hayPATpdSo/o74NUJtvS0wpnJaA6ANtFHY9tHR+gPlq+2W6UErtg6p6Jh4tIOfSVcwo3P5LLC6gX 1HBbutKMtTuj2Kqxmm4LriuQvLPTfqrFHV+TODlgvVejJmkeeXTAkcaT4Ao+RXWvsLslBvlsAOv80 t6a+I7lt3+IRmhtCGhw2DXcwfKJhfl78I00onsocVvGaJ0kMuCTzBd9Ujno0hqadEnZGVj7I004wy XkM4v/eo1UcKfac+AESKJx2xn6GBUyy49QC5KWRBCIIhdqQlqs6B4xpLnCjA5umVAcBVXrjP1pJb4 JMN9Lyeg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o2E7W-002wEh-Ad; Fri, 17 Jun 2022 15:42:50 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 1/5] mm/vmscan: Convert reclaim_clean_pages_from_list() to folios Date: Fri, 17 Jun 2022 16:42:44 +0100 Message-Id: <20220617154248.700416-2-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220617154248.700416-1-willy@infradead.org> References: <20220617154248.700416-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=VQpm0tVt; dmarc=none; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655480584; 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=tP911piPgchHpikeDPLHcbSC30+KA06kleWPz/AymWg=; b=e+9hbvdGmijcy1GExJz3OLhqEII5Jl/Sh5c12YeRoEe11d+uEqwouNSGyBECS8zG4MNVkt R0aMPu8Prdnn/dsj1HYSpHFzwTCSXdJ048lX/aYcbjpvum25mzkMVQPqVhv/oy/Z7LiqU4 W2/zF8ewkrdr3SakW30ijudIj/rfI4I= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655480584; a=rsa-sha256; cv=none; b=j81vtidh0D+yngYSbcIZI9qmETrzLg4Va95Zx7jEg3DpTmkTbqLXsLBCFjxD5WjoX6i8Nt gPKhdu9XYNmXs/5f2eoDXvasJGMRzESxNti2N6cmwJXGgJBR6b4NKsR50CJSiVajZKe7S6 d1DkxA6kv4CiHoMg577OygNAMTE4YLo= X-Stat-Signature: gd6sh9pq38b5oa3mwbxn6cbhezdjz3ck X-Rspamd-Queue-Id: 168A7180086 X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=VQpm0tVt; dmarc=none; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam10 X-HE-Tag: 1655480583-433677 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 is a straightforward conversion which removes several hidden calls to compound_head, saving 330 bytes of kernel text. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/page-flags.h | 6 ++++++ mm/vmscan.c | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index e66f7aa3191d..f32aade2a6e0 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -670,6 +670,12 @@ static __always_inline bool PageAnon(struct page *page) return folio_test_anon(page_folio(page)); } +static __always_inline bool __folio_test_movable(const struct folio *folio) +{ + return ((unsigned long)folio->mapping & PAGE_MAPPING_FLAGS) == + PAGE_MAPPING_MOVABLE; +} + static __always_inline int __PageMovable(struct page *page) { return ((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) == diff --git a/mm/vmscan.c b/mm/vmscan.c index f7d9a683e3a7..6c7184f333bf 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1987,7 +1987,7 @@ static unsigned int shrink_page_list(struct list_head *page_list, } unsigned int reclaim_clean_pages_from_list(struct zone *zone, - struct list_head *page_list) + struct list_head *folio_list) { struct scan_control sc = { .gfp_mask = GFP_KERNEL, @@ -1995,16 +1995,16 @@ unsigned int reclaim_clean_pages_from_list(struct zone *zone, }; struct reclaim_stat stat; unsigned int nr_reclaimed; - struct page *page, *next; - LIST_HEAD(clean_pages); + struct folio *folio, *next; + LIST_HEAD(clean_folios); unsigned int noreclaim_flag; - list_for_each_entry_safe(page, next, page_list, lru) { - if (!PageHuge(page) && page_is_file_lru(page) && - !PageDirty(page) && !__PageMovable(page) && - !PageUnevictable(page)) { - ClearPageActive(page); - list_move(&page->lru, &clean_pages); + list_for_each_entry_safe(folio, next, folio_list, lru) { + if (!folio_test_hugetlb(folio) && folio_is_file_lru(folio) && + !folio_test_dirty(folio) && !__folio_test_movable(folio) && + !folio_test_unevictable(folio)) { + folio_clear_active(folio); + list_move(&folio->lru, &clean_folios); } } @@ -2015,11 +2015,11 @@ unsigned int reclaim_clean_pages_from_list(struct zone *zone, * change in the future. */ noreclaim_flag = memalloc_noreclaim_save(); - nr_reclaimed = shrink_page_list(&clean_pages, zone->zone_pgdat, &sc, + nr_reclaimed = shrink_page_list(&clean_folios, zone->zone_pgdat, &sc, &stat, true); memalloc_noreclaim_restore(noreclaim_flag); - list_splice(&clean_pages, page_list); + list_splice(&clean_folios, folio_list); mod_node_page_state(zone->zone_pgdat, NR_ISOLATED_FILE, -(long)nr_reclaimed); /* -- 2.35.1