From patchwork Fri Nov 3 07:29:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444388 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 F24DBC4708E for ; Fri, 3 Nov 2023 07:29:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 42D75280011; Fri, 3 Nov 2023 03:29:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E91C280014; Fri, 3 Nov 2023 03:29:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 160EE280011; Fri, 3 Nov 2023 03:29:18 -0400 (EDT) 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 EB0A8280014 for ; Fri, 3 Nov 2023 03:29:17 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BAA62C0354 for ; Fri, 3 Nov 2023 07:29:17 +0000 (UTC) X-FDA: 81415817154.18.CAE23CC Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf07.hostedemail.com (Postfix) with ESMTP id 677C840018 for ; Fri, 3 Nov 2023 07:29:15 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1698996555; 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=AQJiy9IXd2NR29+aOZjza5Dosuma1yW9JXDs2UHJAes=; b=BvbPh6i6KUFw7OqaaOG2n6T0JZgOuo2Oxc0s7H1IX2hiqrxcv4OIE+dRyVg+7+dw5XYlpA Omj7ObhN0bVcLQd3z4921sS6gr5SZJF3XRqO6CBkRMtoNr11UFdWGE/xkbLZIs6A+PxTAL BRUwmpcG7hs1GCX+UHW9rcS2zNh2nCU= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698996555; a=rsa-sha256; cv=none; b=XlqJJ7odd5XzXKxudIWlDI22YackUCdR4hasTv9bQkUcd/D5Ujc4H39oHhjFbbf5PmLX/m YjqAIY041RCN08BtZYDqiJQzRdDVcr5QSYvAGgGDN/oFZ1+u2J97dztkPZnN+wA/QPkoKY CvOZ9WdrOUkT2i6kEZ3Vu+Jxm0A5niA= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SMC1p61SqzPnmj; Fri, 3 Nov 2023 15:25:02 +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:09 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , Matthew Wilcox , David Hildenbrand , Kefeng Wang Subject: [PATCH 2/5] mm: task_mmu: use a folio in smaps_account() Date: Fri, 3 Nov 2023 15:29:03 +0800 Message-ID: <20231103072906.2000381-3-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-Rspamd-Queue-Id: 677C840018 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 1jtjxrnub3s4uuwpstsh6uhtxf19rzwf X-HE-Tag: 1698996554-230162 X-HE-Meta: U2FsdGVkX1/RD9k/WFw0w8EhbgE6aXjAwfi+omq/CZA+YdafsXMk3GhBKuNi2PDMk3S0Pry1UDVTodwO+ZLlw5g90s7Nm2eBS8hQseBdok13ZL1LYL6U397PNTBk38dgSqW9JK9T9x0tbCU6EZvYfhmVhZ+N5PL0YXPHrtumlxPml//Bd5KjAp3DJRMZUyZTN3THGUu4vikUqF7jKNaEQCJgQjF6DjmSmlO/nQwyv2B0EpqlSbg06WMYF/wCdBm8zqPkwsQfBlVHwYT80KjeDSJKlfu9KUMpwxWrZGAPOF2k1Hfr4PppLyI6fEufXtXeUDsXOX5m0gPqqDaVFyPB6zy16LyZL+U4+aQA03D8hqPlg2DUCYdGaPgpJz3eIdmV6fVURfMWQKoBtIBV2MOWGHaX40FL+3L0qFSpofPSaOXyAi8Olzmy4eVVxeNh6AQ3dPipDHK2yQTf7rngANnfnMqmiLJkPHjahC7NjKw3Litznao699QEoLql9nQUyD//uMuh+dFYD6UY4sY6ZgY+EsxYLLk/xXci2ga9Y5E1CPMNd5S4yCgOJk0tPgprb+BSA9RiLb3rzMFWaGr3arTvl/E7aMGD5qWlF3GcVb0ln2e6bIRqimB+1hv7S0pzvYF2E4dH/DqVD1KHYj0Yb0om4vOKLoAhPbiCp/h6i/jzK2cl7ynTPtvhNIRYrWPB8P0+xEbloftUFmQmA6r5F33j96n62GZt9rAPOt4AxYXLcHnv4xrr8DJbqBws0dyPO8bOVPTq+yIMT6U5KMp0CXVS7Y1iX95DEW1uwFgAPJ8GYXEh3kWc+ZxUOKUAc+mJ3TtWwS1JN0Jk4Jhazn1HRorBd+t4WniG2YKOY/RVirhAoq8FyyODxWKT3N8QRYO1+iOSmo6j1T30HCaz11loDA2xcVypN1q2l+zSxB542voNERjqdke36B0/nk+iBbugAySyMvCnehPZLCwXqTfSeyD uCVoD3Ei e5q+jYpwrysX7WLeIbU8G0ms0D9wsBXghlHU+8MdJ/YoxCFQO9bXNSpzLJvs/uEe9b3Qf/SRcjSpoKAgCVOfOR/O+uGF8CE72zV+DuUOUHcLANSzFROe8ODmlsbHIA6KyM61zBlEk0/1HO5aGpGSNmqvOTuqOx12SPDSX9pY4n4JvX643SRORbvjEWqF3ECjSVgDe 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 ef2eb12906da..5ec06fee1f14 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;