mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: San Mehat <san@google.com>
Cc: linux-kernel@vger.kernel.org,
	Brian Swetland <swetland@google.com>,
	Matt Mackall <mpm@selenic.com>, Dave Hansen <haveblue@us.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] proc: pagemap: Hold mmap_sem during page walk
Date: Wed, 31 Mar 2010 10:54:45 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.00.1003311036200.3707@i5.linux-foundation.org> (raw)
In-Reply-To: <1270056227-5442-1-git-send-email-san@google.com>



On Wed, 31 Mar 2010, San Mehat wrote:
>
> If the mmap_sem is not held while we walk_page_range(), then
> it is possible for find_vma() to race with a remove_vma_list()
> caused by do_munmap() (or others).

I think you've found a bug, but I also look at that code and say "that's 
just totally insane".

Why does it do that initial "get_user_pages()" at all? It never _uses_ 
that 'pages' array except to mark the pages dirty, but that's insane, 
since as far as I can see the way it actually dirties the pages in 
question is by doing a regular "put_user(pfn, pm->out);". And that will 
dirty the pages in hardware (or put_user).

Also, I get the feeling that the _reason_ it is not doing that down_read() 
is that it would dead-lock the whole system, exactly on that "put_user()", 
if somebody else did a down_write() in another thread. In that case you 
have:

	thread#1		thread#2
	--------		--------

	down_read()
	...
				down_write() - blocks
	...
	put_user();
	 .. page fault ..
	  down_read();	 **DEADLOCK **


because our down_read() tries to be fair to the down_write().

So I think your patch would just create _different_ trouble.

I get the _feeling_ that the whole point of that 'pages' array was to not 
do that put_user() at all, but write to the physical pages through that 
array. But the code looks totally buggy.

I would seriously suggest that we consider removing the 'pagemap' 
interface. The way that code looks, it's just broken.

Matt - give me a reason (which includes either a patch to fix this sh*t up 
or telling me why I'm wrong, but _also_ includes a real independent reason 
to keep that thing around regardless) to not remove it all.

The whole notion seems to be utterly misdesigned.

			Linus

  reply	other threads:[~2010-03-31 17:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-31 17:23 San Mehat
2010-03-31 17:54 ` Linus Torvalds [this message]
2010-03-31 21:40   ` Matt Mackall
2010-04-01  1:33     ` Linus Torvalds
2010-04-01  2:10       ` KOSAKI Motohiro
2010-04-01  3:20       ` Matt Mackall
2010-04-01  4:27         ` Linus Torvalds
2010-04-01  5:54         ` KOSAKI Motohiro
2010-04-01  5:55           ` KAMEZAWA Hiroyuki
2010-04-01  6:05             ` KOSAKI Motohiro
2010-04-01  6:09               ` KAMEZAWA Hiroyuki
2010-04-01  6:34                 ` KAMEZAWA Hiroyuki
2010-04-01  7:09                   ` Matt Mackall
2010-04-01  7:21                     ` KOSAKI Motohiro
2010-04-01 15:10                   ` Linus Torvalds
2010-04-02  0:11                     ` KAMEZAWA Hiroyuki
2010-04-02 14:30                       ` Matt Mackall
2010-04-06  6:48                         ` KAMEZAWA Hiroyuki

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=alpine.LFD.2.00.1003311036200.3707@i5.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=haveblue@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.com \
    --cc=san@google.com \
    --cc=swetland@google.com \
    /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

Powered by JetHome