Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4901880iob; Mon, 9 May 2022 04:28:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9+i9JyrIQ/Qie2Kp2bPboZjeU5p3vYmpyza4MK88R7mE6v3m7x6gE8mOpvjvL1VlP2kGb X-Received: by 2002:a17:90b:3442:b0:1d9:8af8:2913 with SMTP id lj2-20020a17090b344200b001d98af82913mr26153493pjb.199.1652095716737; Mon, 09 May 2022 04:28:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652095716; cv=none; d=google.com; s=arc-20160816; b=Q0xtGAuBMa6FoQF6IHeFsIZGDPAwXbikaxYP4s7qfWPUokSVu5isUJCKC6mToqjxPE iyIGWoK7LrZiownvTnSkb8oR6iqd4NR/lLZLNHG5Ec9eqX7PL4y3UP6J+jPhSUHnR2sQ eB8c8xs/GfFAyJHGeuQoCN2hRv5IfY703E2uYmR9I1xMWaKTNwFkSDwQANrhvPrOJyQx qxfb8ELe9gMjqnQA5rG8JvMoqIVCtH2kwDMGjGJ7IrYbWXerWFuNCxsaQVIJpYoOUXhx nL5UXH3eR6j05v7W0KHKy/k6hbbTdcC7AeKARf9TEL1k6VaQDtIYBjMoNZMHC79yOzzP Mn3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wlb5sCv0vT9DKd6Y0pxChn3TRESHpDGd2RiWXJbPiOA=; b=TgXXolmT3KuVp27FDjsTIXOGf0UGNtSovccGoSXUZpSqaYhJhRxk1OxCdj858rnrlJ 2T36A3ms6fToLj//fTguF54LdEOVyQNUVkuZPfABH0vDnej0lEenG0+Qo/3GhqLSl2kT ThJw75dnmvTpn9Gj6do2/XO2EHul/DwC2Yw0KWDKLIfD1cTWs/idRzSUHpcnWJqYfCId DKx5c4dPKCDjnImu6Iff0ms43E85WNV5CDRf+clgmzLOSNO/OYyLAuTWRGvratjKkADB UUCmFzKhg1tIT4FalCA+ejtnbopUzWRneZQ2uz9quYjU2E9SdO2kZIDUSpP4ozP9zATP 7QxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="A8uBy/es"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j6-20020a056a00174600b00505d4875450si16508784pfc.112.2022.05.09.04.28.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 04:28:36 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="A8uBy/es"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6298B2B4942; Mon, 9 May 2022 03:35:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234705AbiEHPaT (ORCPT + 99 others); Sun, 8 May 2022 11:30:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234692AbiEHPaP (ORCPT ); Sun, 8 May 2022 11:30:15 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69A2EB87 for ; Sun, 8 May 2022 08:26:25 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id a11so10265838pff.1 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=LPT/3b5w0zQtdaK9Yy8FddcHtCsQaNBgN+7D46blPISxLqRph0HTTs1AfpjzpZO9Np gpC+wy11U8T7odlOL0TALjAVL+79O9LBhCmuxaJT7x4JX8PRgX90ssOJCpsaA+ob8ijL V495YhJvuyX+pyUsXr2qMLBrzw4iWpOws20rp+j0CyUKyzi7CnCwLD+xmG+f3St2eDoO ioq3UhAwxKnPfiPijNAx5ieHVApfNKvuaZ0b0I1UgLyCLQv0Ci28CY/a1FBbXBnYq+WR fPibguxraISp5ugUutyBClKGaVcT0mWLYoS1RkVj97H0/WEXGtvn/lYItB3ebVAArXxQ zJvA== X-Gm-Message-State: AOAM5323lFFwnSCoH7QiztpYhG2bvfIFktmWmKMWWGqQUomv9pJtgZ5u ADfSf9Fh4v9Wz+O/SQQLf3tAyIfgTu0K7Q== 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > >