linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Bernd Schubert <bernd.schubert@fastmail.fm>
To: Matthew Wilcox <willy@infradead.org>
Cc: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	Miklos Szeredi <miklos@szeredi.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-doc@vger.kernel.org
Subject: Re: sequential 1MB mmap read ends in 1 page sync read-ahead
Date: Mon, 17 Apr 2023 17:10:03 +0200	[thread overview]
Message-ID: <48eca641-e810-fac5-0ff0-8762eed3f61e@fastmail.fm> (raw)
In-Reply-To: <ZDnNeKt1bPWb2PzC@casper.infradead.org>



On 4/15/23 00:02, Matthew Wilcox wrote:
> On Fri, Apr 14, 2023 at 10:47:39PM +0200, Bernd Schubert wrote:
>>> Up to bs=512K it works fine, 1M (and for what it matters
>>> already 768K) introduce the order=0 issue.
>>
>> Hmm, I replaced memcpy with dumb version, that copies byte by byte - problem
>> gone. Is it possible that the optimized memcpy causes caused kind of random
>> memory access and confuses mm / readahead?
>> And somehow your memcpy or system is not doing that?
> 
> Oh, that would make sense!  If the memcpy() works high-to-low, then
> you'd see exactly the behaviour you're reporting.  Whereas low-to-high
> results in the behaviour I'm seeing.

In my case it is not exactly high-to-low, it is more low, high, then 
from high to low. Issue goes away with a sufficiently large RA size. And 
RA behaves better when POSIX_MADV_SEQUENTIAL is not done.
For sure memcpy implementation and cpu depending (I have tested on avx 
and avx2 systems).

> 
> Hm.  I don't know what to do about that.  Maybe a "sufficiently large"
> memcpy should call posix_madvise(src, n, POSIX_MADV_WILLNEED)


What would speak against ignoring POSIX_MADV_SEQUENTIAL for RA when it 
would detect that something breaks the contract?

But then I don't know how much mmap/memcpy is used for large memcpy or 
memcmp - maybe we should just document the issue right now in the mmap 
man page? Especially that POSIX_MADV_SEQUENTIAL should be avoided?



Thanks,
Bernd


      reply	other threads:[~2023-04-17 15:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <aae918da-833f-7ec5-ac8a-115d66d80d0e@fastmail.fm>
2023-04-13 21:33 ` Bernd Schubert
2023-04-14  4:07   ` Matthew Wilcox
2023-04-14 15:05     ` Bernd Schubert
2023-04-14 19:52       ` Bernd Schubert
2023-04-14 20:47         ` Bernd Schubert
2023-04-14 22:02           ` Matthew Wilcox
2023-04-17 15:10             ` Bernd Schubert [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=48eca641-e810-fac5-0ff0-8762eed3f61e@fastmail.fm \
    --to=bernd.schubert@fastmail.fm \
    --cc=akpm@linux-foundation.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=miklos@szeredi.hu \
    --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