[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <16fb7985-ec0f-4b56-91e7-404c5114f899@kernel.org>
Date: Mon, 9 Feb 2026 10:55:32 +0100
From: "David Hildenbrand (Arm)" <david@...nel.org>
To: Baolin Wang <baolin.wang@...ux.alibaba.com>, Chris Mason <clm@...a.com>
Cc: akpm@...ux-foundation.org, catalin.marinas@....com, will@...nel.org,
lorenzo.stoakes@...cle.com, ryan.roberts@....com, Liam.Howlett@...cle.com,
vbabka@...e.cz, rppt@...nel.org, surenb@...gle.com, mhocko@...e.com,
riel@...riel.com, harry.yoo@...cle.com, jannh@...gle.com,
willy@...radead.org, baohua@...nel.org, dev.jain@....com,
linux-mm@...ck.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 4/5] arm64: mm: implement the architecture-specific
clear_flush_young_ptes()
On 2/9/26 10:36, Baolin Wang wrote:
>
>
> On 2/9/26 5:09 PM, David Hildenbrand (Arm) wrote:
>> On 1/29/26 02:42, Baolin Wang wrote:
>>>
>>>
>>>
>>> Indeed. I previously discussed with Ryan whether using pte_cont() was
>>> enough, and we believed that invalid PTEs wouldn’t have the PTE_CONT
>>> bit set. But we clearly missed the device-folio cases. Thanks for
>>> reporting.
>>>
>>> Andrew, could you please squash the following fix into this patch? If
>>> you prefer a new version, please let me know. Thanks.
>>
>> Isn't the real problem that we should never ever ever ever, try
>> clearing the young bit on a non-present pte?
>>
>> See damon_ptep_mkold() how that is handled with the flushing/notify.
>>
>> There needs to be a pte_present() check in the caller.
>
> The handling of ZONE_DEVICE memory in check_pte() makes me me doubt my
> earlier understanding. And I think you are right.
>
> } else if (pte_present(ptent)) {
> pfn = pte_pfn(ptent);
> } else {
> const softleaf_t entry = softleaf_from_pte(ptent);
>
> /* Handle un-addressable ZONE_DEVICE memory */
> if (!softleaf_is_device_private(entry) &&
> !softleaf_is_device_exclusive(entry))
> return false;
>
> pfn = softleaf_to_pfn(entry);
> }
>
>
>> BUT
>>
>> I recall that folio_referenced() should never apply to ZONE_DEVICE
>> folios. folio_referenced() is only called from memory reclaim code,
>> and ZONE_DEVICE pages never get reclaimed through vmscan.c
>
> Thanks for clarifying. So I can drop the pte valid check.
We should probably add a safety check in folio_referenced(), warning
if we would ever get a ZONE_DEVICE folio passed.
Can someone look into that ? :)
--
Cheers,
David
Powered by blists - more mailing lists