|
|
Log in / Subscribe / Register

Re: [RFC][PATCH 6/8] mm: handle_speculative_fault()

From:  Linus Torvalds <torvalds-AT-linux-foundation.org>
To:  Minchan Kim <minchan.kim-AT-gmail.com>
Subject:  Re: [RFC][PATCH 6/8] mm: handle_speculative_fault()
Date:  Mon, 4 Jan 2010 20:48:23 -0800 (PST)
Cc:  KAMEZAWA Hiroyuki <kamezawa.hiroyu-AT-jp.fujitsu.com>, Peter Zijlstra <a.p.zijlstra-AT-chello.nl>, "Paul E. McKenney" <paulmck-AT-linux.vnet.ibm.com>, Peter Zijlstra <peterz-AT-infradead.org>, "linux-kernel-AT-vger.kernel.org" <linux-kernel-AT-vger.kernel.org>, "linux-mm-AT-kvack.org" <linux-mm-AT-kvack.org>, cl-AT-linux-foundation.org, "hugh.dickins" <hugh.dickins-AT-tiscali.co.uk>, Nick Piggin <nickpiggin-AT-yahoo.com.au>, Ingo Molnar <mingo-AT-elte.hu>



On Tue, 5 Jan 2010, Minchan Kim wrote:
> 
> Isn't it protected by get_file and iget?

When the vma is mapped, yes.

> Am I miss something?

remove_vma() will have done a

	fput(vma->vm_file);

and other house-keeping (removing the executable info, doing 
vm_ops->close() etc). 

And that is _not_ done delayed by RCU, and as outlined in my previous 
email I think that if the code really _does_ delay it, then munmap() (and 
exit) need to wait for the RCU callbacks to have been done, because 
otherwise the file may end up being busy "asynchronously" in ways that 
break existing semantics.

Just as an example: imagine a script that does "fork()+execve()" on a 
temporary file, and then after waiting for it all to finish with wait4() 
does some re-write of the file. It currently works. But what if the 
open-for-writing gets ETXTBUSY because the file is still marked as being 
VM_DENYWRITE, and RCU hasn't done all the callbacks?

Or if you do the i_writecount handling synchronously (which is likely fine 
- it really is just for ETXTBUSY handling, and I don't think speculative 
page faults matter), what about a shutdown sequence (or whatever) that 
wants to unmount the filesystem, but the file is still open - as it has to 
be - because the actual close is delayed by RCU.

So the patch-series as-is is fundamentally buggy - and trying to fix it 
seems painful.

I'm also not entirely clear on how the race with page table tear-down vs 
page-fault got handled, but I didn't read the whole patch-series very 
carefully. I skimmed through it and got rather nervous about it all. It 
doesn't seem too large, but it _does_ seem rather cavalier about all the 
object lifetimes.

		Linus

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>




to post comments


Copyright © 2010, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds