Skip to contentSkip to conversation

remove mmu notifier calls in apply_to_page_range

PATCH In review Jeremy Fitzhardinge 2 participants 2 messages Jul 9, 2010 – Jul 12, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remove mmu notifier calls in apply_to_page_range

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.

mm/memory.c +1 -2
index 6ab19dd..d6b89eb 100644
@@ -1890,7 +1890,6 @@ int apply_to_page_range(struct mm_struct *mm, unsigned long addr,
 	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);
@@ -1898,7 +1897,7 @@ int apply_to_page_range(struct mm_struct *mm, unsigned long addr,
 		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);
#1 lore raw
Quoted 19 lines · Jeremy Fitzhardinge
mm/memory.c +0 -1
index 6ab19dd..d6b89eb 100644
@@ -1890,7 +1890,6 @@ int apply_to_page_range(struct mm_struct *mm, unsigned long addr,
 	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);

mm/memory.c int apply_to_page_range(struct mm_struct *mm, unsigned long addr, · line 1903

Quoted 8 lines
mm/memory.c +1 -1
@@ -1898,7 +1897,7 @@ int apply_to_page_range(struct mm_struct *mm, unsigned long addr,
 		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);

The local variable start in apply_to_page_range is not used anymore:
remove it.

---

mm/memory.c +1 -1
index 9d33bfe..0a47927 100644
@@ -1989,7 +1989,7 @@ 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);