linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix migration races in rmap_walk()
@ 2010-04-26 22:37 Mel Gorman
  2010-04-26 22:37 ` [PATCH 1/2] mm,migration: During fork(), wait for migration to end if migration PTE is encountered Mel Gorman
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Mel Gorman @ 2010-04-26 22:37 UTC (permalink / raw)
  To: Linux-MM, LKML
  Cc: Minchan Kim, KAMEZAWA Hiroyuki, Mel Gorman, Christoph Lameter,
	Andrea Arcangeli, Rik van Riel, Andrew Morton

After digging around a lot, I believe the following two patches are the
best way to close the race that allows a migration PTE to be left behind
triggering a BUG check in migration_entry_to_page().

Patch one alters has fork() wait for migration to complete. Patch two has
vma_adjust() acquire the anon_vma lock it is aware of and makes rmap_walk()
aware that different VMAs can be encountered during the walk.

I dropped the use of the seq counter because there were still races in
place. For example, while the seq counter would catch when vma_adjust()
and rmap_walk() were looking at the same VMA, there was still insufficient
protection on the VMA list being modified.

The reproduction case was as follows;

1. Run kernel compilation in a loop
2. Start two processes that repeatedly fork()ed and manipulated mappings
3. Constantly compact memory using /proc/sys/vm/compact_memory
4. Optionally add/remove swap

With these two patches applied, I was unable to trigger the bug check
in migration_entry_to_page() but it would be really helpful if Rik could
comment on the anon_vma locking requirements and whether patch 2 is 100%
safe or not.  The tests have only been running 8 hours but I'm posting now
anyway and will see how it survives running for a few days.

The other issues raised about expand_downwards will need to be re-examined to
see if they still exist and transparent hugepage support will need further
thinking to see if split_huge_page() can deal with these situations.

 mm/ksm.c    |   13 +++++++++++++
 mm/memory.c |   25 ++++++++++++++++---------
 mm/mmap.c   |    6 ++++++
 mm/rmap.c   |   23 ++++++++++++++++++++---
 4 files changed, 55 insertions(+), 12 deletions(-)

--
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>

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

end of thread, other threads:[~2010-04-27 16:36 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-26 22:37 [PATCH 0/2] Fix migration races in rmap_walk() Mel Gorman
2010-04-26 22:37 ` [PATCH 1/2] mm,migration: During fork(), wait for migration to end if migration PTE is encountered Mel Gorman
2010-04-26 23:28   ` Minchan Kim
2010-04-27  0:08   ` Rik van Riel
2010-04-26 22:37 ` [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] seeing the wrong VMA information Mel Gorman
2010-04-26 23:05   ` Minchan Kim
2010-04-27  0:30     ` KAMEZAWA Hiroyuki
2010-04-27  9:17     ` Mel Gorman
2010-04-26 23:15   ` Minchan Kim
2010-04-27  0:07   ` KAMEZAWA Hiroyuki
2010-04-27  3:50     ` KAMEZAWA Hiroyuki
2010-04-27  4:03       ` KAMEZAWA Hiroyuki
2010-04-27  8:59       ` Mel Gorman
2010-04-27  9:09         ` KAMEZAWA Hiroyuki
2010-04-27 10:29           ` Mel Gorman
2010-04-27 15:37             ` Andrea Arcangeli
2010-04-27 16:35               ` Mel Gorman
2010-04-27  0:30   ` Rik van Riel
2010-04-27  0:31     ` KAMEZAWA Hiroyuki
2010-04-27  2:13       ` Rik van Riel
2010-04-26 23:04 ` [PATCH 0/2] Fix migration races in rmap_walk() Andrea Arcangeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).