From patchwork Fri Nov 10 03:33:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 163764 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp864714vqs; Thu, 9 Nov 2023 19:34:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuKStqooT0jRgpvxaYCgq8juVhmqAeiTrND9J/CTFhiL2wIHxNSZ349u675QVt/kdwN1pz X-Received: by 2002:a17:902:8f96:b0:1cc:6ace:e427 with SMTP id z22-20020a1709028f9600b001cc6acee427mr6943387plo.5.1699587250095; Thu, 09 Nov 2023 19:34:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699587250; cv=none; d=google.com; s=arc-20160816; b=NYSwtZ2bNra9UW/esVdedryfNIuysZQy4khgpJhVqEBJVx9ECnv8J3ImUhLjNBLxxx ykRslmafG1SGTpFv4YPXlPDRyVkTy1U3ct1u1N9qegVrqrB+c4/fsA0XRT7hRiGoQmJu +NWEGiH3ZEzZph9AN65mNzYw09AEbF+JNgRtOMxIE42Z1mAvZ1u2sRmMqH2PXBSy+NkC Ijans+OFYgK5aXzXhYhO8t5zKEv+1rQyVJu5QUpW7g4Y7doKqfrNJx0MGg496Bk6yiwz WeBYlheOL6UuwidxIKw/Y1fapZtj/Twz1GjqrvwlkZN6KwgsaLjZnnokROn15UQ+FXFy g1KQ== 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=yLmVQ9KLbgFtHt55SBzSQPM0B7D9zMqtHQVIyqdaEig=; fh=Ig0AqGQMuH358nWWGrnHSF2kv4xbMV1Ws+OHgkmQS6g=; b=HLNF1aZwP+xOFUBeWHUfqUQIIooYDUezSpr24gLhtduucmhBNYJp9f2Pouo+TKY8GP api6U3FQ/Utv6kUwmXSCnslYke/sUT1wMhJfT4YJuF3obIjeOGVgvn3JyaGXsD3q3CM8 lIT9IW42gWvT+IySq9T0pjqhyO9gY3XBiUa5ai0fweXmmEXXc9uf7ECKLsnVK/ARUUbN tsZm1XfQmG7rtIUCnYRtuDFYwFnS8XHnQcDUV8vmox/I4sebsRl7WkpomNO39+HQNJFa Ul/I8ahhSRot5/2d35TylZLpjqrelTSOfnXOOor34CN3gBcqctcFaj66WLzyDLgnenbI Qm8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id t18-20020a1709028c9200b001cc18133022si6050706plo.285.2023.11.09.19.34.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 19:34:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 2F78983B4583; Thu, 9 Nov 2023 19:34:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345836AbjKJDeB (ORCPT + 30 others); Thu, 9 Nov 2023 22:34:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345805AbjKJDdy (ORCPT ); Thu, 9 Nov 2023 22:33:54 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78D354682 for ; Thu, 9 Nov 2023 19:33:52 -0800 (PST) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SRPYW5dvJzWhCv; Fri, 10 Nov 2023 11:33:35 +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 6/7] mm: task_mmu: use a folio in clear_refs_pte_range() Date: Fri, 10 Nov 2023 11:33:23 +0800 Message-ID: <20231110033324.2455523-7-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 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 (snail.vger.email [0.0.0.0]); Thu, 09 Nov 2023 19:34:09 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782146399938822238 X-GMAIL-MSGID: 1782146399938822238 Use a folio to save two compound_head() calls in clear_refs_pte_range(). Signed-off-by: Kefeng Wang --- fs/proc/task_mmu.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index fe15f99a4908..740d5c4fa33c 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1161,7 +1161,7 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, struct vm_area_struct *vma = walk->vma; pte_t *pte, ptent; spinlock_t *ptl; - struct page *page; + struct folio *folio; ptl = pmd_trans_huge_lock(pmd, vma); if (ptl) { @@ -1173,12 +1173,12 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, if (!pmd_present(*pmd)) goto out; - page = pmd_page(*pmd); + folio = page_folio(pmd_page(*pmd)); /* Clear accessed and referenced bits. */ pmdp_test_and_clear_young(vma, addr, pmd); - test_and_clear_page_young(page); - ClearPageReferenced(page); + folio_test_clear_young(folio); + folio_clear_referenced(folio); out: spin_unlock(ptl); return 0; @@ -1200,14 +1200,14 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, if (!pte_present(ptent)) continue; - page = vm_normal_page(vma, addr, ptent); - if (!page) + folio = vm_normal_folio(vma, addr, ptent); + if (!folio) continue; /* Clear accessed and referenced bits. */ ptep_test_and_clear_young(vma, addr, pte); - test_and_clear_page_young(page); - ClearPageReferenced(page); + folio_test_clear_young(folio); + folio_clear_referenced(folio); } pte_unmap_unlock(pte - 1, ptl); cond_resched();