mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Lorenzo Stoakes <lstoakes@gmail.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Jan Kara <jack@suse.cz>
Subject: Re: [PATCH] mm/filemap: clarify filemap_fault() comments for not uptodate case
Date: Mon, 2 Oct 2023 17:02:00 +0100	[thread overview]
Message-ID: <ZRrpeNrmcNdTO5Qp@casper.infradead.org> (raw)
In-Reply-To: <20230930231029.88196-1-lstoakes@gmail.com>

On Sun, Oct 01, 2023 at 12:10:29AM +0100, Lorenzo Stoakes wrote:
> The existing comments in filemap_fault() suggest that, after either a minor
> fault has occurred and filemap_get_folio() found a folio in the page cache,
> or a major fault arose and __filemap_get_folio(FGP_CREATE...) did the job
> (having relied on do_sync_mmap_readahead() or filemap_read_folio() to read
> in the folio), the only possible reason it could not be uptodate is because
> of an error.
> 
> This is not so, as if, for instance, the fault occurred within a VMA which
> had the VM_RAND_READ flag set (via madvise() with the MADV_RANDOM flag
> specified), this would cause even synchronous readahead to fail to read in
> the folio.
> 
> I confirmed this by dropping page caches and faulting in memory madvise()'d
> this way, observing that this code path was reached on each occasion.
> 
> Clarify the comments to include this case, and additionally update the
> comment recently added around the invalidate lock logic to make it clear
> the comment explicitly refers to the minor fault case.

I do appreciate the comment being made accurate, but I wonder if we
shouldn't change the code to match the comment.  We're got two "should"s
pointing in different directions -- we "should" not use readahead if
readahead is disabled, and we "should" always use readahead first,
using read_folio() only if readahead doesn't succeed.

The code isn't ideally structured for this, but I'm going to play with
it a bit and see what I can create.

      parent reply	other threads:[~2023-10-02 16:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-30 23:10 Lorenzo Stoakes
2023-10-02  6:26 ` Christoph Hellwig
2023-10-02  6:39   ` Vlastimil Babka
2023-10-02  9:43     ` Joe Perches
2023-10-02  6:47   ` Lorenzo Stoakes
2023-10-02  6:50     ` Christoph Hellwig
2023-10-02  9:55 ` Jan Kara
2023-10-02 16:02 ` Matthew Wilcox [this message]

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=ZRrpeNrmcNdTO5Qp@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lstoakes@gmail.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

all inboxes | Powered by JetHome®