Re: [patch 1/3] mmu_notifier: Core code

From: Robin Holt
Date: Thu Jan 31 2008 - 21:31:26 EST


Christoph,

Jack has repeatedly pointed out needing an unregister outside the
mmap_sem. I still don't see the benefit to not having the lock in the mm.

Thanks,
Robin

Index: mmu_notifiers-cl-v4/include/linux/mm_types.h
===================================================================
--- mmu_notifiers-cl-v4.orig/include/linux/mm_types.h 2008-01-31 19:56:08.000000000 -0600
+++ mmu_notifiers-cl-v4/include/linux/mm_types.h 2008-01-31 19:56:58.000000000 -0600
@@ -155,6 +155,7 @@ struct vm_area_struct {

struct mmu_notifier_head {
#ifdef CONFIG_MMU_NOTIFIER
+ spinlock_t list_lock;
struct hlist_head head;
#endif
};
Index: mmu_notifiers-cl-v4/mm/mmu_notifier.c
===================================================================
--- mmu_notifiers-cl-v4.orig/mm/mmu_notifier.c 2008-01-31 19:56:08.000000000 -0600
+++ mmu_notifiers-cl-v4/mm/mmu_notifier.c 2008-01-31 20:26:31.000000000 -0600
@@ -60,25 +60,19 @@ int mmu_notifier_age_page(struct mm_stru
* Note that all notifiers use RCU. The updates are only guaranteed to be
* visible to other processes after a RCU quiescent period!
*/
-void __mmu_notifier_register(struct mmu_notifier *mn, struct mm_struct *mm)
-{
- hlist_add_head_rcu(&mn->hlist, &mm->mmu_notifier.head);
-}
-EXPORT_SYMBOL_GPL(__mmu_notifier_register);
-
void mmu_notifier_register(struct mmu_notifier *mn, struct mm_struct *mm)
{
- down_write(&mm->mmap_sem);
- __mmu_notifier_register(mn, mm);
- up_write(&mm->mmap_sem);
+ spin_lock(&mm->mmu_notifier.list_lock);
+ hlist_add_head_rcu(&mn->hlist, &mm->mmu_notifier.head);
+ spin_unlock(&mm->mmu_notifier.list_lock);
}
EXPORT_SYMBOL_GPL(mmu_notifier_register);

void mmu_notifier_unregister(struct mmu_notifier *mn, struct mm_struct *mm)
{
- down_write(&mm->mmap_sem);
+ spin_lock(&mm->mmu_notifier.list_lock);
hlist_del_rcu(&mn->hlist);
- up_write(&mm->mmap_sem);
+ spin_unlock(&mm->mmu_notifier.list_lock);
}
EXPORT_SYMBOL_GPL(mmu_notifier_unregister);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/