From: Andrew Morton <akpm@zip.com.au>
To: Michael Marxmeier <mike@marxmeier.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: Question on sys_readahead()
Date: Fri, 21 Dec 2001 15:25:13 -0800 [thread overview]
Message-ID: <3C23C4D9.F11B2472@zip.com.au> (raw)
In-Reply-To: <3C23BF4B.70BDABBE@marxmeier.com>
Michael Marxmeier wrote:
>
> I have a question on sys_readahead and would appreciate
> some hint or a pointer.
>
> - When was this call added?
Very late one night, we think :) It was added in linux-2.4.13-pre4.
> - As far as i understand the code it reads the data into
> the page cache. The data is ready sync and there is no
> way to do this async and have a notification unless using
> a separate thread.
It is async. The call will submit the IO and will return immediately.
It could block on things like memory shortage, request queue exhaustion,
but this is unlikely, and pretty much any syscall could block under these
conditions.
You should be able to poll the status of the readhead pages by mmapping
the relevant section of the file and then using mincore() to find out if
the IO has completed.
> A typical use i could see is preloading some data in the
> page cache from a separate thread (eg. for a media player).
Or from the same thread.
> BTW: AFAICS the code is off by one if offset/count is not in
> PAGE_SIZE chunks?
>
> unsigned long start = offset >> PAGE_CACHE_SHIFT;
> unsigned long len = (count + ((long)offset & ~PAGE_CACHE_MASK)) >> PAGE_CACHE_SHIFT;
Looks like it. If offset is zero and count is 4097, it will only read
one page.
-
prev parent reply other threads:[~2001-12-21 23:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-21 23:01 Question on sys_readahead() Michael Marxmeier
2001-12-21 23:25 ` Andrew Morton [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=3C23C4D9.F11B2472@zip.com.au \
--to=akpm@zip.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=mike@marxmeier.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