linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2] hugetlb: fix race condition in hugetlb_fault()
  2012-04-01 12:10     ` Hillf Danton
@ 2012-04-01 16:51 Chris Metcalf
  2012-03-30 20:07 ` [PATCH] " Chris Metcalf
  2012-04-06 22:23 ` [PATCH v2] hugetlb: fix race condition in hugetlb_fault() Andrew Morton
  0 siblings, 2 replies; 17+ messages in thread
From: Chris Metcalf @ 2012-04-01 16:51 UTC (permalink / raw)
  To: Hillf Danton
  Cc: linux-kernel, linux-mm, Andrew Morton, Michal Hocko,
	KAMEZAWA Hiroyuki, Hugh Dickins

On 4/1/2012 8:10 AM, Hillf Danton wrote:
> On Sat, Mar 31, 2012 at 4:07 AM, Chris Metcalf <cmetcalf@tilera.com> wrote:
>> The race is as follows.  Suppose a multi-threaded task forks a new
>> process, thus bumping up the ref count on all the pages.  While the fork
>> is occurring (and thus we have marked all the PTEs as read-only), another
>> thread in the original process tries to write to a huge page, taking an
>> access violation from the write-protect and calling hugetlb_cow().  Now,
>> suppose the fork() fails.  It will undo the COW and decrement the ref
>> count on the pages, so the ref count on the huge page drops back to 1.
>> Meanwhile hugetlb_cow() also decrements the ref count by one on the
>> original page, since the original address space doesn't need it any more,
>> having copied a new page to replace the original page.  This leaves the
>> ref count at zero, and when we call unlock_page(), we panic.
>>
>> The solution is to take an extra reference to the page while we are
>> holding the lock on it.
>>
> If the following chart matches the above description,
>
> [...]
>
> would you please spin with description refreshed?

Done, and thanks!  I added your timeline chart to my description; I figure
no harm in having it both ways.

>> Cc: stable@kernel.org
> Let Andrew do the stable work, ok?

Fair point.  I'm used to adding the Cc myself for things I push through the
arch/tile tree.  This of course does make more sense to go through Andrew,
so I'll remove it.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2012-04-07  0:25 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-01 16:51 [PATCH v2] hugetlb: fix race condition in hugetlb_fault() Chris Metcalf
2012-03-30 20:07 ` [PATCH] " Chris Metcalf
2012-03-30 20:07   ` [PATCH v2] " Chris Metcalf
2012-04-01 12:10     ` Hillf Danton
2012-03-30 20:07       ` [PATCH v3] " Chris Metcalf
2012-03-31 12:27   ` [PATCH] " Hillf Danton
2012-03-30 19:37     ` [PATCH v2] arch/tile: support multiple huge page sizes dynamically Chris Metcalf
2012-03-31 14:03       ` Hillf Danton
2012-03-30 19:37         ` [PATCH v3] " Chris Metcalf
2012-04-01 12:33           ` Hillf Danton
2012-04-01 16:46             ` Chris Metcalf
2012-04-02  2:21               ` Hillf Danton
2012-04-06 22:23 ` [PATCH v2] hugetlb: fix race condition in hugetlb_fault() Andrew Morton
2012-04-06 23:10   ` Hugh Dickins
2012-04-06 23:26     ` Andrew Morton
2012-04-06 23:35       ` Hugh Dickins
2012-04-07  0:25         ` Chris Metcalf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox