mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qiliang Yuan <qiliang.yuan@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Qiliang Yuan <qiliang.yuan@linux.dev>,
	Qiliang Yuan <odys.yuan@gmail.com>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Jan Kara <jack@suse.cz>, Joanne Koong <joannelkoong@gmail.com>,
	linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/readahead: look two windows ahead for the hole on a marker hit
Date: Tue, 17 Nov 2026 00:42:02 -0500	[thread overview]
Message-ID: <20261117054202.50460-1-qiliang.yuan@linux.dev> (raw)
In-Reply-To: <20261115203328.f98ce9a068849c2f2fb32a41@linux-foundation.org>

On Sun, Nov 15, 2026 at 08:33:28PM -0800, Andrew Morton wrote:
> And you have QEMU in the way, so reads can get served from host
> pagecache (depends on QEMU setup), which also matters.
>
> So I just don't know what to conclude from your numbers.  I *suspect*
> the gains are from reduced CPU & memory-access times which is of course
> good.  But was there any actual physical device access involved?

No, the host page cache was warm in those runs too.

I have now repeated them with the file on a raw disk attached with
cache=none, which sits on a hardware RAID of spinning disks in the
host, so every read in the guest goes to the disks. dd with O_DIRECT
reads the 16 GiB file at 440-490 MB/s. Same 8 MiB memcpy() pieces,
read_ahead_kb 8192, guest cache dropped before each run, v7.4-rc3
(666539eecdf4) with and without the patch, three alternating boots,
median, with the amount read from the disk:

                                 time (s)            read (MB)
  workload                    before  after change  before  after
  1 thread from offset 2 GiB   60.69  28.68   -53%   14340  14340
  8 threads, one range each    36.80  31.22   -15%   16384  16384
  32 threads, one range each   34.67  30.38   -12%   16384  16384
  8 threads, 7 MiB interleaved 27.54  27.20    -1%   16384  16384
  8 threads, pread()           32.06  32.27    +1%   16384  16384

The single reader goes from half the disk's bandwidth to all of it, and
its major faults drop from 1793 to 2. With 8 and 32 threads the disk is
already the limit, so the gain shrinks to 12-15%. None of these reads
more than the copy needs.

> I tested the patch on my LLM-driven test setup, which is similar to
> yours.  The results are...  ambivalent.  The things which you want
> faster are indeed faster, but other things slowed down (wall of words
> appended).

I reproduced both costs on the same disk in the same runs: fault in the
middle of a window at 64 places in the file, so read-around marks a
folio 6 MiB in, cache the next 8 MiB (or 16 MiB) with
POSIX_FADV_WILLNEED, then touch each marker once (median of the
per-run median access times):

  beyond the window      before (us)  after (us)  read before  read after
  8 MiB cached, then gap        16.1        43.1         0 MB      512 MB
  16 MiB cached                  9.3        17.5         0 MB        0 MB

The first row is a real cost of the patch: mainline reads nothing
there, the patch reads one more window (read_ahead_kb) per marker hit.
It is wasted only if the reader stops before that window. A reader that
goes on, like the copies above, would otherwise fault on the hole and
read it synchronously. The second row is the longer lookup when nothing
is read, about 8 us per such marker hit.

v2 is the same change rebased onto v7.4-rc2:
https://lore.kernel.org/r/20261109-bug-mm-readahead-async-overtaken-v2-1-06ead50562a2@linux.dev

Thanks,
Qiliang

      reply	other threads:[~2026-11-17  5:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 15:24 Qiliang Yuan
2026-11-16  4:33 ` Andrew Morton
2026-11-17  5:42   ` Qiliang Yuan [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=20261117054202.50460-1-qiliang.yuan@linux.dev \
    --to=qiliang.yuan@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=jack@suse.cz \
    --cc=joannelkoong@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=odys.yuan@gmail.com \
    --cc=willy@infradead.org \
    /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®