login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2010
»
April
»
27
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] seeing the wrong VMA information
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: KAMEZAWA Hiroyuki
Subject:
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] seeing the wrong VMA information
Date: Monday, April 26, 2010 - 5:30 pm
On Tue, 27 Apr 2010 08:05:26 +0900 Minchan Kim <minchan.kim@gmail.com> wrote:
quoted text
> On Tue, Apr 27, 2010 at 7:37 AM, Mel Gorman <mel@csn.ul.ie> wrote: > > vma_adjust() is updating anon VMA information without any locks taken. > > In contrast, file-backed mappings use the i_mmap_lock and this lack of > > locking can result in races with page migration. During rmap_walk(), > > vma_address() can return -EFAULT for an address that will soon be valid. > > This leaves a dangling migration PTE behind which can later cause a BUG_ON > > to trigger when the page is faulted in. > > > > With the recent anon_vma changes, there can be more than one anon_vma->lock > > that can be taken in a anon_vma_chain but a second lock cannot be spinned > > upon in case of deadlock. Instead, the rmap walker tries to take locks of > > different anon_vma's. If the attempt fails, the operation is restarted. > > > > Signed-off-by: Mel Gorman <mel@csn.ul.ie> > > --- > > mm/ksm.c | 13 +++++++++++++ > > mm/mmap.c | 6 ++++++ > > mm/rmap.c | 22 +++++++++++++++++++--- > > 3 files changed, 38 insertions(+), 3 deletions(-) > > > > diff --git a/mm/ksm.c b/mm/ksm.c > > index 3666d43..baa5b4d 100644 > > --- a/mm/ksm.c > > +++ b/mm/ksm.c > > @@ -1674,9 +1674,22 @@ again: > > spin_lock(&anon_vma->lock); > > list_for_each_entry(vmac, &anon_vma->head, same_anon_vma) { > > vma = vmac->vma; > > + > > + /* See comment in mm/rmap.c#rmap_walk_anon on locking */ > > + if (anon_vma != vma->anon_vma) { > > + if (!spin_trylock(&vma->anon_vma->lock)) { > > + spin_unlock(&anon_vma->lock); > > + goto again; > > + } > > + } > > + > > if (rmap_item->address < vma->vm_start || > > rmap_item->address >= vma->vm_end) > > continue; > > + > > + if (anon_vma != vma->anon_vma) > > + spin_unlock(&vma->anon_vma->lock); > > + > > /* > > * Initially we examine only the vma which covers this > > * rmap_item; but later, if there is still work to do, > > diff --git a/mm/mmap.c b/mm/mmap.c > > index f90ea92..61d6f1d 100644 > > --- a/mm/mmap.c > > +++ b/mm/mmap.c > > @@ -578,6 +578,9 @@ again: remove_next = 1 + (end > next->vm_end); > > } > > } > > > > + if (vma->anon_vma) > > + spin_lock(&vma->anon_vma->lock); > > + > > if (root) { > > flush_dcache_mmap_lock(mapping); > > vma_prio_tree_remove(vma, root); > > @@ -620,6 +623,9 @@ again: remove_next = 1 + (end > next->vm_end); > > if (mapping) > > spin_unlock(&mapping->i_mmap_lock); > > > > + if (vma->anon_vma) > > + spin_unlock(&vma->anon_vma->lock); > > + > > if (remove_next) { > > if (file) { > > fput(file); > > diff --git a/mm/rmap.c b/mm/rmap.c > > index 85f203e..bc313a6 100644 > > --- a/mm/rmap.c > > +++ b/mm/rmap.c > > @@ -1368,15 +1368,31 @@ static int rmap_walk_anon(struct page *page, int (*rmap_one)(struct page *, > > * are holding mmap_sem. Users without mmap_sem are required to > > * take a reference count to prevent the anon_vma disappearing > > */ > > +retry: > > anon_vma = page_anon_vma(page); > > if (!anon_vma) > > return ret; > > spin_lock(&anon_vma->lock); > > list_for_each_entry(avc, &anon_vma->head, same_anon_vma) { > > struct vm_area_struct *vma = avc->vma; > > - unsigned long address = vma_address(page, vma); > > - if (address == -EFAULT) > > - continue; > > + unsigned long address; > > + > > + /* > > + * Guard against deadlocks by not spinning against > > + * vma->anon_vma->lock. If contention is found, release our > > + * lock and try again until VMA list can be traversed without > > + * contention. > > + */ > > + if (anon_vma != vma->anon_vma) { > > + if (!spin_trylock(&vma->anon_vma->lock)) { > > + spin_unlock(&anon_vma->lock); > > + goto retry; > > + } > > + } > > + address = vma_address(page, vma); > > + if (anon_vma != vma->anon_vma) > > + spin_unlock(&vma->anon_vma->lock); > > + > > if (address == -EFAULT) > continue; >
yes. thank you for pointing out. -Kame --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH 0/2] Fix migration races in rmap_walk()
, Mel Gorman
, (Mon Apr 26, 3:37 pm)
[PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] see ...
, Mel Gorman
, (Mon Apr 26, 3:37 pm)
Re: [PATCH 0/2] Fix migration races in rmap_walk()
, Andrea Arcangeli
, (Mon Apr 26, 4:04 pm)
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] ...
, Minchan Kim
, (Mon Apr 26, 4:05 pm)
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] ...
, Minchan Kim
, (Mon Apr 26, 4:15 pm)
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] ...
, KAMEZAWA Hiroyuki
, (Mon Apr 26, 5:07 pm)
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] ...
, KAMEZAWA Hiroyuki
, (Mon Apr 26, 5:30 pm)
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] ...
, Rik van Riel
, (Mon Apr 26, 5:30 pm)
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] ...
, KAMEZAWA Hiroyuki
, (Mon Apr 26, 5:31 pm)
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] ...
, Rik van Riel
, (Mon Apr 26, 7:13 pm)
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] ...
, KAMEZAWA Hiroyuki
, (Mon Apr 26, 8:50 pm)
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] ...
, KAMEZAWA Hiroyuki
, (Mon Apr 26, 9:03 pm)
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] ...
, Mel Gorman
, (Tue Apr 27, 1:59 am)
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] ...
, KAMEZAWA Hiroyuki
, (Tue Apr 27, 2:09 am)
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] ...
, Mel Gorman
, (Tue Apr 27, 2:17 am)
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] ...
, Mel Gorman
, (Tue Apr 27, 3:29 am)
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] ...
, Andrea Arcangeli
, (Tue Apr 27, 8:37 am)
Re: [PATCH 2/2] mm,migration: Prevent rmap_walk_[anon|ksm] ...
, Mel Gorman
, (Tue Apr 27, 9:35 am)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Fortier,Vincent [Montreal]
2.6.21.5 june 30th to july 1st date hang?
Jeff Dike
[ PATCH 2/6 ] UML - Formatting fixes around os_{read_write}_file callers
Liam Girdwood
[PATCH 07/13] regulator: regulator test harness
Oleg Nesterov
Re: Getting the new RxRPC patches upstream
Stefan Seyfried
Re: 2.6.19-rc5: grub is much slower resuming from suspend-to-disk than in 2.6.18
linux-netdev
:
Arnaud Ebalard
Re: [REGRESSION,BISECTED] MIPv6 support broken by f4f914b58019f0
Jan Engelhardt
Re: [PATCH iptables] extension: add xt_cpu match
Jarek Poplawski
Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock().
Sebastian Andrzej Siewior
[PATCH 8/8] net/emergency: remove locking from reycling pool if emergncy pools are...
David Miller
Re: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2
git
:
Jakub Narebski
Re: git on MacOSX and files with decomposed utf-8 file names
Brandon Casey
Re: Thunderbird and patches (was Re: [PATCH v2] Enable setting attach as the def...
Christian Couder
[PATCH 1/3] rev-parse: add test script for "--verify"
Ramkumar Ramachandra
Re: [GSoC update] git-remote-svn: The final one
Junio C Hamano
Re: git-rm isn't the inverse action of git-add
openbsd-misc
:
Joachim Schipper
Re: UVC Webcams
Florin Andrei
SOLVED [was: firewall is very slow, something's wrong]
Todd Alan Smith
Re: Microsoft gets the Most Secure Operating Systems award
Neal Hogan
Re: Need Advice: Thinkpad T60 or T61?
Sam Fourman Jr.
Re: Real men don't attack straw men
git-commits-head
:
Linux Kernel Mailing List
ACPI: Disable ARB_DISABLE on platforms where it is not needed
Linux Kernel Mailing List
m68knommu: add read_barrier_depends() and irqs_disabled_flags()
Linux Kernel Mailing List
[MTD] Add mtd panic_write function pointer
Linux Kernel Mailing List
[ARM] pxa: remove duplicate select statements from Kconfig
Linux Kernel Mailing List
mlx4_core: Don't read reserved fields in mlx4_QUERY_ADAPTER()
Colocation donated by:
Syndicate