From patchwork Fri Nov 10 03:33:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13452061 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 F0F5AC4332F for ; Fri, 10 Nov 2023 03:34:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D47FA4401C1; Thu, 9 Nov 2023 22:33:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CD18B4401C0; Thu, 9 Nov 2023 22:33:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B980A4401C1; Thu, 9 Nov 2023 22:33:58 -0500 (EST) 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 A8E2F4401C0 for ; Thu, 9 Nov 2023 22:33:58 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 82E1312041B for ; Fri, 10 Nov 2023 03:33:58 +0000 (UTC) X-FDA: 81440625756.11.60A8A30 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf26.hostedemail.com (Postfix) with ESMTP id 4BA1B140002 for ; Fri, 10 Nov 2023 03:33:55 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.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=1699587236; 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=EaJLPcZe74hOHKLXknVt3PsmvfGOnExzjig3UfkxqBs=; b=kVWoKds0KMQVl72MbYRaTeSwgLdLajJ1XC6JRVpnCIvgJrBl2k9EvPmXAw0UL1LjD8Ucph za/cyIx68gtS98Vw+xwwmSlPf5FB1lIeFfsPx0AiN1C8lLItOF1hwyv+9G54gn7ozJpjFS QhiWwtLd9YZQqFYS+abeWu2WHANZhm8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.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=1699587236; a=rsa-sha256; cv=none; b=aHm3yb0VbSKyzee7qe2gGwPnUEEnW8kkjZJuDQ6CzOYL/3iT0gv9tZdyYwW48NeZIIdVw8 mjaz1qpnFCall0UlbLyeJ3IbTDVDHpGF7q4IXb3+HyZvdCXKt3hhdQZVuoGzDTGL6cLiyj RUMczGkJt9OlQcHAKquPo5PdMP6uumY= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SRPV46ygbzmXKT; 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:50 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Gregory Price , Kefeng Wang Subject: [PATCH v2 5/7] mm: task_mmu: use a folio in smaps_account() Date: Fri, 10 Nov 2023 11:33:22 +0800 Message-ID: <20231110033324.2455523-6-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-Rspam-User: X-Stat-Signature: 9kco34xi9m57u6h93rftchuepcxchxr8 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4BA1B140002 X-HE-Tag: 1699587235-812397 X-HE-Meta: U2FsdGVkX19z5WHcPQmz43Eyf3tnUUBECnp82k5f4/kfAW0Np13IrOw3Qd8XB3tfSIph153cMWsf0wnSGAZO0oL++Z00do1CD+nhUjD9RA2EsApa90ivaGMiJR7s4z06aR9y7uQmEOYGuvUAiV2/3vvYoLCSB2dduDb/UuWhIsH4/FHOe5/PbdHLzTeCZiUfTi8OeyUaLvw1qFyswhurnW+vQRejBOsPHP/qpCfQe1l5lP8j1QeL+lrUSRlHPeW+DfNzwG1iqJbqJCt+zDTn4mlhz9Hh9NBDAT+TyHQ1e1hn4n/kwSrDM733Z1bZlnZFzVbMrWwTzwt7ck9CUDNyie+fxnI85frVz1bHk/BZtK8Qu9Ft5T76aCXzjYaGrVfOgoCohFPQsSOV0bfI4vfY4vKrc/tmNhmawJ5dyg//ETcDEGQXoXNil10SFJW+QO6yUOg0zG82glloQpwYN9oHyKTjopKtZDmNNoZYzImNuhiPh5//bWuyfUqhHw/oiPBgOGTOrpJ2dMA/Ys/O7GRBw4u2awzbZkeiHVvN7rGWjfZKzVPtjvu24bK/V6XHqmbPHJJZqkWqNxxRbqGSKk3rTq7mikzn+i+N22H4QojhMN5rul3Tqgcp5bEoFaKopPniBTgxyoBUteShfB63nysDaGgcmIie3i7LxBuuA8pvbaZqPT4Th2Rer8Qk3X88HlGlTjthMcLVsqBWCmaxCng4ACIBjgZzt3QW9UZoPxGeQlzHn855MrPvkf29n39wtLbWvcPVybyw8+YRrbfDJA5ybzJtd/4yA/XVr5AwVqu8uq/nzWXQ0+miggyX9R1YVRo0zZGfg8ixdH/Z2YAZhkA+PeWV12OO3NbfJWYdZoZnbXXImvgU2kmJgO5+GfXLJXrQejvf/wjM/CqhMcC9/q0WkY+qAuVP7sqMnTWbewR7DPK8Okj9RiiRdVG+dyu4sRTFvNfpAZOJTyUmC3Y6c4y p/HR45ph X6B/WUADPrDYODOo7RiBKn8zGIVemubo6fNX72DqoT4+iQuoOqemqKppw5vsnk80gkBglDeDMK4h9PzwPFRWAW/LjRwR2AoXJ82+lg61kTit/75/6u4YIK2ivavd90v5H8E1fhZpMj+w9YSg17fu+gaQmPZZACGz5j3Qba1nKoeNTX/dBPH+i+0hKmH45rNJWPWTZ 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 seven implicit calls to compound_head() with one page_folio(). Signed-off-by: Kefeng Wang --- fs/proc/task_mmu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 51e0ec658457..fe15f99a4908 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -445,23 +445,25 @@ static void smaps_account(struct mem_size_stats *mss, struct page *page, { int i, nr = compound ? compound_nr(page) : 1; unsigned long size = nr * PAGE_SIZE; + struct folio *folio = page_folio(page); /* * First accumulate quantities that depend only on |size| and the type * of the compound page. */ - if (PageAnon(page)) { + if (folio_test_anon(folio)) { mss->anonymous += size; - if (!PageSwapBacked(page) && !dirty && !PageDirty(page)) + if (!folio_test_swapbacked(folio) && !dirty && + !folio_test_dirty(folio)) mss->lazyfree += size; } - if (PageKsm(page)) + if (folio_test_ksm(folio)) mss->ksm += size; mss->resident += size; /* Accumulate the size in pages that have been accessed. */ - if (young || page_is_young(page) || PageReferenced(page)) + if (young || folio_test_young(folio) || folio_test_referenced(folio)) mss->referenced += size; /* @@ -479,7 +481,7 @@ static void smaps_account(struct mem_size_stats *mss, struct page *page, * especially for migration entries. Treat regular migration entries * as mapcount == 1. */ - if ((page_count(page) == 1) || migration) { + if ((folio_ref_count(folio) == 1) || migration) { smaps_page_accumulate(mss, page, size, size << PSS_SHIFT, dirty, locked, true); return;