linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Dev Jain <dev.jain@arm.com>,
	ziy@nvidia.com, willy@infradead.org, dhowells@redhat.com,
	hughd@google.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	ryan.roberts@arm.com, aneesh.kumar@kernel.org
Subject: Re: [QUESTION] xas_reload() in iter_xarray_populate_pages()
Date: Tue, 17 Jun 2025 11:26:46 +0200	[thread overview]
Message-ID: <b2a08c1f-190b-4e20-b8be-704d12b406c8@redhat.com> (raw)
In-Reply-To: <8b8ce450-0300-4eed-a80f-2e8e18fb4e11@arm.com>

On 17.06.25 11:18, Dev Jain wrote:
> 
> On 17/06/25 1:17 pm, David Hildenbrand wrote:
>> On 17.06.25 07:10, 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()?
>>
>> I think the points where
>>
>> (a) this should go all away soon
>>
>> (b) there is the expectation that the folios cannot get truncated
>>      concurrently. So we can do an unconditional folio_get(), don't have
>>      to check folio->mapping etc.
> 
> Well...pretty sure the file read path is taking the inode->i_rwsem or
> i_lock somewhere,
> 
> to synchronize with truncation/reclaim, can't figure out where. Reclaim
> takes the i_lock in __remove_mapping and
> 
> then freezes the folio reference, so the read path must lock i_lock
> somewhere.

I mean, if concurrent freeing of a folio would be possible, the function 
would be horribly broken :)

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2025-06-17  9:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-26  6:35 [QUESTION] xas_reload() in iter_xarray_populate_pages() Dev Jain
2025-05-26  7:40 ` David Hildenbrand
2025-05-26 19:20   ` Matthew Wilcox
2025-06-17  5:10 ` Dev Jain
2025-06-17  7:47   ` David Hildenbrand
2025-06-17  9:18     ` Dev Jain
2025-06-17  9:26       ` David Hildenbrand [this message]
2025-06-17  9:38         ` Dev Jain
2025-06-17 13:47   ` Matthew Wilcox
2025-06-18  3:14     ` Dev Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2a08c1f-190b-4e20-b8be-704d12b406c8@redhat.com \
    --to=david@redhat.com \
    --cc=aneesh.kumar@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=dhowells@redhat.com \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ryan.roberts@arm.com \
    --cc=willy@infradead.org \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).