mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: andrea@suse.de, linux-kernel@vger.kernel.org, mason@suse.com
Subject: Re: [patch] fix the 2nd buffer race properly
Date: Wed, 27 Apr 2005 18:00:12 -0700	[thread overview]
Message-ID: <20050427180012.26b75e0f.akpm@osdl.org> (raw)
In-Reply-To: <4270296D.9010109@yahoo.com.au>

Nick Piggin <nickpiggin@yahoo.com.au> wrote:
>
> > There are two situations:
>  > 
>  > a) Thread 2 comes in and tries to write a buffer which thread1 didn't write:
>  > 
>  >    Yes, thread 1 will get confused and will try to write thread 2's buffer.
>  > 
>  > b) Thread 2 comes in and tries to write a buffer which thread 1 is
>  >    writing.  (Say, the buffer was redirtied by
>  >    munmap->__set_page_dirty_buffers, which doesn't lock the page or the
>  >    buffers)
>  > 
> 
>  I don't think b) happens, because thread 1 has to have finished all
>  its writes before the page will end writeback and thread 2 can go
>  anywhere.

hm, spose so.

>  >    Thread 2 will fail the test_set_buffer_locked() and will redirty the page.
>  > 
>  > That's all a bit too complex.   How's about this instead?
>  > 
> 
>  Well you really don't need to hold the page locked for that long.

Is a rare case, so there's no perfomance issue here.

I do prefer the idea of simply keeping other threads of control out of the
page until this thread has finished playing with its buffers.

(The buffer-ring walk we have in there is racy against page reclaim, too. 
If only the first buffer is dirty, we inspect the other buffers after
PageWriteback has potentially cleared.)

>  block_read_full_page, nobh_prepare_write both use the same sort of
>  array of buffer heads logic - I think it makes sense not to touch
>  any buffers after submitting them all for IO...?

Well.  Most code in there uses the ->b_this_page walk.

  reply	other threads:[~2005-04-28  1:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-27 13:15 Nick Piggin
2005-04-27 13:20 ` Nick Piggin
2005-04-27 17:56 ` Andrew Morton
2005-04-28  0:08   ` Nick Piggin
2005-04-28  1:00     ` Andrew Morton [this message]
2005-04-28  1:29       ` 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=20050427180012.26b75e0f.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=andrea@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mason@suse.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®