From patchwork Fri Nov 10 03:33:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13452063 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 CA2F6C4167B for ; Fri, 10 Nov 2023 03:34:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 928D44401C3; Thu, 9 Nov 2023 22:34:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D8E74401C0; Thu, 9 Nov 2023 22:34:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 778D84401C3; Thu, 9 Nov 2023 22:34:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 680D24401C0 for ; Thu, 9 Nov 2023 22:34:12 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 3D3F1401FD for ; Fri, 10 Nov 2023 03:34:12 +0000 (UTC) X-FDA: 81440626344.04.D4726E6 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf15.hostedemail.com (Postfix) with ESMTP id 7D086A000B for ; Fri, 10 Nov 2023 03:34:09 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1699587250; 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=7m1Pxk98srFU0kXtPDQlyvtZ89qCO4y/HQx1e+D5jmw=; b=dIiWmQSQqVyEip9m/y0pnrAN1o85d5oj2278FkFIuHIUKzLZbQk+XOteoajUmnf76b46RG kozpd86nRbfWzUXKl6NHOjYXjelVor5o+LHS1NZIte7O3l1xw+ryd17yJFk2ZkXTkz+HCC N5NPhrglsm5MDVX1GZdAzDpBAhV6Urw= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699587250; a=rsa-sha256; cv=none; b=0ujhsXCt597LH3opkg+N3bVBUM3eeNG+i9dECKhpNoYSdSXbx/5rhAmoMkeceWlz1hxHyz VQfW23rzSQA1U0cRgnFbk1mFr2Y8TkQDoMXQNP6T9C94/HP4ek2eOlpu9Wh8EG9hpHjUSJ Axqr1lYlWFrnVAXITcFSVnDO31DyuoY= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SRPV436p6z1P8F9; Fri, 10 Nov 2023 11:30:36 +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, 10 Nov 2023 11:33:48 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Gregory Price , Kefeng Wang Subject: [PATCH v2 2/7] fs/proc/page: use a folio in stable_page_flags() Date: Fri, 10 Nov 2023 11:33:19 +0800 Message-ID: <20231110033324.2455523-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> References: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 7D086A000B X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: oqupdjd7c4a67n1gy3zwr8xcjsjmkd4h X-HE-Tag: 1699587249-837288 X-HE-Meta: U2FsdGVkX19JmunFBaPUlpgls4xbM0oZDiqQwaUEME5WGzUQtfMmeZnogg2W+UDbpIRh+YM1rIHgqrVDsFVH1XydCLRue2zpbG37QNbCP5pRo/y+G3jjy5TCDq3O1xPw19dSf4y42CaV2Ag/thSObdqnlIEYipcO7gywAof2kbhfjY0zS60pqeXc5pV9q/tgNjEVhyNMSTvzDg/WzXCMlBOZIefLslEP2tzUYbTFMqCId+2BG3wl+503n0aF5TkJmkdXHbJ5pd0zEMlATHwGxifs7DCH+2rC7vVopziSmr4+oVlZC6K3XSOz7nm0sjldp3PwrIf8V20dq7EuW0kb/M7Btgvn1rIioZ36RXG0BmIH6UtKsnxOKieqRuJQq0MCyf5tMMHc9mtU5qJS8FPja58LSYlrwOQjYYoHC4tvqrRdqmG7ymBcFv9u1B6ZKi4ldNtaCjrokEPtCQEuUD9ym38NN2+356/WzjUMupSfa1NJRynUABMQoYs5mFyZvc3Wq8rmEXhgWnYH9n4nYZ8nFRNu04St41aR9aI+wSunaYXF/Hlin1DCfKEMYepFvH7mk1MaF77vCIQCrcyEJDIwjC0XCP+UdYkqcQxZiE4FSMtzZ6UVzgURcp5No38PBaM0MhJ+e/HpQfElok209NZpgDQ1HbUXRg0yT6XVvokAiToqm7ocqI0z+96NeReu4YZgMNYwHl2+aXM6z0AcZaDRvoJ/NmPoP0Lj5mwR9jTgVVRdVxbiqmSOZurXf1dTxlsXgaYJ3Qb3YYhud5XW+OqdtkUUqRhAMCC3jzTn8dlAFCqV1BW+x0iqQxdjLWMYl95bexw3qeoPZ2KGhxX9f9+5z/2N9ack+RmfYWB1HG481BxGSJQSosim3GraSCUw75rp45F4mM/Vri58uH1m+cyrIyB209Kjk1PoZA1yrat8Bh4foo+UVYVRh1JsfsFd8aErtXvAEmrBJmHcbtZ4yhN ED3Y+Fyi BwXM3mzzKqgNSLyiWQlEDpMwa1Jvkj06QTraih7S1d9qMN50yW31rDpPkxwfD4uf8AHOOJ0LpEubJFxkw0RAtF9/paMvxGMj9XmC5I7sQcVRm6oRyBscEHv+JxHhqLVho+sP4qCRjjKPo7stSbY9FRdKjJp30GKYYN/w9uTKeeSNh4hPEfys/BqXKq71bscN8BDcS 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 nine compound_head() calls with one page_folio(). Signed-off-by: Kefeng Wang --- fs/proc/page.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 466efb0dadf7..dcef02471f91 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,7 +178,7 @@ 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); @@ -194,7 +194,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);