mm: add rss counters consistency check
Warn about non-zero rss counters at final mmdrop. This check will prevent reoccurences of bugs such as that fixed in "mm: fix rss count leakage during migration". I didn't hide this check under CONFIG_VM_DEBUG because it rather small and rss counters cover whole page-table management, so this is a good invariant. Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org> Cc: Hugh Dickins <hughd@google.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Родитель
dc3f21eade
Коммит
c3f0327f8e
|
@ -511,6 +511,23 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void check_mm(struct mm_struct *mm)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < NR_MM_COUNTERS; i++) {
|
||||||
|
long x = atomic_long_read(&mm->rss_stat.count[i]);
|
||||||
|
|
||||||
|
if (unlikely(x))
|
||||||
|
printk(KERN_ALERT "BUG: Bad rss-counter state "
|
||||||
|
"mm:%p idx:%d val:%ld\n", mm, i, x);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
||||||
|
VM_BUG_ON(mm->pmd_huge_pte);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate and initialize an mm_struct.
|
* Allocate and initialize an mm_struct.
|
||||||
*/
|
*/
|
||||||
|
@ -538,9 +555,7 @@ void __mmdrop(struct mm_struct *mm)
|
||||||
mm_free_pgd(mm);
|
mm_free_pgd(mm);
|
||||||
destroy_context(mm);
|
destroy_context(mm);
|
||||||
mmu_notifier_mm_destroy(mm);
|
mmu_notifier_mm_destroy(mm);
|
||||||
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
check_mm(mm);
|
||||||
VM_BUG_ON(mm->pmd_huge_pte);
|
|
||||||
#endif
|
|
||||||
free_mm(mm);
|
free_mm(mm);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(__mmdrop);
|
EXPORT_SYMBOL_GPL(__mmdrop);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче