login
Header Space

 
 

Re: [PATCH 01 of 11] mmu-notifier-core

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Jack Steiner <steiner@...>
Cc: Andrew Morton <akpm@...>, Christoph Lameter <clameter@...>, Robin Holt <holt@...>, Nick Piggin <npiggin@...>, Peter Zijlstra <a.p.zijlstra@...>, <kvm-devel@...>, Kanoj Sarcar <kanojsarcar@...>, Roland Dreier <rdreier@...>, Steve Wise <swise@...>, <linux-kernel@...>, Avi Kivity <avi@...>, <linux-mm@...>, <general@...>, Hugh Dickins <hugh@...>, Rusty Russell <rusty@...>, Anthony Liguori <aliguori@...>, Chris Wright <chrisw@...>, Marcelo Tosatti <marcelo@...>, Eric Dumazet <dada1@...>, Paul E. McKenney <paulmck@...>
Date: Monday, May 5, 2008 - 2:34 pm

On Mon, May 05, 2008 at 12:25:06PM -0500, Jack Steiner wrote:

No problem.


If you also like __mmu_notifier_register more I'll go with it. The
bitflags seems like a bit of overkill as I can't see the need of any
other bitflag other than this one and they also can't be removed as
easily in case you'll find a way to call it outside the lock later.


If you didn't implement it you shall apply this patch but you shall
read carefully the comment I written that covers that usage case.

diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h
--- a/include/linux/mmu_notifier.h
+++ b/include/linux/mmu_notifier.h
@@ -29,10 +29,25 @@ struct mmu_notifier_ops {
 	/*
 	 * Called either by mmu_notifier_unregister or when the mm is
 	 * being destroyed by exit_mmap, always before all pages are
-	 * freed. It's mandatory to implement this method. This can
-	 * run concurrently with other mmu notifier methods and it
+	 * freed. This can run concurrently with other mmu notifier
+	 * methods (the ones invoked outside the mm context) and it
 	 * should tear down all secondary mmu mappings and freeze the
-	 * secondary mmu.
+	 * secondary mmu. If this method isn't implemented you've to
+	 * be sure that nothing could possibly write to the pages
+	 * through the secondary mmu by the time the last thread with
+	 * tsk->mm == mm exits.
+	 *
+	 * As side note: the pages freed after ->release returns could
+	 * be immediately reallocated by the gart at an alias physical
+	 * address with a different cache model, so if ->release isn't
+	 * implemented because all memory accesses through the
+	 * secondary mmu implicitly are terminated by the time the
+	 * last thread of this mm quits, you've also to be sure that
+	 * speculative hardware operations can't allocate dirty
+	 * cachelines in the cpu that could not be snooped and made
+	 * coherent with the other read and write operations happening
+	 * through the gart alias address, leading to memory
+	 * corruption.
 	 */
 	void (*release)(struct mmu_notifier *mn,
 			struct mm_struct *mm);
diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c
--- a/mm/mmu_notifier.c
+++ b/mm/mmu_notifier.c
@@ -59,7 +59,8 @@ void __mmu_notifier_release(struct mm_st
 		 * from establishing any more sptes before all the
 		 * pages in the mm are freed.
 		 */
-		mn->ops->release(mn, mm);
+		if (mn->ops->release)
+			mn->ops->release(mn, mm);
 		srcu_read_unlock(&mm->mmu_notifier_mm->srcu, srcu);
 		spin_lock(&mm->mmu_notifier_mm->lock);
 	}
@@ -251,7 +252,8 @@ void mmu_notifier_unregister(struct mmu_
 		 * guarantee ->release is called before freeing the
 		 * pages.
 		 */
-		mn->ops->release(mn, mm);
+		if (mn->ops->release)
+			mn->ops->release(mn, mm);
 		srcu_read_unlock(&mm->mmu_notifier_mm->srcu, srcu);
 	} else
 		spin_unlock(&mm->mmu_notifier_mm->lock);
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00 of 11] mmu notifier #v15, Andrea Arcangeli, (Fri May 2, 11:05 am)
Re: [PATCH 00 of 11] mmu notifier #v15, Jack Steiner, (Sat May 3, 7:09 am)
[PATCH 11 of 11] mmap sems, Andrea Arcangeli, (Fri May 2, 11:05 am)
[PATCH 10 of 11] export zap_page_range for XPMEM, Andrea Arcangeli, (Fri May 2, 11:05 am)
[PATCH 09 of 11] mm_lock-rwsem, Andrea Arcangeli, (Fri May 2, 11:05 am)
[PATCH 08 of 11] anon-vma-rwsem, Andrea Arcangeli, (Fri May 2, 11:05 am)
[PATCH 07 of 11] i_mmap_rwsem, Andrea Arcangeli, (Fri May 2, 11:05 am)
[PATCH 06 of 11] rwsem contended, Andrea Arcangeli, (Fri May 2, 11:05 am)
[PATCH 05 of 11] unmap vmas tlb flushing, Andrea Arcangeli, (Fri May 2, 11:05 am)
[PATCH 04 of 11] free-pgtables, Andrea Arcangeli, (Fri May 2, 11:05 am)
[PATCH 03 of 11] invalidate_page outside PT lock, Andrea Arcangeli, (Fri May 2, 11:05 am)
[PATCH 02 of 11] get_task_mm, Andrea Arcangeli, (Fri May 2, 11:05 am)
[PATCH 01 of 11] mmu-notifier-core, Andrea Arcangeli, (Fri May 2, 11:05 am)
Re: [PATCH 01 of 11] mmu-notifier-core, Jack Steiner, (Mon May 5, 12:21 pm)
Re: [PATCH 01 of 11] mmu-notifier-core, Andrea Arcangeli, (Mon May 5, 1:14 pm)
Re: [PATCH 01 of 11] mmu-notifier-core, Jack Steiner, (Mon May 5, 1:25 pm)
Re: [PATCH 01 of 11] mmu-notifier-core, Andrea Arcangeli, (Mon May 5, 2:34 pm)
Re: [PATCH 01 of 11] mmu-notifier-core, Jack Steiner, (Mon May 5, 3:46 pm)
mmu notifier v15 -&gt; v16 diff, Andrea Arcangeli, (Tue May 6, 1:53 pm)
Re: [PATCH 01 of 11] mmu-notifier-core, Andrea Arcangeli, (Tue May 6, 10:46 am)
Re: [PATCH 01 of 11] mmu-notifier-core, Robin Holt, (Sun May 4, 3:13 pm)
Re: [PATCH 01 of 11] mmu-notifier-core, Andrea Arcangeli, (Sun May 4, 6:08 pm)
Re: [PATCH 01 of 11] mmu-notifier-core, Robin Holt, (Sun May 4, 10:25 pm)
speck-geostationary