From patchwork Wed Jun 8 08:04: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: 12873012 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36E7DC433EF for ; Wed, 8 Jun 2022 08:05:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=sKRq8L2u2cURtPmGhuwB1tsIlDteFPhtYbmdkwQwMUA=; b=uuyQebFI9KBVvQ jJUhScC6VwIZg3VnCqqOhxv0FfIlW01rRd6/wN9v3kxTnGGjQPBLzqX1Q2gxCsNVhxeUClgvLZE0H KxyHBVYCsiCRoZxAvD+5mAmGNEUlcUY/nBVlDOTGikRvuyW+xMW+Jrt/nvF3h5hADD8R0xvs4B43F xMMPpKmTGuOJ28LQL/UTnxHD5zX85fvWyNaGdHqCuzcYuYg18Cx2ITF9djqJXoYTRZoyfp2gT5OUu zi9+IasMX+C1r6rgqvkL5TPUKVsTnNLfgfyEYiEXCZOkwvlF7Cly81OZkhH/NJl1xGEEMz8B55SKD kH8gpA4c6fDuEkW2vyNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyqg9-00BoMc-Ia; Wed, 08 Jun 2022 08:04:37 +0000 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyqg4-00BoJm-FX for linux-arm-kernel@lists.infradead.org; Wed, 08 Jun 2022 08:04:35 +0000 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VFl.CFb_1654675462; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VFl.CFb_1654675462) by smtp.aliyun-inc.com; Wed, 08 Jun 2022 16:04:22 +0800 From: Baolin Wang To: catalin.marinas@arm.com, will@kernel.org Cc: anshuman.khandual@arm.com, mike.kravetz@oracle.com, songmuchun@bytedance.com, baolin.wang@linux.alibaba.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RESEND PATCH] arm64/hugetlb: Simplify the huge_ptep_set_access_flags() Date: Wed, 8 Jun 2022 16:04:09 +0800 Message-Id: X-Mailer: git-send-email 1.8.3.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220608_010432_731908_C209E79B X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. Thus there is no need to check them again when setting the access flags for CONT-PTE/PMD hugetlb in huge_ptep_set_access_flags(), since the original pte value already considered the subpages' dirty and young state by huge_ptep_get(). 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 be failed to monitoring the actual accesses of the CONT-PTE/PMD hugetlb page, due to we can not make its pte old if some subpages are accessing. 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)