From patchwork Fri Nov 3 07:29:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161187 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp855376vqu; Fri, 3 Nov 2023 00:29:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFSkzS+9GCyS8W0GktF/AhLZd75SVzA3n/lfjcEvjBH7TEnAeAh33i6oscN074lx5Z3snRT X-Received: by 2002:a17:902:e88e:b0:1c7:5776:a30f with SMTP id w14-20020a170902e88e00b001c75776a30fmr2701068plg.12.1698996585685; Fri, 03 Nov 2023 00:29:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698996585; cv=none; d=google.com; s=arc-20160816; b=LWMu/9dKyFD1wxElTZE50aAG8OAhWdA4iG4qsiHGh7uClnA+sGPu+RRupuSE8UmzlL Wi6JggmmbfKqvyht9fz0u797rjmSrXllH2eq57T4y+2lEHgchcukHU/PS+1KoLbPCjAq fa3JDhwLJNDApzDp7RAMCNXtIzfCVs6EmJZx7Hj/9Ib+vla2PPNi9G87NuGXUqcu/EPI 8hplfK36l/B49oRwDStkpj//iupAwTTvxzqHB98ixhTQE0An8kDHDrsTUa1yNmAN5p+Q 51VcYBsUf5ZBlvv6gUSzLJVaVTxv593nkpvZU80Y4Ms8UsYodoFfVWuH3mlc/1biDZgK Rp5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ffFsOMCEMvqrtDLA9F7plpO34zh5hKKKwxR41j/1U6k=; fh=Q7tPJ/E8MvXjzgZkYtX4LsRnr2SdvitVhN9e/tMZDyY=; b=qOdBN9zr4cMGWB1HOxN27bHuENkoIyfczM7ELUVQb5GB2I2xONl+puftvmnOuhIvAX s8HeWjwJgmcoGMUbTXB+tsUHR5Vbsr9VV9M0HgnQTJ3RB9tdWEEmF+aXVhOaqcMmhzby j7VyaP/MAUkndBdOX20Iow5eqvHndYidOujDQzUzGjtDtF3p6KUIzIs++AM6Qz45u1gw shNwxbWZU/7HtXxopD3q7ThcWFyucUcXttyNnI1qeBpdSx6t2NfHYR61ZZ+VQmLYW7bF 8BnnOGhvKxBq4Wy6ecmlmnt8hui1FWTMWI1opmQHji7bHQ2JAF88VpMHRvjQaKbdmmNJ x6Kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id j7-20020a170902da8700b001cc50c56980si1120766plx.411.2023.11.03.00.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 00:29:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 85D1F825ED8D; Fri, 3 Nov 2023 00:29:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346169AbjKCH3a (ORCPT + 36 others); Fri, 3 Nov 2023 03:29:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344219AbjKCH3S (ORCPT ); Fri, 3 Nov 2023 03:29:18 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19C7C1A8; Fri, 3 Nov 2023 00:29:16 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SMC6W1mdSzvQJd; Fri, 3 Nov 2023 15:29:07 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 15:29:10 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , Matthew Wilcox , David Hildenbrand , Kefeng Wang Subject: [PATCH 4/5] fs/proc/page: use a folio in stable_page_flags() Date: Fri, 3 Nov 2023 15:29:05 +0800 Message-ID: <20231103072906.2000381-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103072906.2000381-1-wangkefeng.wang@huawei.com> References: <20231103072906.2000381-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 03 Nov 2023 00:29:42 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781527043801821281 X-GMAIL-MSGID: 1781527043801821281 Replace ten compound_head() calls with one page_folio(). Signed-off-by: Kefeng Wang --- fs/proc/page.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 195b077c0fac..94ab0ba13b16 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -109,6 +109,7 @@ static inline u64 kpf_copy_bit(u64 kflags, int ubit, int kbit) u64 stable_page_flags(struct page *page) { + struct folio *folio; u64 k; u64 u; @@ -119,6 +120,7 @@ u64 stable_page_flags(struct page *page) if (!page) return 1 << KPF_NOPAGE; + folio = page_folio(page); k = page->flags; u = 0; @@ -128,11 +130,11 @@ u64 stable_page_flags(struct page *page) * Note that page->_mapcount is overloaded in SLAB, so the * simple test in page_mapped() is not enough. */ - if (!PageSlab(page) && page_mapped(page)) + if (!folio_test_slab(folio) && folio_mapped(folio)) u |= 1 << KPF_MMAP; - if (PageAnon(page)) + if (folio_test_anon(folio)) u |= 1 << KPF_ANON; - if (PageKsm(page)) + if (folio_test_ksm(folio)) u |= 1 << KPF_KSM; /* @@ -152,11 +154,9 @@ u64 stable_page_flags(struct page *page) * to make sure a given page is a thp, not a non-huge compound page. */ else if (PageTransCompound(page)) { - struct page *head = compound_head(page); - - if (PageLRU(head) || PageAnon(head)) + if (folio_test_lru(folio) || folio_test_anon(folio)) u |= 1 << KPF_THP; - else if (is_huge_zero_page(head)) { + else if (is_huge_zero_page(&folio->page)) { u |= 1 << KPF_ZERO_PAGE; u |= 1 << KPF_THP; } @@ -170,7 +170,7 @@ u64 stable_page_flags(struct page *page) */ if (PageBuddy(page)) u |= 1 << KPF_BUDDY; - else if (page_count(page) == 0 && is_free_buddy_page(page)) + else if (folio_ref_count(folio) == 0 && is_free_buddy_page(page)) u |= 1 << KPF_BUDDY; if (PageOffline(page)) @@ -178,13 +178,13 @@ u64 stable_page_flags(struct page *page) if (PageTable(page)) u |= 1 << KPF_PGTABLE; - if (page_is_idle(page)) + if (folio_test_idle(folio)) u |= 1 << KPF_IDLE; u |= kpf_copy_bit(k, KPF_LOCKED, PG_locked); u |= kpf_copy_bit(k, KPF_SLAB, PG_slab); - if (PageTail(page) && PageSlab(page)) + if (PageTail(page) && folio_test_slab(folio)) u |= 1 << KPF_SLAB; u |= kpf_copy_bit(k, KPF_ERROR, PG_error); @@ -197,7 +197,7 @@ u64 stable_page_flags(struct page *page) u |= kpf_copy_bit(k, KPF_ACTIVE, PG_active); u |= kpf_copy_bit(k, KPF_RECLAIM, PG_reclaim); - if (PageSwapCache(page)) + if (folio_test_swapcache(folio)) u |= 1 << KPF_SWAPCACHE; u |= kpf_copy_bit(k, KPF_SWAPBACKED, PG_swapbacked);