From patchwork Wed May 25 10:31:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 12860946 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 5A7F5C433EF for ; Wed, 25 May 2022 10:31:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E42D48D0003; Wed, 25 May 2022 06:31:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DEEB88D0001; Wed, 25 May 2022 06:31:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB4468D0003; Wed, 25 May 2022 06:31:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B93328D0001 for ; Wed, 25 May 2022 06:31:24 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 9553781007 for ; Wed, 25 May 2022 10:31:24 +0000 (UTC) X-FDA: 79503898488.06.11354C6 Received: from out30-57.freemail.mail.aliyun.com (out30-57.freemail.mail.aliyun.com [115.124.30.57]) by imf25.hostedemail.com (Postfix) with ESMTP id E268FA0036 for ; Wed, 25 May 2022 10:30:54 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R641e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VEN9UHQ_1653474679; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VEN9UHQ_1653474679) by smtp.aliyun-inc.com(127.0.0.1); Wed, 25 May 2022 18:31:20 +0800 From: Baolin Wang To: catalin.marinas@arm.com, will@kernel.org Cc: mike.kravetz@oracle.com, songmuchun@bytedance.com, anshuman.khandual@arm.com, baolin.wang@linux.alibaba.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] arm64/hugetlb: Simplify the huge_ptep_set_access_flags() Date: Wed, 25 May 2022 18:31:09 +0800 Message-Id: X-Mailer: git-send-email 1.8.3.1 Authentication-Results: imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.57 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspam-User: X-Stat-Signature: y5hnjbsdztz3489z7xdpm8bqgnrs4uxa X-Rspamd-Queue-Id: E268FA0036 X-Rspamd-Server: rspam01 X-HE-Tag: 1653474654-787922 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: After commit bc5dfb4fd7bd ("arm64/hugetlb: Implement arm64 specific huge_ptep_get()"), the arm64 specific huge_ptep_get() will always consider the subpages' dirty and young state for CONT-PTE/PMD hugetlb, so there is no need to check them again when setting the access flags for CONT-PTE/PMD hugetlb in huge_ptep_set_access_flags(). Meanwhile this also fixes an issue when users want to make the CONT-PTE/PMD hugetlb's pte entry old, which will be failed to make the pte entry old since the original code will always consider the subpages' young state if the subpages' young state is set. For example, we will make the CONT-PTE/PMD hugetlb pte entry old in DAMON to monitoring the accesses, but we'll failed to monitoring the actual accesses of the CONT-PTE/PMD hugetlb page, due to we can not make its pte old. Thus remove the code considering the subpages' dirty and young state in huge_ptep_set_access_flags() to fix this issue and simplify the function. Signed-off-by: Baolin Wang --- arch/arm64/mm/hugetlbpage.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index e2a5ec9..5c703aa 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -448,7 +448,6 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, size_t pgsize = 0; unsigned long pfn = pte_pfn(pte), dpfn; pgprot_t hugeprot; - pte_t orig_pte; if (!pte_cont(pte)) return ptep_set_access_flags(vma, addr, ptep, pte, dirty); @@ -459,14 +458,7 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, if (!__cont_access_flags_changed(ptep, pte, ncontig)) return 0; - orig_pte = get_clear_contig(vma->vm_mm, addr, ptep, pgsize, ncontig); - - /* Make sure we don't lose the dirty or young state */ - if (pte_dirty(orig_pte)) - pte = pte_mkdirty(pte); - - if (pte_young(orig_pte)) - pte = pte_mkyoung(pte); + clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig); hugeprot = pte_pgprot(pte); for (i = 0; i < ncontig; i++, ptep++, addr += pgsize, pfn += dpfn)