[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9cbbda32-b0e3-4509-a81c-9174ab741433@arm.com>
Date: Wed, 18 Jun 2025 08:44:05 +0530
From: Dev Jain <dev.jain@....com>
To: Matthew Wilcox <willy@...radead.org>
Cc: david@...hat.com, ziy@...dia.com, dhowells@...hat.com, hughd@...gle.com,
linux-mm@...ck.org, linux-kernel@...r.kernel.org, ryan.roberts@....com,
aneesh.kumar@...nel.org
Subject: Re: [QUESTION] xas_reload() in iter_xarray_populate_pages()
On 17/06/25 7:17 pm, Matthew Wilcox wrote:
> On Tue, Jun 17, 2025 at 10:40:51AM +0530, Dev Jain wrote:
>> On 26/05/25 12:05 pm, Dev Jain wrote:
>>> Hello all,
>>>
>>> After doing an xas_load() and xas_retry(), we take neither a reference nor a lock
>>> on the folio, and we do an xas_reload(). Is this just to reduce the time window
>>> for a race?
>>>
>>> If the above is true, then, there is a negligible window between xas_load() and
>>> xas_reload(), because only xas_retry() exists between them, so why to even reload()?
>>>
>>> Thanks,
>>> Dev
>> I do not completely remember our discussion in THP Cabal; I recall David Howells maybe
>> saying that the folios are already locked, so it is safe to do xas_load and then do
>> a folio_get()? Even if we remove the redundant xas_reload(), I still don't understand
>> why we won't need xas_reload() at least after folio_get()?
> Because you need xas_reload() in order to solve this race:
>
> A: load folio
> B: remove folio
> B: free folio
> C: alloc folio
> A: tryget folio
> A: reload folio
>
> If A already has a refcount on folio, folio cannot be freed, and so A
> cannot get a refcount to C's folio.
Yes sorry, I should have written that why is an unconditional folio get being
used instead of tryget...and the answer seems to be that we already probably
have the inode lock so we are guaranteed that the folio won't get evicted.
>
> The other mutexes are irrelevant here; this is purely a folio refcount
> problem/solution.
Powered by blists - more mailing lists