From: Nick Piggin I've moved the bugchecks under CONFIG_DEBUG_VM. Cc: Hugh Dickins Signed-off-by: Andrew Morton --- include/linux/rmap.h | 10 +++++++++- mm/rmap.c | 8 ++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff -puN include/linux/rmap.h~mm-more-rmap-checking-tidy include/linux/rmap.h --- a/include/linux/rmap.h~mm-more-rmap-checking-tidy +++ a/include/linux/rmap.h @@ -72,9 +72,17 @@ void __anon_vma_link(struct vm_area_stru void page_add_anon_rmap(struct page *, struct vm_area_struct *, unsigned long); void page_add_new_anon_rmap(struct page *, struct vm_area_struct *, unsigned long); void page_add_file_rmap(struct page *); -void page_dup_rmap(struct page *page, struct vm_area_struct *vma, unsigned long address); void page_remove_rmap(struct page *, struct vm_area_struct *); +#ifdef CONFIG_DEBUG_VM +void page_dup_rmap(struct page *page, struct vm_area_struct *vma, unsigned long address); +#else +static inline void page_dup_rmap(struct page *page, struct vm_area_struct *vma, unsigned long address) +{ + atomic_inc(&page->_mapcount); +} +#endif + /* * Called from mm/vmscan.c to handle paging out */ diff -puN mm/rmap.c~mm-more-rmap-checking-tidy mm/rmap.c --- a/mm/rmap.c~mm-more-rmap-checking-tidy +++ a/mm/rmap.c @@ -538,6 +538,7 @@ static void __page_set_anon_rmap(struct static void __page_check_anon_rmap(struct page *page, struct vm_area_struct *vma, unsigned long address) { +#ifdef CONFIG_DEBUG_VM /* * The page's anon-rmap details (mapping and index) are guaranteed to * be set up correctly at this point. @@ -554,6 +555,7 @@ static void __page_check_anon_rmap(struc anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON; BUG_ON(page->mapping != (struct address_space *)anon_vma); BUG_ON(page->index != linear_page_index(vma, address)); +#endif } /** @@ -567,8 +569,8 @@ static void __page_check_anon_rmap(struc void page_add_anon_rmap(struct page *page, struct vm_area_struct *vma, unsigned long address) { - BUG_ON(!PageLocked(page)); - BUG_ON(address < vma->vm_start || address >= vma->vm_end); + VM_BUG_ON(!PageLocked(page)); + VM_BUG_ON(address < vma->vm_start || address >= vma->vm_end); if (atomic_inc_and_test(&page->_mapcount)) __page_set_anon_rmap(page, vma, address); else @@ -605,6 +607,7 @@ void page_add_file_rmap(struct page *pag __inc_zone_page_state(page, NR_FILE_MAPPED); } +#ifdef CONFIG_DEBUG_VM /** * page_dup_rmap - duplicate pte mapping to a page * @page: the page to add the mapping to @@ -622,6 +625,7 @@ void page_dup_rmap(struct page *page, st __page_check_anon_rmap(page, vma, address); atomic_inc(&page->_mapcount); } +#endif /** * page_remove_rmap - take down pte mapping from a page _