Skip to content

Commit

Permalink
mmu-notifiers: remove mmu notifier calls in apply_to_page_range()
Browse files Browse the repository at this point in the history
It is not appropriate for apply_to_page_range() to directly call any mmu
notifiers, because it is a general purpose function whose effect depends
on what context it is called in and what the callback function does.

In particular, if it is being used as part of an mmu notifier
implementation, the recursive calls can be particularly problematic.

It is up to apply_to_page_range's caller to do any notifier calls if
necessary.  It does not affect any in-tree users because they all operate
on init_mm, and mmu notifiers only pertain to usermode mappings.

[stefano.stabellini@eu.citrix.com: remove unused local `start']
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Avi Kivity <avi@qumranet.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Jeremy Fitzhardinge authored and Linus Torvalds committed Aug 10, 2010
1 parent 58c37f6 commit 57250a5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -2006,19 +2006,18 @@ int apply_to_page_range(struct mm_struct *mm, unsigned long addr,
{
pgd_t *pgd;
unsigned long next;
unsigned long start = addr, end = addr + size;
unsigned long end = addr + size;
int err;

BUG_ON(addr >= end);
mmu_notifier_invalidate_range_start(mm, start, end);
pgd = pgd_offset(mm, addr);
do {
next = pgd_addr_end(addr, end);
err = apply_to_pud_range(mm, pgd, addr, next, fn, data);
if (err)
break;
} while (pgd++, addr = next, addr != end);
mmu_notifier_invalidate_range_end(mm, start, end);

return err;
}
EXPORT_SYMBOL_GPL(apply_to_page_range);
Expand Down

0 comments on commit 57250a5

Please sign in to comment.