All of lore.kernel.org
 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: Mon, 26 May 2025 09:40:06 +0200	[thread overview]
Message-ID: <8da60934-0670-4f8a-8bde-fa4de320cdbb@redhat.com> (raw)
In-Reply-To: <20250526063524.22597-1-dev.jain@arm.com>

On 26.05.25 08:35, 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()?

The usual sequence for the pagecache is (see filemap_get_entry())

1) xas_load(): Load the entry

2) xas_retry(): Test if we have to retry immediately

3) folio || xa_is_value(folio): check if the entry stores a folio

4) folio_try_get(): try getting a folio reference, might get freed
    concurrently, so a folio_get() is not safe

5) folio != xas_reload(&xas): recheck whether the entry was changed
    concurrently

iter_xarray_get_pages()->iter_xarray_populate_pages() works on whatever 
xarray was provided to iov_iter_xarray().

erofs/netfs/orangefs seem to pass the pagecache ... so I would also 
assume that we have to use the same sequence as above.

Willy and me had a look ad that code in b57f4f4f186d ("iov_iter: convert 
iter_xarray_populate_pages() to use folios").

But looking at it now, I think that code is incorrect. At least the 
folio_get() and reload-before-folio-get is weird.

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2025-05-26  7:40 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 [this message]
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
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=8da60934-0670-4f8a-8bde-fa4de320cdbb@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.