All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrea Arcangeli <andrea@suse.de>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, hugh@veritas.com
Subject: Re: smp race fix between invalidate_inode_pages* and do_no_page
Date: Tue, 13 Dec 2005 22:14:41 +0100	[thread overview]
Message-ID: <20051213211441.GH3092@opteron.random> (raw)
In-Reply-To: <20051213130227.2efac51e.akpm@osdl.org>

On Tue, Dec 13, 2005 at 01:02:27PM -0800, Andrew Morton wrote:
> It's always bugged me that filemap_nopage() doesn't lock the page.  There
> might be additional uglies which could be tidied up if we were to do so.
> 
> The scalability loss would happen if there are multiple processes/threads
> faulting in the same page I guess.   I wonder how important that would be.

I don't know for sure, I know for sure with threads faulting on the same
page at the same time is common, but I don't know with processes, I
expected it is possible. 

> I suppose that even if we did lock the page in filemap_nopage(), the
> coverage isn't sufficient here - it needs to extend into do_no_page()?

I think so, for invalidate_mapping_pages (the simpler case since it's
less aggressive) we'd need to drop the page lock after increasing the
mapcount, so page_mapped() will notice it has to skip the page.

> Why this rather than down_read/down_write?  We might even be able to hoist
> ext3_inode's i_truncate_sem into the address_space, for zero space cost on
> most Linux inodes (dunno).

The only reason for not using semaphores, is to keep the fast path 100%
scalable, without risking cacheline bouncing and without requiring
exclusive access to a cacheline in a cpu (i.e. writes).

> Is there some way in which we can use mapping->truncate_count to tell
> do_no_page() that it raced with invalidate()?  By checking it after the pte
> has been established?

I tried that but failed, the reason is that the truncate_count alone is
worthless, we combine the truncate_count with the i_size information and
we write and read them in reverse order to do the locking for truncate.

But invalidates can't change the i_size, so truncate_count alone can't
be used.

I could save 4 bytes by using truncate_count instead of sl->sequence,
but the ugliness of the code that it would have been generated made me
waste 4 bytes.

> yield() is pretty sucky.

I wonder if we can use a waitqueue to wait a wakeup from the writer
while still leaving the fast path readonly. In theory yield() should
never trigger, when it triggers it means we had a race condition, but I
also don't like yield. anyway it was pointless to make it more
complicated before hearing some comment, I'd rather not invest too much
time in the seqschedlocks before knowing if they will be used ;).

  reply	other threads:[~2005-12-13 21:14 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-13 19:37 smp race fix between invalidate_inode_pages* and do_no_page Andrea Arcangeli
2005-12-13 21:02 ` Andrew Morton
2005-12-13 21:14   ` Andrea Arcangeli [this message]
2005-12-16 13:51     ` Andrea Arcangeli
2006-01-10  6:24       ` Andrea Arcangeli
2006-01-10  6:48         ` Andrea Arcangeli
2006-01-11  4:08         ` Nick Piggin
2006-01-11  8:23           ` Andrea Arcangeli
2006-01-11  8:51             ` Andrew Morton
2006-01-11  9:02               ` Andrea Arcangeli
2006-01-11  9:06                 ` Andrew Morton
2006-01-11  9:13                   ` Andrea Arcangeli
2006-01-11 20:49                     ` Hugh Dickins
2006-01-11 21:05                       ` Andrew Morton
2006-01-13  7:35                       ` Nick Piggin
2006-01-13  7:47                         ` Andrew Morton
2006-01-13 10:37                           ` Nick Piggin
2006-03-31 12:36                             ` Andrea Arcangeli
2006-04-02  5:17                               ` Nick Piggin
2006-04-02  5:21                               ` Andrew Morton
2006-04-07 19:18                                 ` Hugh Dickins
2006-01-11  9:39                 ` Nick Piggin
2006-01-11  9:34             ` 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=20051213211441.GH3092@opteron.random \
    --to=andrea@suse.de \
    --cc=akpm@osdl.org \
    --cc=hugh@veritas.com \
    --cc=linux-kernel@vger.kernel.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 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.