[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+55aFyzjvq=qQM1sNcyqt06u_05zyYv4RyCx+n8vZ4RLu7R5g@mail.gmail.com>
Date: Sun, 16 Dec 2012 11:58:09 -0800
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Andy Lutomirski <luto@...capital.net>
Cc: linux-mm <linux-mm@...ck.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Al Viro <viro@...iv.linux.org.uk>,
Ingo Molnar <mingo@...nel.org>,
Michel Lespinasse <walken@...gle.com>,
Hugh Dickins <hughd@...gle.com>,
Jörn Engel <joern@...fs.org>
Subject: Re: [PATCH v2] mm: Downgrade mmap_sem before locking or populating on mmap
On Fri, Dec 14, 2012 at 6:17 PM, Andy Lutomirski <luto@...capital.net> wrote:
> This is a serious cause of mmap_sem contention. MAP_POPULATE
> and MCL_FUTURE, in particular, are disastrous in multithreaded programs.
>
> Signed-off-by: Andy Lutomirski <luto@...capital.net>
Ugh. This patch is just too ugly.
Conditional locking like this is just too disgusting for words. And
this v2 is worse, with that whole disgusting 'downgraded' pointer
thing.
I'm not applying disgusting hacks like this. I suspect you can clean
it up by moving the mlock/populate logic into the (few) callers
instead (first as a separate patch that doesn't do the downgrading)
and then a separate patch that does the downgrade in the callers,
possibly using a "finish_mmap" helper function that releases the lock.
No "if (write) up_write() else up_read()" crap. Instead, make the
finish_mmap helper do something like
if (!populate_r_mlock) {
up_write(mmap_sem);
return;
}
downgrade(mmap_sem);
.. populate and mlock ..
up_read(mmap_sem);
and you never have any odd "now I'm holding it for writing" state
variable with conditional locking rules etc.
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists