mm/mmu_notifier: rename mmu_notifier_synchronize() to <...>_barrier()
Subsystems (2)
PATCH 1/1 mm/mmu_notifier: rename mmu_notifier_synchronize() to <...>_barrier()
...and update its comment to explicitly reference its association with mmu_notifier_call_srcu().
Contrary to its name, mmu_notifier_synchronize() does not synchronize the notifier's SRCU instance, but rather waits for RCU callbacks to finished, i.e. it invokes rcu_barrier(). The RCU documentation is quite clear on this matter, explicitly calling out that rcu_barrier() does not imply synchronize_rcu(). The misnomer could lean an unwary developer to incorrectly assume that mmu_notifier_synchronize() can be used in conjunction with mmu_notifier_unregister_no_release() to implement a variation of mmu_notifier_unregister() that synchronizes SRCU without invoking ->release. A Documentation-allergic and hasty developer could be further confused by the fact that rcu_barrier() is indeed a pass-through to synchronize_rcu()... in tiny SRCU.
--- mm/mmu_notifier.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/mmu_notifier.c +3 -3
@@ -35,12 +35,12 @@ void mmu_notifier_call_srcu(struct rcu_head *rcu, }EXPORT_SYMBOL_GPL (mmu_notifier_call_srcu); -void mmu_notifier_synchronize (void ) +void mmu_notifier_barrier (void ) { -/* Wait for any running method to finish. */ +/* Wait for any running RCU callbacks (see above) to finish. */ srcu_barrier (&srcu); } -EXPORT_SYMBOL_GPL (mmu_notifier_synchronize); +EXPORT_SYMBOL_GPL (mmu_notifier_barrier);/* * This function can't run concurrently against mmu_notifier_register
Signature · 1 line
2.19.1
Andrew Morton
maintainerQuoted 14 lines · On Mon, 5 Nov 2018 11:29:55 -0800 Sean Christopherson…
...and update its comment to explicitly reference its association with
mmu_notifier_call_srcu().Contrary to its name,
mmu_notifier_synchronize()does not synchronize the notifier's SRCU instance, but rather waits for RCU callbacks to finished, i.e. it invokesrcu_barrier(). The RCU documentation is quite clear on this matter, explicitly calling out thatrcu_barrier()does not implysynchronize_rcu(). The misnomer could lean an unwary developer to incorrectly assume thatmmu_notifier_synchronize()can be used in conjunction withmmu_notifier_unregister_no_release()to implement a variation ofmmu_notifier_unregister()that synchronizes SRCU without invoking ->release. A Documentation-allergic and hasty developer could be further confused by the fact thatrcu_barrier()is indeed a pass-through tosynchronize_rcu()... in tiny SRCU.
Fair enough.
Quoted 8 lines
mm/mmu_notifier.c +1
-1@@ -35,12 +35,12 @@ void mmu_notifier_call_srcu(struct rcu_head *rcu, }EXPORT_SYMBOL_GPL (mmu_notifier_call_srcu); -void mmu_notifier_synchronize (void ) +void mmu_notifier_barrier (void )
mm/mmu_notifier.c void mmu_notifier_call_srcu(struct rcu_head *rcu, · line 46
Quoted 10 lines
mm/mmu_notifier.c +2
-2{ -/* Wait for any running method to finish. */ +/* Wait for any running RCU callbacks (see above) to finish. */ srcu_barrier (&srcu); } -EXPORT_SYMBOL_GPL (mmu_notifier_synchronize); +EXPORT_SYMBOL_GPL (mmu_notifier_barrier);/* * This function can't run concurrently against mmu_notifier_register
But as it has no callers, why retain it?
Quoted 35 lines · Andrew Morton
Quoted 14 lines · On Mon, 5 Nov 2018 11:29:55 -0800 Sean Christopherson…
...and update its comment to explicitly reference its association with
mmu_notifier_call_srcu().Contrary to its name,
mmu_notifier_synchronize()does not synchronize the notifier's SRCU instance, but rather waits for RCU callbacks to finished, i.e. it invokesrcu_barrier(). The RCU documentation is quite clear on this matter, explicitly calling out thatrcu_barrier()does not implysynchronize_rcu(). The misnomer could lean an unwary developer to incorrectly assume thatmmu_notifier_synchronize()can be used in conjunction withmmu_notifier_unregister_no_release()to implement a variation ofmmu_notifier_unregister()that synchronizes SRCU without invoking ->release. A Documentation-allergic and hasty developer could be further confused by the fact thatrcu_barrier()is indeed a pass-through tosynchronize_rcu()... in tiny SRCU.Fair enough.
Quoted 16 lines
mm/mmu_notifier.c +3
-3@@ -35,12 +35,12 @@ void mmu_notifier_call_srcu(struct rcu_head *rcu, }EXPORT_SYMBOL_GPL (mmu_notifier_call_srcu); -void mmu_notifier_synchronize (void ) +void mmu_notifier_barrier (void ) { -/* Wait for any running method to finish. */ +/* Wait for any running RCU callbacks (see above) to finish. */ srcu_barrier (&srcu); } -EXPORT_SYMBOL_GPL (mmu_notifier_synchronize); +EXPORT_SYMBOL_GPL (mmu_notifier_barrier);
Quoted 4 lines
mm/mmu_notifier.c void mmu_notifier_call_srcu(struct rcu_head *rcu, · line 46
Quoted 2 lines
mm/mmu_notifier.c +0
-0/* * This function can't run concurrently against mmu_notifier_register But as it has no callers, why retain it?
I was hesitant to remove it altogether since it was explicitly added to complement mmu_notifier_call_srcu()[1] even though the initial user of mmu_notifier_call_srcu() didn't use mmu_notifier_synchronize()[2]. I assume there was a good reason for adding the barrier function, but maybe that's a bad assumption.
[1] b972216e27d1 ("mmu_notifier: add call_srcu and sync function for listener to delay call and sync")
[2] https://lore.kernel.org/patchwork/patch/515318/
Quoted 3 lines · Andrew Morton
Quoted 1 line
+++
b/mm/mmu_notifier.cBut as it has no callers, why retain it?
... and this patch missed the declaration of mmu_notifier_synchronize in include/linux/mmu_notifier.h (whether we delete it or rename it, that mention of it needs to be fixed)
Quoted 1 line · Andrew Morton
On Mon, 5 Nov 2018 11:29:55 -0800 Sean Christopherson <[email protected]> wrote:
[...]
Quoted 7 lines
mm/mmu_notifier.c void mmu_notifier_call_srcu(struct rcu_head *rcu, · line 46
Quoted 5 lines
mm/mmu_notifier.c +1
-1-EXPORT_SYMBOL_GPL (mmu_notifier_synchronize); +EXPORT_SYMBOL_GPL (mmu_notifier_barrier);/* * This function can't run concurrently against mmu_notifier_register But as it has no callers, why retain it?
Exported symbols are not freed and if this is not used by any in-kernel code then I would just remove it.
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 8 lines · Matthew Wilcox
Quoted 4 lines · Andrew Morton
Quoted 3 lines
+++
b/mm/mmu_notifier.cBut as it has no callers, why retain it?
... and this patch missed the declaration of
mmu_notifier_synchronizeininclude/linux/mmu_notifier.h(whether we delete it or rename it, that mention of it needs to be fixed)
Doh. A I'll remove the function and send v2.