From: Peter Zijlstra <peterz@infradead.org>
To: Matt Klein <matt.klein@pikewerks.com>
Cc: linux-kernel@vger.kernel.org, Nick Piggin <nickpiggin@yahoo.com.au>
Subject: Re: Cached IO Synchronization Question
Date: Wed, 08 Apr 2009 17:23:37 +0200 [thread overview]
Message-ID: <1239204217.4557.2590.camel@laptop> (raw)
In-Reply-To: <49DA7498.3050000@pikewerks.com>
On Mon, 2009-04-06 at 14:31 -0700, Matt Klein wrote:
> (Please CC me on any responses)
>
> Hi,
>
> I am studying 2.6.27.21 to try to understand the IO synchronization
> model used in the Linux kernel.
>
> I have the following question:
>
> How are cached reads/writes synchronized? I assume they are, but I can
> not determine how it is done.
>
> 1) do_generic_file_read calls find_get_page to get the existing page
> cache page if it exists (it uses RCU to prevent the page from being
> blown away while reading takes place). Assuming it does, it performs
> various checks to make sure the page is up to date before performing an
> atomic copy to user mode. The read path does not take the page lock.
>
> 2) The write path takes both the inode lock and the page lock to prevent
> multiple writers. It also does an atomic copy from user mode into the
> page cache page.
>
> From my reading of the code, the atomic copies are atomic only on a
> single processor, not across processors. Right?
Not even that ;-)
> If so, what is to prevent one CPU from starting a cached read into a
> user mode buffer while another CPU has partially copied data into the
> page cache page?
Note how do_generic_file_read() checks PageUptodate() and does a
lock_page_killable() in case its not.
next prev parent reply other threads:[~2009-04-08 15:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-06 21:31 Matt Klein
2009-04-08 15:23 ` Peter Zijlstra [this message]
2009-04-08 15:56 ` Matt Klein
2009-04-09 3:56 ` Nick Piggin
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=1239204217.4557.2590.camel@laptop \
--to=peterz@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.klein@pikewerks.com \
--cc=nickpiggin@yahoo.com.au \
/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®