All of lore.kernel.org
 help / color / mirror / Atom feed
* Where does a process wait after requesting some data file ?
@ 2009-01-15 13:50 Francis Moreau
  2009-01-15 14:00 ` Matthew Wilcox
  0 siblings, 1 reply; 8+ messages in thread
From: Francis Moreau @ 2009-01-15 13:50 UTC (permalink / raw)
  To: linux-fsdevel

Hello,

Let's say that a process wants to read a page of data stored in a file.
For that it issues a sys_read().

Now the data page is not in the page cache and it must be fetched from
the disk.

So I assume while the data page is recovered from the disk, the process
is suspended until the data are ready to be read.

Could anybody show me where in the source code where the process is
suspended ?

Thanks
-- 
Francis

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Where does a process wait after requesting some data file ?
  2009-01-15 13:50 Where does a process wait after requesting some data file ? Francis Moreau
@ 2009-01-15 14:00 ` Matthew Wilcox
  2009-01-15 16:20   ` Manish Katiyar
  2009-01-16 16:30   ` Francis Moreau
  0 siblings, 2 replies; 8+ messages in thread
From: Matthew Wilcox @ 2009-01-15 14:00 UTC (permalink / raw)
  To: Francis Moreau; +Cc: linux-fsdevel

On Thu, Jan 15, 2009 at 02:50:27PM +0100, Francis Moreau wrote:
> Let's say that a process wants to read a page of data stored in a file.
> For that it issues a sys_read().
> 
> Now the data page is not in the page cache and it must be fetched from
> the disk.
> 
> So I assume while the data page is recovered from the disk, the process
> is suspended until the data are ready to be read.
> 
> Could anybody show me where in the source code where the process is
> suspended ?

Sure.  Take a look in mm/filemap.c.  Filesystems that use the page cache
will usually end up calling do_generic_file_read() one way or another.
It tries to find the page in the page cache, when it doesn't find the
page, it creates it, then calls ->readpage() to start the read, and
lock_page_killable() to wait for the page to be read.  As the comment
says, when the read finishes, it will unlock the page and the reader
will continue.

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Where does a process wait after requesting some data file ?
  2009-01-15 14:00 ` Matthew Wilcox
@ 2009-01-15 16:20   ` Manish Katiyar
  2009-01-15 16:54     ` Matthew Wilcox
  2009-01-16 16:30   ` Francis Moreau
  1 sibling, 1 reply; 8+ messages in thread
From: Manish Katiyar @ 2009-01-15 16:20 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Francis Moreau, linux-fsdevel

On Thu, Jan 15, 2009 at 7:30 PM, Matthew Wilcox <matthew@wil.cx> wrote:
> On Thu, Jan 15, 2009 at 02:50:27PM +0100, Francis Moreau wrote:
>> Let's say that a process wants to read a page of data stored in a file.
>> For that it issues a sys_read().
>>
>> Now the data page is not in the page cache and it must be fetched from
>> the disk.
>>
>> So I assume while the data page is recovered from the disk, the process
>> is suspended until the data are ready to be read.
>>
>> Could anybody show me where in the source code where the process is
>> suspended ?

I might be wrong, because I am a newbie too.......but still i will
try. I think it follows the below path.

do_generic_file_read() -> find_get_page() (This tries to find the
required page in cache). If we don't find here we try to do a
readahead using page_cache_sync_readahead() and then we eventually
call mpage_readpage() -> do_mpage_readpage() and then we put it in the
cache using add_to_page_cache_lru().

Please correct me if I am wrong.

Thanks -
Manish

>
> Sure.  Take a look in mm/filemap.c.  Filesystems that use the page cache
> will usually end up calling do_generic_file_read() one way or another.
> It tries to find the page in the page cache, when it doesn't find the
> page, it creates it, then calls ->readpage() to start the read, and
> lock_page_killable() to wait for the page to be read.  As the comment
> says, when the read finishes, it will unlock the page and the reader
> will continue.
>
> --
> Matthew Wilcox                          Intel Open Source Technology Centre
> "Bill, look, we understand that you're interested in selling us this
> operating system, but compare it to ours.  We can't possibly take such
> a retrograde step."
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Where does a process wait after requesting some data file ?
  2009-01-15 16:20   ` Manish Katiyar
@ 2009-01-15 16:54     ` Matthew Wilcox
  2009-01-15 16:56       ` Manish Katiyar
  0 siblings, 1 reply; 8+ messages in thread
From: Matthew Wilcox @ 2009-01-15 16:54 UTC (permalink / raw)
  To: Manish Katiyar; +Cc: Francis Moreau, linux-fsdevel

On Thu, Jan 15, 2009 at 09:50:57PM +0530, Manish Katiyar wrote:
> On Thu, Jan 15, 2009 at 7:30 PM, Matthew Wilcox <matthew@wil.cx> wrote:
> > On Thu, Jan 15, 2009 at 02:50:27PM +0100, Francis Moreau wrote:
> >> Let's say that a process wants to read a page of data stored in a file.
> >> For that it issues a sys_read().
> >>
> >> Now the data page is not in the page cache and it must be fetched from
> >> the disk.
> >>
> >> So I assume while the data page is recovered from the disk, the process
> >> is suspended until the data are ready to be read.
> >>
> >> Could anybody show me where in the source code where the process is
> >> suspended ?
> 
> I might be wrong, because I am a newbie too.......but still i will
> try. I think it follows the below path.
> 
> do_generic_file_read() -> find_get_page() (This tries to find the
> required page in cache). If we don't find here we try to do a
> readahead using page_cache_sync_readahead() and then we eventually
> call mpage_readpage() -> do_mpage_readpage() and then we put it in the
> cache using add_to_page_cache_lru().
> 
> Please correct me if I am wrong.

You're not wrong, but you aren't answering his question.  He asked where
the process is suspended, and the answer is "in __lock_page_killable()".

> Thanks -
> Manish
> 
> >
> > Sure.  Take a look in mm/filemap.c.  Filesystems that use the page cache
> > will usually end up calling do_generic_file_read() one way or another.
> > It tries to find the page in the page cache, when it doesn't find the
> > page, it creates it, then calls ->readpage() to start the read, and
> > lock_page_killable() to wait for the page to be read.  As the comment
> > says, when the read finishes, it will unlock the page and the reader
> > will continue.
> >
> > --
> > Matthew Wilcox                          Intel Open Source Technology Centre
> > "Bill, look, we understand that you're interested in selling us this
> > operating system, but compare it to ours.  We can't possibly take such
> > a retrograde step."
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Where does a process wait after requesting some data file ?
  2009-01-15 16:54     ` Matthew Wilcox
@ 2009-01-15 16:56       ` Manish Katiyar
  0 siblings, 0 replies; 8+ messages in thread
From: Manish Katiyar @ 2009-01-15 16:56 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Francis Moreau, linux-fsdevel

On Thu, Jan 15, 2009 at 10:24 PM, Matthew Wilcox <matthew@wil.cx> wrote:
> On Thu, Jan 15, 2009 at 09:50:57PM +0530, Manish Katiyar wrote:
>> On Thu, Jan 15, 2009 at 7:30 PM, Matthew Wilcox <matthew@wil.cx> wrote:
>> > On Thu, Jan 15, 2009 at 02:50:27PM +0100, Francis Moreau wrote:
>> >> Let's say that a process wants to read a page of data stored in a file.
>> >> For that it issues a sys_read().
>> >>
>> >> Now the data page is not in the page cache and it must be fetched from
>> >> the disk.
>> >>
>> >> So I assume while the data page is recovered from the disk, the process
>> >> is suspended until the data are ready to be read.
>> >>
>> >> Could anybody show me where in the source code where the process is
>> >> suspended ?
>>
>> I might be wrong, because I am a newbie too.......but still i will
>> try. I think it follows the below path.
>>
>> do_generic_file_read() -> find_get_page() (This tries to find the
>> required page in cache). If we don't find here we try to do a
>> readahead using page_cache_sync_readahead() and then we eventually
>> call mpage_readpage() -> do_mpage_readpage() and then we put it in the
>> cache using add_to_page_cache_lru().
>>
>> Please correct me if I am wrong.
>
> You're not wrong, but you aren't answering his question.  He asked where
> the process is suspended, and the answer is "in __lock_page_killable()".

Thanks a lot.

thanks -
Manish


>
>> Thanks -
>> Manish
>>
>> >
>> > Sure.  Take a look in mm/filemap.c.  Filesystems that use the page cache
>> > will usually end up calling do_generic_file_read() one way or another.
>> > It tries to find the page in the page cache, when it doesn't find the
>> > page, it creates it, then calls ->readpage() to start the read, and
>> > lock_page_killable() to wait for the page to be read.  As the comment
>> > says, when the read finishes, it will unlock the page and the reader
>> > will continue.
>> >
>> > --
>> > Matthew Wilcox                          Intel Open Source Technology Centre
>> > "Bill, look, we understand that you're interested in selling us this
>> > operating system, but compare it to ours.  We can't possibly take such
>> > a retrograde step."
>> > --
>> > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
>> > the body of a message to majordomo@vger.kernel.org
>> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> >
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> --
> Matthew Wilcox                          Intel Open Source Technology Centre
> "Bill, look, we understand that you're interested in selling us this
> operating system, but compare it to ours.  We can't possibly take such
> a retrograde step."
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Where does a process wait after requesting some data file ?
  2009-01-15 14:00 ` Matthew Wilcox
  2009-01-15 16:20   ` Manish Katiyar
@ 2009-01-16 16:30   ` Francis Moreau
  2009-01-17 21:06     ` Matthew Wilcox
  1 sibling, 1 reply; 8+ messages in thread
From: Francis Moreau @ 2009-01-16 16:30 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-fsdevel

Hello Matthew,

Thanks for your precious answers.

On Thu, Jan 15, 2009 at 3:00 PM, Matthew Wilcox <matthew@wil.cx> wrote:
> Sure.  Take a look in mm/filemap.c.  Filesystems that use the page cache
> will usually end up calling do_generic_file_read() one way or another.
> It tries to find the page in the page cache, when it doesn't find the
> page, it creates it, then calls ->readpage() to start the read, and
> lock_page_killable() to wait for the page to be read.

I see now thanks !

> As the comment says, when the read finishes, it will unlock the page
> and the reader will continue.

I expect that the comment you're talking about is this one in
do_generic_file_read():

page_not_up_to_date:
                /* Get exclusive access to the page ... */
                error = lock_page_killable(page);
                if (unlikely(error))
                        goto readpage_error;

If so, IMHO it's pretty useless as is... it could have been:

/* we're probably going to wait for the data to be ready */

or something.
-- 
Francis

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Where does a process wait after requesting some data file ?
  2009-01-16 16:30   ` Francis Moreau
@ 2009-01-17 21:06     ` Matthew Wilcox
  2009-01-17 22:07       ` Francis Moreau
  0 siblings, 1 reply; 8+ messages in thread
From: Matthew Wilcox @ 2009-01-17 21:06 UTC (permalink / raw)
  To: Francis Moreau; +Cc: linux-fsdevel

On Fri, Jan 16, 2009 at 05:30:12PM +0100, Francis Moreau wrote:
> > As the comment says, when the read finishes, it will unlock the page
> > and the reader will continue.
> 
> I expect that the comment you're talking about is this one in
> do_generic_file_read():
> 
> page_not_up_to_date:
>                 /* Get exclusive access to the page ... */

I meant this one:

readpage:
                /* Start the actual read. The read will unlock the page. */


-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Where does a process wait after requesting some data file ?
  2009-01-17 21:06     ` Matthew Wilcox
@ 2009-01-17 22:07       ` Francis Moreau
  0 siblings, 0 replies; 8+ messages in thread
From: Francis Moreau @ 2009-01-17 22:07 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-fsdevel

Matthew Wilcox <matthew@wil.cx> writes:

> On Fri, Jan 16, 2009 at 05:30:12PM +0100, Francis Moreau wrote:
>> > As the comment says, when the read finishes, it will unlock the page
>> > and the reader will continue.
>> 
>> I expect that the comment you're talking about is this one in
>> do_generic_file_read():
>> 
>> page_not_up_to_date:
>>                 /* Get exclusive access to the page ... */
>
> I meant this one:
>
> readpage:
>                 /* Start the actual read. The read will unlock the page. */
>

Well, if I read the code correctly, this is executed if
page_cache_sync_readahead() failed which is not the 'normal' path.

Thanks
-- 
Francis

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-01-17 22:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-15 13:50 Where does a process wait after requesting some data file ? Francis Moreau
2009-01-15 14:00 ` Matthew Wilcox
2009-01-15 16:20   ` Manish Katiyar
2009-01-15 16:54     ` Matthew Wilcox
2009-01-15 16:56       ` Manish Katiyar
2009-01-16 16:30   ` Francis Moreau
2009-01-17 21:06     ` Matthew Wilcox
2009-01-17 22:07       ` Francis Moreau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.