From mboxrd@z Thu Jan 1 00:00:00 1970 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 86A74C433FE for ; Sun, 8 May 2022 15:26:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E0386B0072; Sun, 8 May 2022 11:26:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9676F6B0073; Sun, 8 May 2022 11:26:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E2066B0074; Sun, 8 May 2022 11:26:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 67F056B0072 for ; Sun, 8 May 2022 11:26:29 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3D2D92FB62 for ; Sun, 8 May 2022 15:26:29 +0000 (UTC) X-FDA: 79442952498.22.45ACE66 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf01.hostedemail.com (Postfix) with ESMTP id DD77B40038 for ; Sun, 8 May 2022 15:26:15 +0000 (UTC) Received: by mail-pf1-f174.google.com with SMTP id p12so10284184pfn.0 for ; Sun, 08 May 2022 08:26:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=wlb5sCv0vT9DKd6Y0pxChn3TRESHpDGd2RiWXJbPiOA=; b=A8uBy/esNOEbUqh4vOntGYm1YMVp8KTDNwiHyleMxFUxETUvcSv6DZ39zZIcwk5yYw 86UrDKPKDKAZMR7dwUoHWD+jUB4gtgw1yCKhEiU7ARnW49msAlzrKSzQ8vYFlTYpNIt4 hQLknIHiDmcV0B5wHAtIxy+UOOM5eEY20zDhI9WMiJaDrUjdvDVuVJ7iiy5qzG1y47jV 5gEm227YJe0hvNojSjOoSAN3C1iYnEXrtZFcNuKVuuM/p8p/52As0MlF3Mk2EzYn6wr/ J7bXPbCej7CVuXF4I6IX7/Rq1hiMYtnD6AFcfLgLxgY9EZUeI+It1LKO31oPmsw6uMey wxog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wlb5sCv0vT9DKd6Y0pxChn3TRESHpDGd2RiWXJbPiOA=; b=NMwsHIwemTgurxPPwY4vctTVQHDgKJep19b1/aLnecx75CENeEOPGoYwbsbuB7Gfuv w6jvGlMc/gTikvvJCI4dYO9jy+CFF1yhuACmXmDRqaakIBX9QMZLLZ8+QrDKp/5xffp9 2qApC15t6SUfkjZriHh3WAvpfMcep9ika/zBNOfV6F+IE4YzeSNoBf2fiD/qEmpwWvM8 JEucudb2zbJGA5jm5znGtC6VMl4C2qHt60OKjz1jGGXQ7kvrggdEDiBQI3XPJI1FYtCP bsqAFkRL6xzFc0LEdB7g1DJKX3/MK5B6U7pAy/HFW51Hz4dN7MJ3LyoznjcU1/Xdf8Nu dmww== X-Gm-Message-State: AOAM532S/RC4stIzOREXIXFtxAnTn+4Cc9ltIiaOICNlhfoIUhi8GO/D GRztgZ3575vXGOZq0J5dcaHcOw== X-Google-Smtp-Source: ABdhPJwrAUBJu+P2n6cQJedLTi8BGUZ973hWDTaS8Y3nr73sK+kVeWZgWILLCvpX1mBPKLFMAkg+uw== X-Received: by 2002:aa7:9d0d:0:b0:50d:4fcc:7cb1 with SMTP id k13-20020aa79d0d000000b0050d4fcc7cb1mr11948987pfp.41.1652023584948; Sun, 08 May 2022 08:26:24 -0700 (PDT) Received: from localhost ([139.177.225.250]) by smtp.gmail.com with ESMTPSA id a19-20020a170902b59300b0015e8d4eb229sm5253221pls.115.2022.05.08.08.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 08:26:24 -0700 (PDT) Date: Sun, 8 May 2022 23:26:21 +0800 From: Muchun Song To: Baolin Wang Cc: catalin.marinas@arm.com, will@kernel.org, arnd@arndb.de, mike.kravetz@oracle.com, akpm@linux-foundation.org, sj@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC PATCH 0/3] Introduce new huge_ptep_get_access_flags() interface Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: t1rstxhx98usqkzz5ks3mgb7nsz5e7ik X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: DD77B40038 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="A8uBy/es"; spf=pass (imf01.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspam-User: X-HE-Tag: 1652023575-5781 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: On Sun, May 08, 2022 at 04:58:51PM +0800, Baolin Wang wrote: > Hi, > > As Mike pointed out [1], the huge_ptep_get() will only return one specific > pte value for the CONT-PTE or CONT-PMD size hugetlb on ARM64 system, which > will not take into account the subpages' dirty or young bits of a CONT-PTE/PMD > size hugetlb page. That will make us miss dirty or young flags of a CONT-PTE/PMD > size hugetlb page for those functions that want to check the dirty or > young flags of a hugetlb page. For example, the gather_hugetlb_stats() will > get inaccurate dirty hugetlb page statistics, and the DAMON for hugetlb monitoring > will also get inaccurate access statistics. > > To fix this issue, one approach is that we can define an ARM64 specific huge_ptep_get() > implementation, which will take into account any subpages' dirty or young bits. IIUC, we could get the page size by page_size(pte_page(pte)). So, how about the following implementation of huge_ptep_get()? Does this work for you? pte_t huge_ptep_get(pte_t *ptep) { int ncontig, i; size_t pgsize; pte_t orig_pte = ptep_get(ptep); if (!pte_present(orig_pte) || !pte_cont(orig_pte)) return orig_pte; ncontig = num_contig_ptes(page_size(pte_page(orig_pte)), &pgsize); for (i = 0; i < ncontig; i++, ptep++) { pte_t pte = ptep_get(ptep); if (pte_dirty(pte)) orig_pte = pte_mkdirty(orig_pte); if (pte_young(pte)) orig_pte = pte_mkyoung(orig_pte); } return orig_pte; } > However we should add a new parameter for ARM64 specific huge_ptep_get() to check > how many continuous PTEs or PMDs in this CONT-PTE/PMD size hugetlb, that means we > should convert all the places using huge_ptep_get(), meanwhile most places using > huge_ptep_get() did not care about the dirty or young flags at all. > > So instead of changing the prototype of huge_ptep_get(), this patch set introduces > a new huge_ptep_get_access_flags() interface and define an ARM64 specific implementation, > that will take into account any subpages' dirty or young bits for CONT-PTE/PMD size > hugetlb page. And we can only change to use huge_ptep_get_access_flags() for those > functions that care about the dirty or young flags of a hugetlb page. > > [1] https://lore.kernel.org/linux-mm/85bd80b4-b4fd-0d3f-a2e5-149559f2f387@oracle.com/ > > Baolin Wang (3): > arm64/hugetlb: Introduce new huge_ptep_get_access_flags() interface > fs/proc/task_mmu: Change to use huge_ptep_get_access_flags() > mm/damon/vaddr: Change to use huge_ptep_get_access_flags() > > arch/arm64/include/asm/hugetlb.h | 2 ++ > arch/arm64/mm/hugetlbpage.c | 24 ++++++++++++++++++++++++ > fs/proc/task_mmu.c | 3 ++- > include/asm-generic/hugetlb.h | 7 +++++++ > mm/damon/vaddr.c | 5 +++-- > 5 files changed, 38 insertions(+), 3 deletions(-) > > -- > 1.8.3.1 > >