mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-10-31 18:09:19 +00:00
[PATCH] adapt page_lock_anon_vma() to PREEMPT_RCU
page_lock_anon_vma() uses spin_lock() to block RCU. This doesn't work with PREEMPT_RCU, we have to do rcu_read_lock() explicitely. Otherwise, it is theoretically possible that slab returns anon_vma's memory to the system before we do spin_unlock(&anon_vma->lock). [ Hugh points out that this only matters for PREEMPT_RCU, which isn't merged yet, and may never be. Regardless, this patch is conceptually the right thing to do, even if it doesn't matter at this point. - Linus ] Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Cc: Paul McKenney <paulmck@linux.vnet.ibm.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Christoph Lameter <clameter@engr.sgi.com> Acked-by: Hugh Dickins <hugh@veritas.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
48dba8ab9b
commit
34bbd70405
1 changed files with 13 additions and 4 deletions
17
mm/rmap.c
17
mm/rmap.c
|
@ -183,7 +183,7 @@ void __init anon_vma_init(void)
|
||||||
*/
|
*/
|
||||||
static struct anon_vma *page_lock_anon_vma(struct page *page)
|
static struct anon_vma *page_lock_anon_vma(struct page *page)
|
||||||
{
|
{
|
||||||
struct anon_vma *anon_vma = NULL;
|
struct anon_vma *anon_vma;
|
||||||
unsigned long anon_mapping;
|
unsigned long anon_mapping;
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
|
@ -195,9 +195,16 @@ static struct anon_vma *page_lock_anon_vma(struct page *page)
|
||||||
|
|
||||||
anon_vma = (struct anon_vma *) (anon_mapping - PAGE_MAPPING_ANON);
|
anon_vma = (struct anon_vma *) (anon_mapping - PAGE_MAPPING_ANON);
|
||||||
spin_lock(&anon_vma->lock);
|
spin_lock(&anon_vma->lock);
|
||||||
|
return anon_vma;
|
||||||
out:
|
out:
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
return anon_vma;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void page_unlock_anon_vma(struct anon_vma *anon_vma)
|
||||||
|
{
|
||||||
|
spin_unlock(&anon_vma->lock);
|
||||||
|
rcu_read_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -333,7 +340,8 @@ static int page_referenced_anon(struct page *page)
|
||||||
if (!mapcount)
|
if (!mapcount)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
spin_unlock(&anon_vma->lock);
|
|
||||||
|
page_unlock_anon_vma(anon_vma);
|
||||||
return referenced;
|
return referenced;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -802,7 +810,8 @@ static int try_to_unmap_anon(struct page *page, int migration)
|
||||||
if (ret == SWAP_FAIL || !page_mapped(page))
|
if (ret == SWAP_FAIL || !page_mapped(page))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
spin_unlock(&anon_vma->lock);
|
|
||||||
|
page_unlock_anon_vma(anon_vma);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue