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: 161184 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp855289vqu; Fri, 3 Nov 2023 00:29:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHU1xa6uwYIHOL1eWdwBXIP+ksEKoO/BACz21ka3MmHoMTn04n3QX47miPe9Dn2JARFDiao X-Received: by 2002:a05:6a00:3911:b0:6c3:710b:38d7 with SMTP id fh17-20020a056a00391100b006c3710b38d7mr914596pfb.6.1698996573209; Fri, 03 Nov 2023 00:29:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698996573; cv=none; d=google.com; s=arc-20160816; b=aIGgsKtnqBt8DJy759xJ+CTE6rvPghdn22Wueiw60/pR3oj4mtab/WJBypg2HRgSBl NKlKwtDDuVYl3S5nRUDU66h8BaP5ETD+31dN+3YePegCZu+gMrfqklcpDtB4DprwEYaH udHjBoNwnH1a5fa8E04iU4gzC+zGn98tj0Vyu8p+24Bmsnd3sJ1OCxzayxoFQUdE7iV2 0/eR6uOAFa0UWS3lCRo3TlYVwnXYAvfFdWBz06E+fr66VUWUxRtPBAeTjCnVZPeorJM7 mk2k51vRAgOoyFg3gAbi0gJyGAJwsgydfpHFDXwCbyhAfWggDHKk52FArQH++tQLvA6s HuzA== 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=AQJiy9IXd2NR29+aOZjza5Dosuma1yW9JXDs2UHJAes=; fh=Q7tPJ/E8MvXjzgZkYtX4LsRnr2SdvitVhN9e/tMZDyY=; b=sadiZmtrMBJQH/X9AYX15z2idvgqnU/c3JcJQKe3ndzbnt9YcHxWpnHsKEsV4dJYeb Q4onH+ZuBeiXsi2KuPDc10svrDSvzoDet4ZS7cPVYfksqQbs3fj2SYzdKF7/giArVOHc 96xycY6VkyQcaKDYanL9ZK5QMEKxgMmX5NIQj1HjnYlemQdLT1wKExOIi+znurQo7HPW wndxAlSGUMkU3azcsUdo9lMPEZBMe3OpQjeTo48Vh4c3P5wm/7B1o+Mu7T/hUG6sTSiZ 7oThY1tsSiFvRZ7W+Ft5FEDbFzplBueM3Tn2JoObGORjH5ODz21h8b3MFlVBBHouRuFs DD/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id h16-20020a056a00219000b0068780155ddbsi1076729pfi.131.2023.11.03.00.29.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 00:29:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id EAFD281A5DFD; Fri, 3 Nov 2023 00:29:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346142AbjKCH3W (ORCPT + 36 others); Fri, 3 Nov 2023 03:29:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233093AbjKCH3P (ORCPT ); Fri, 3 Nov 2023 03:29:15 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07B7518E; Fri, 3 Nov 2023 00:29:12 -0700 (PDT) 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-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 agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 03 Nov 2023 00:29:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781527031183992160 X-GMAIL-MSGID: 1781527031183992160 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;