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 1DA19C433F5 for ; Sun, 8 May 2022 17:08:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 700066B0072; Sun, 8 May 2022 13:08:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B0546B0073; Sun, 8 May 2022 13:08:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A0416B0074; Sun, 8 May 2022 13:08:39 -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 4A21A6B0072 for ; Sun, 8 May 2022 13:08:39 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0F28720BA5 for ; Sun, 8 May 2022 17:08:39 +0000 (UTC) X-FDA: 79443209958.29.DB7DCCB Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf14.hostedemail.com (Postfix) with ESMTP id B852510008B for ; Sun, 8 May 2022 17:08:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=rCdXSvZjp6F8gmuuM1Bzn/n/1RjrsEENuke5qJWo6Ik=; b=ZITLMC7DKkB4Trwc7bNWRzlWiR uT0nYzvCip831JpgQyklirM6W5ZtBvwI/rbUgZG25OXn37GktTQvcDVwZvekFIFN3RlwQjbeMxQNZ t8svRibUKtQ5pSma7ZHwD4rhYKKSKUMuCXUudxB/lKBTjcYTiXuIP90H0LBavuHykOSLAYZBR0n+N xlbmj9fmytKxcHJHrhHJQrB6rfhARHN0rdqB7mMnuDA1ZrH+oqN64jvGi1P+6adiJ4DRVajMHBRqD xcUx+jC59ig3ERAVQ/K3bOHlarpWldz6ZU9Jf6bS+1+KW5lZVKfkttKna9E0jBro6nPjtg4Fm6//P zy6sUqmw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnkOI-002foo-RN; Sun, 08 May 2022 17:08:18 +0000 Date: Sun, 8 May 2022 18:08:18 +0100 From: Matthew Wilcox 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: h4mac1jsdri4p7zcrpohwiefzrduuf3k X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B852510008B X-Rspam-User: Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ZITLMC7D; dmarc=none; spf=none (imf14.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1652029716-152500 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: > 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 don't have a hard objection to your approach, I just want to discuss other possibilities.