Received: by 2002:a19:651b:0:0:0:0:0 with SMTP id z27csp3746414lfb; Mon, 9 May 2022 03:13:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1fvGY1eHa58teoBpwn5JXpfgVpitrvY8BSy/oI9VrDASox5jfNoLfqTu2uhkHsJ7WHR/I X-Received: by 2002:a05:6a00:22c8:b0:50e:57:b2a0 with SMTP id f8-20020a056a0022c800b0050e0057b2a0mr15634402pfj.80.1652091200593; Mon, 09 May 2022 03:13:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652091200; cv=none; d=google.com; s=arc-20160816; b=mylmq7S44TGk6WGX/4twjZxyCIUxfUOYy2/kCDX2Gnz35oq7Cw7ojtDaDNkN9r9x4k A3BeH3Vr9KULuIFYTVANolD0e83nszOJbcjrTPn7TB3RjxGraIx1H3rIfeoGPid1s6Md sIbgo3Rf3YYgKo8f0cRIqajFgbHL8QYpU3IkBHA6Gd9IWysePHwxN++VPXXzCweUn+g+ yH+54AyFTtPUcCkSyLweDxVeCeOd6IQvefg6dIGOnWsFn91uHsfNsuFk6qoWRyqTsBlr o+bTU6hhMjE9qZ8hxQiC5BFESRF4XZoLhnHSUzjspqPMB5VFEdb6xT7N1lajcT18OtYQ B3mQ== 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=ZTTQaK1MCP0Shiup/o7qs7DSoxAGZcC20JNp/8zusXE=; b=Iv7e7wSDt2/1n9dPWpVlNxIjQKPuROWWQzeAUpMbp0D70+Rn2KbAMT1pjWC4IdiMUi pKkhQLBPbia6OcT4uuJ9IWvJfAOoxMA4N2HzJcJhPDRzCqLKoliZrWeskAE4aLHGYRUz ASy4aIURsTO2TbP3Heoh996y0DMUSCTkTLgyhx9I8d8vsa2W6oIhaMGzR/CZPqUKbtGJ a1FfMCcIpUBqM+yJQVza3tnS9TY14p/Nfccjo/VXduLaJE5+wssmPqZHEawWjnFiumrd +/1FHFVy4fAPs/jzAVjP+kzMjiNUsB26l1Uju9jZTspy13TaGqZqCGfeaUp2GhoVTa/Y ZtFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=lvu0tqEA; 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 s38-20020a635266000000b0039da2c7eaf9si14178597pgl.452.2022.05.09.03.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 03:13:20 -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=lvu0tqEA; 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 1BAFC22906F; Mon, 9 May 2022 02:51:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229621AbiEIC7X (ORCPT + 99 others); Sun, 8 May 2022 22:59:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbiEIC55 (ORCPT ); Sun, 8 May 2022 22:57:57 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD4DD8164B for ; Sun, 8 May 2022 19:54:05 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id l7-20020a17090aaa8700b001dd1a5b9965so1113286pjq.2 for ; Sun, 08 May 2022 19:54:05 -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=ZTTQaK1MCP0Shiup/o7qs7DSoxAGZcC20JNp/8zusXE=; b=lvu0tqEAYL4lMpXHlUzMzuGrVzNiSN1F7GkTpaXG15DPrHT1CKlKmPTSyxU7h/NV/j kUWsTNFP/67CPMC2uOZi3lJkE0lLp5sDkHR5Vg4ZoLQibwozZlVvVrWAmrcTfYRpX//B IUvdewS9yYA2LSGRsdHGz3Vy9in8L82rvGFwD3Zc8rtXp9G3nFfXed3dmePb2uW74wWS gjRGNoAkLLOEaS+JIVqDdXS8Khp2rr6+h+bGKqkjlK7OSgl+ubpQebutmaP5tiQRi8Kq 5jTLundScFrLcZoaaz36HUq3ybV0gU6aQtsrRhtprHTBJRtzsvzNZ5USFQbLHaHia+ap v4wA== 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=ZTTQaK1MCP0Shiup/o7qs7DSoxAGZcC20JNp/8zusXE=; b=uwc8GOXxzAVOptfAoEPeWPTXfwkGbXb+kRV8MrDBNau51XVnlkJAcxiIuZPS4rx5oH xY+DaWaC9YKlw3BdoJfgZoPO0SYtqKLPoV0Uy+7zTJgJoLBVWWZxehg0g1Q7z2w1YuDt xA7fVXAZyETznEIG0hMeewiTyDrzv7SxkRppY5Gj6vb96Q/WvJwZUl+y9HMZSh4DexbZ Tkl1g+iV7pjn+jN7FDBaNZLf/elJKEBlizOQPL/XnlYUcCkarCROAKut58YY6yXHT9Vh dj2X+D6yLzWR/reZYbvNWZlNmvMFEjIPDPgbRE/u+8NkKWmtYak0ybxnbbjyksyDrSne 0NEw== X-Gm-Message-State: AOAM533lEF8EU2wI5d9FAsPStY9jjZOmKOIQBYJFcM7UQ6hACIrPZphd MqohMT/x0YAYgQpLBEZgyyLaJg== X-Received: by 2002:a17:902:d2c9:b0:15e:b28d:8ad2 with SMTP id n9-20020a170902d2c900b0015eb28d8ad2mr14262241plc.94.1652064845269; Sun, 08 May 2022 19:54:05 -0700 (PDT) Received: from localhost ([139.177.225.250]) by smtp.gmail.com with ESMTPSA id o18-20020a170902e29200b0015e8d4eb258sm5783241plc.162.2022.05.08.19.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 19:54:04 -0700 (PDT) Date: Mon, 9 May 2022 10:54:00 +0800 From: Muchun Song To: Matthew Wilcox Cc: Baolin Wang , 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 06:08:18PM +0100, Matthew Wilcox wrote: > On Sun, May 08, 2022 at 04:58:51PM +0800, Baolin Wang wrote: > > 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. > > 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. > > I question whether this is the right approach. I understand that > different hardware implementations have different requirements here, > but at least one that I'm aware of (AMD Zen 2/3) requires that all > PTEs that are part of a contig PTE must have identical A/D bits. Now, > you could say that's irrelevant because it's x86 and we don't currently > support contPTE on x86, but I wouldn't be surprised to see that other > hardware has the same requirement. > > So what if we make that a Linux requirement? Setting a contPTE dirty or > accessed becomes a bit more expensive (although still one/two cachelines, > so not really much more expensive than a single write). Then there's no > need to change the "get" side of things because they're always identical. > > It does mean that we can't take advantage of hardware setting A/D bits, > unless hardware can be persuaded to behave this way. I don't have any > ARM specs in front of me to check. > I have looked at the comments in get_clear_flush() (in arch/arm64/mm/hugetlbpage.c). That says: /* * If HW_AFDBM is enabled, then the HW could turn on * the dirty or accessed bit for any page in the set, * so check them all. */ Unfortunately, the AD bits are not identical in all subpages. Thanks.