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: 13444390 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 D1F34C4167B for ; Fri, 3 Nov 2023 07:29:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A14B7280015; Fri, 3 Nov 2023 03:29:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C5B1280012; Fri, 3 Nov 2023 03:29:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 865EE280015; Fri, 3 Nov 2023 03:29:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6F8BB280012 for ; Fri, 3 Nov 2023 03:29:20 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 430C4A0FDB for ; Fri, 3 Nov 2023 07:29:20 +0000 (UTC) X-FDA: 81415817280.10.141AD88 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf01.hostedemail.com (Postfix) with ESMTP id CFABE40007 for ; Fri, 3 Nov 2023 07:29:15 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698996557; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ffFsOMCEMvqrtDLA9F7plpO34zh5hKKKwxR41j/1U6k=; b=WijOpl+qpY2epFGvnSgDYH8D8t8EAYFHpXObTLq43zkgsKIJWNYe+BqE8szARz0nWb+znt FnRs/gTw1J1LK1YApi44Q6GRo0BmEsaUybLweD2KgufBlI2yHrvGnndhm89B+/F3+Ym0TK kQkaNQZrsoZ5CT5sM+tWiwElYX7Q9Fo= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698996557; a=rsa-sha256; cv=none; b=arclxNLcXrDbjSAQ5/F5nljDQrf96VPUqyZSMsoc9SqxZYqK0WIBNM9BznH/xSq679EGHz 6JGztRdZ3k62bGc/rEdQn0bbQfhY0i76SqwtjrLNw4iRegXMCTMHspJDSZg/MXYm937bGg 1icAUv6XeCDLndnNnHJ1bz/OZUP5tAk= 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-Rspam-User: X-Stat-Signature: jk9w319bbjihjaxorisf6s6yyh676h16 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: CFABE40007 X-HE-Tag: 1698996555-997400 X-HE-Meta: U2FsdGVkX1+vfFsoyj+6BjBW4AM3oYAeP7HZGXdsZ14KpUFuHsl1Z+0O9CGf5SxYFDz7mQrropStVjfSYGzrD4uk8Wf/HLaPDf4dK+zxtPDWAwvGMuBBIGrY0R4Pcc34VbFODr/pAj+iuNah5movBk0ngyhH63R7GP9z3ENqn5xrgJVwB7PryNqpWkUofVHumgxGTEbsPYt3gLI60PhOINwnksZb2DDjxa9fvP4C8psZUumvI4uJ+UDMPDUWybwkhWhNyK687idIhF85ZAcsgaV0bGSDBDnuHtdcqHzsYqjSjdxG4Ni68kza4teTlddS9YuVLNyNz23utWmcgT08zgh/bLPWNUcI8Ncuc3AcQu8RgvgQ8/5bWIZXQ6tV8PhhgJYNsxmWNAQ8y4g1/VELqDEqxJvrKvt+2J9KQ8rL3K7wdyG0ZFIdqz4V12Kqq7yvb3jPmL8SXWbHGFClohrX74y8ZdCyiDuATRp70yxcYVwPna6Nom5Te700U7UxGJatXAWUb2GuO8aucQeaYRo6ZK2DMlgF02pJxSvwiOq2Ion475UHeyCuohJmcpV1Y0227MYH36XBOXEQD1XLP595fGlXeBJGsg1B81Pya5VsnOgJGUICj0Rs5u8fsao/OmAUj8mVaA9Wn02njCd7Rn8Dv5dN9MYTAuYBhn9h459Gb1nJTuwp5QumNwuF8qOntM2o+EnFpcFlT3xEL6X0d+fKVK01NoGAmyiMAJUr9n5mzQT+AC3pAQ7/sRVbTK+o8j9O6KTJKnTMA+0BLXEFyv+0WPqgVpV26qeWM7JMN2CJP9WmKNY1590RpkjKl+IA32BkSzFMLfZVhg79JP91F7z5+z+/FeA/X9VessQayAgRmJRVMWFP54f4Hk+8PGIONenIOiKhyYFjpWAe4/VgYa/w0K4cn5v06SvWKFqk9L+cZd7rU2MFnGAm3TgwePFomejc6qGjsTUT60hSMvU83QB sY00qbqk LuOQfVVXp9BGXOyu1cONkpHse2aZiGhiDJAcc+qekwkHD6uWNhsscVcSckabnuWPtjPoIzATk+aHGUdliLC/N/M1tRwV2d1G2YU3ADw88mzeVg63j4kaqmRzHqAgoj/mPw/hJrkxRJZOpNpb8fBz59/O+nHN7rtp9jiOmDaJ0DANtjqqXROdYI5kZpxS/yUwnQal8 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: List-Subscribe: List-Unsubscribe: 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);