srcu/tiny: Remove preempt_disable/enable() in srcu_gp_start_if_needed()
Subsystems (2)
Zqiang
reviewerPATCH v2 1/1 srcu/tiny: Remove preempt_disable/enable() in srcu_gp_start_if_needed()
Currently, the srcu_gp_start_if_needed() is always be invoked in preempt disable's critical section, this commit therefore remove redundant preempt_disable/enable() in srcu_gp_start_if_needed() and adds a call to lockdep_assert_preemption_disabled() in order to enable lockdep to diagnose mistaken invocations of this function from preempts-enabled code.
--- kernel/rcu/srcutiny.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
kernel/rcu/srcutiny.c +1 -3
@@ -181,10 +181,9 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp) {unsigned long cookie; -preempt_disable ();// Needed for PREEMPT_LAZY +lockdep_assert_preemption_disabled (); cookie =get_state_synchronize_srcu (ssp);if (ULONG_CMP_GE (READ_ONCE (ssp->srcu_idx_max), cookie)) { -preempt_enable ();return ; }WRITE_ONCE (ssp->srcu_idx_max, cookie);
@@ -194,7 +193,6 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp)else if (list_empty (&ssp->srcu_work.entry))list_add (&ssp->srcu_work.entry, &srcu_boot_list); } -preempt_enable (); }/*
Signature · 1 line
2.48.1
Paul E. McKenney
maintainerQuoted 9 lines · Zqiang
Currently, the
srcu_gp_start_if_needed()is always be invoked in preempt disable's critical section, this commit therefore remove redundant preempt_disable/enable() insrcu_gp_start_if_needed()and adds a call tolockdep_assert_preemption_disabled()in order to enable lockdep to diagnose mistaken invocations of this function from preempts-enabled code.Fixes 65b4a59557f6 ("srcu: Make Tiny SRCU explicitly disable preemption")Signed-off-by Zqiang <[email protected]>
Very good, applied for testing and further review, thank you!
Thanx, Paul
Quoted 31 lines
--- kernel/rcu/srcutiny.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)kernel/rcu/srcutiny.c +1
-3@@ -181,10 +181,9 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp) {unsigned long cookie; -preempt_disable ();// Needed for PREEMPT_LAZY +lockdep_assert_preemption_disabled (); cookie =get_state_synchronize_srcu (ssp);if (ULONG_CMP_GE (READ_ONCE (ssp->srcu_idx_max), cookie)) { -preempt_enable ();return ; }WRITE_ONCE (ssp->srcu_idx_max, cookie);@@ -194,7 +193,6 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp)else if (list_empty (&ssp->srcu_work.entry))list_add (&ssp->srcu_work.entry, &srcu_boot_list); } -preempt_enable (); }/* Signature · 1 line
2.48.1
Joel Fernandes
maintainer[..]
Quoted 11 lines
Quoted 11 lines
kernel/rcu/srcutiny.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)kernel/rcu/srcutiny.c +0
-0@@ -181,10 +181,9 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp) {unsigned long cookie;
Quoted 2 lines
kernel/rcu/srcutiny.c static void srcu_gp_start_if_needed(struct srcu_struct *ssp) · line 184
Quoted 2 lines
kernel/rcu/srcutiny.c +1
-1-preempt_disable ();// Needed for PREEMPT_LAZY +lockdep_assert_preemption_disabled ();
nit: Do we still want to keep the comment that the expectation of preemption being disabled is for the LAZY case?
thanks,
- Joel
Quoted 17 lines
Quoted 17 lines
kernel/rcu/srcutiny.c +0
-2cookie =get_state_synchronize_srcu (ssp);if (ULONG_CMP_GE (READ_ONCE (ssp->srcu_idx_max), cookie)) { -preempt_enable ();return ; }WRITE_ONCE (ssp->srcu_idx_max, cookie);@@ -194,7 +193,6 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp)else if (list_empty (&ssp->srcu_work.entry))list_add (&ssp->srcu_work.entry, &srcu_boot_list); } -preempt_enable (); }/* Signature · 1 line
2.48.1
Paul E. McKenney
maintainerQuoted 12 lines · Joel Fernandes
[..]
Quoted 11 lines
Quoted 11 lines
kernel/rcu/srcutiny.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)kernel/rcu/srcutiny.c +0
-0@@ -181,10 +181,9 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp) {unsigned long cookie;
Quoted 5 lines
Quoted 2 lines
kernel/rcu/srcutiny.c static void srcu_gp_start_if_needed(struct srcu_struct *ssp) · line 184
Quoted 2 lines
kernel/rcu/srcutiny.c +1
-1-preempt_disable ();// Needed for PREEMPT_LAZY +lockdep_assert_preemption_disabled ();nit: Do we still want to keep the comment that the expectation of preemption being disabled is for the LAZY case?
Good point, and I do believe that we do. Zqiang, any reason not to add this comment back in?
Thanx, Paul
Quoted 22 lines
thanks,
- Joel
Quoted 17 lines
Quoted 17 lines
kernel/rcu/srcutiny.c +0
-2cookie =get_state_synchronize_srcu (ssp);if (ULONG_CMP_GE (READ_ONCE (ssp->srcu_idx_max), cookie)) { -preempt_enable ();return ; }WRITE_ONCE (ssp->srcu_idx_max, cookie);@@ -194,7 +193,6 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp)else if (list_empty (&ssp->srcu_work.entry))list_add (&ssp->srcu_work.entry, &srcu_boot_list); } -preempt_enable (); }/* Signature · 1 line
2.48.1
Zqiang
reviewerQuoted 16 lines · Joel Fernandes
Quoted 14 lines
[..]
Quoted 11 lines
kernel/rcu/srcutiny.c| 4 +---1 file changed, 1 insertion(+), 3 deletions(-)kernel/rcu/srcutiny.c +0
-0@@ -181,10 +181,9 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp) {unsigned long cookie;
Quoted 8 lines
Quoted 6 lines
kernel/rcu/srcutiny.c static void srcu_gp_start_if_needed(struct srcu_struct *ssp) · line 184
Quoted 2 lines
kernel/rcu/srcutiny.c +1
-1-preempt_disable ();// Needed for PREEMPT_LAZY +lockdep_assert_preemption_disabled ();nit: Do we still want to keep the comment that the expectation of preemption being disabled is for the LAZY case?
Good point, and I do believe that we do. Zqiang, any reason not to add this comment back in?
in rcu-tree, this commit:
(935147775c977 "EXP srcu: Enable Tiny SRCU On all CONFIG_SMP=n kernels")
make preempt disable needed for CONFIG_PREEMPT=y or CONFIG_PREEMPT_LAZY=y when the CONFIG_SMP=n. do we need to replace "Needed for PREEMPT_LAZY" comments with "Needed for PREEMPT or PREEMPT_LAZY"?
Thanks
Zqiang
Quoted 28 lines
Thanx, Paul
Quoted 24 lines
thanks,
- Joel
Quoted 17 lines
kernel/rcu/srcutiny.c +0
-2cookie =get_state_synchronize_srcu (ssp);if (ULONG_CMP_GE (READ_ONCE (ssp->srcu_idx_max), cookie)) { -preempt_enable ();return ; }WRITE_ONCE (ssp->srcu_idx_max, cookie);@@ -194,7 +193,6 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp)else if (list_empty (&ssp->srcu_work.entry))list_add (&ssp->srcu_work.entry, &srcu_boot_list); } -preempt_enable (); }/* Signature · 1 line
2.48.1
Paul E. McKenney
maintainerQuoted 25 lines · Zqiang
Quoted 16 lines · Joel Fernandes
Quoted 14 lines
[..]
Quoted 11 lines
kernel/rcu/srcutiny.c| 4 +---1 file changed, 1 insertion(+), 3 deletions(-)kernel/rcu/srcutiny.c +0
-0@@ -181,10 +181,9 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp) {unsigned long cookie;Quoted 8 lines
Quoted 6 lines
kernel/rcu/srcutiny.c static void srcu_gp_start_if_needed(struct srcu_struct *ssp) · line 184
Quoted 2 lines
kernel/rcu/srcutiny.c +1
-1-preempt_disable ();// Needed for PREEMPT_LAZY +lockdep_assert_preemption_disabled ();nit: Do we still want to keep the comment that the expectation of preemption being disabled is for the LAZY case?
Good point, and I do believe that we do. Zqiang, any reason not to add this comment back in?
Quoted 7 lines
in rcu-tree, this commit:
(
935147775c977"EXP srcu: Enable Tiny SRCU On allCONFIG_SMP=nkernels")make preempt disable needed for
CONFIG_PREEMPT=yorCONFIG_PREEMPT_LAZY=ywhen theCONFIG_SMP=n. do we need to replace "Needed forPREEMPT_LAZY" comments with "Needed for PREEMPT orPREEMPT_LAZY"?
Good point as well, thank you! And I need to decide whether I should send that patch upstream. Its original purpose was to test PREEMPT_LAZY=y better than could be tested with PREEMPT_LAZY.
Thoughts?
Thanx, Paul
Quoted 32 lines
Thanks
ZqiangQuoted 28 lines
Thanx, Paul
Quoted 24 lines
thanks,
- Joel
Quoted 17 lines
kernel/rcu/srcutiny.c +0
-2cookie =get_state_synchronize_srcu (ssp);if (ULONG_CMP_GE (READ_ONCE (ssp->srcu_idx_max), cookie)) { -preempt_enable ();return ; }WRITE_ONCE (ssp->srcu_idx_max, cookie);@@ -194,7 +193,6 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp)else if (list_empty (&ssp->srcu_work.entry))list_add (&ssp->srcu_work.entry, &srcu_boot_list); } -preempt_enable (); }/* Signature · 1 line
2.48.1
Zqiang
reviewerQuoted 36 lines · Zqiang
Quoted 26 lines · Joel Fernandes
Quoted 14 lines
[..]
Quoted 11 lines
kernel/rcu/srcutiny.c| 4 +---1 file changed, 1 insertion(+), 3 deletions(-)kernel/rcu/srcutiny.c +0
-0@@ -181,10 +181,9 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp) {unsigned long cookie;Quoted 6 lines
kernel/rcu/srcutiny.c static void srcu_gp_start_if_needed(struct srcu_struct *ssp) · line 184
Quoted 2 lines
kernel/rcu/srcutiny.c +1
-1-preempt_disable ();// Needed for PREEMPT_LAZY +lockdep_assert_preemption_disabled ();nit: Do we still want to keep the comment that the expectation of preemption being disabled is for the LAZY case?
Good point, and I do believe that we do. Zqiang, any reason not to add this comment back in?
Quoted 8 lines
in rcu-tree, this commit:
(
935147775c977"EXP srcu: Enable Tiny SRCU On allCONFIG_SMP=nkernels")make preempt disable needed for
CONFIG_PREEMPT=yorCONFIG_PREEMPT_LAZY=ywhen theCONFIG_SMP=n. do we need to replace "Needed forPREEMPT_LAZY" comments with "Needed for PREEMPT orPREEMPT_LAZY"?
Quoted 5 lines
Good point as well, thank you! And I need to decide whether I should send that patch upstream. Its original purpose was to test PREEMPT_LAZY=y better than could be tested with
PREEMPT_LAZY.Thoughts?
I will add "Needed for PREEMPT_LAZY" comments, if this commit (935147775c977) is send to upstream, will update comments again in the future.
Thanks
Zqiang
Quoted 37 lines
Thanx, Paul
Quoted 33 lines
Thanks
ZqiangThanx, Paul
Quoted 24 lines
thanks,
- Joel
Quoted 17 lines
kernel/rcu/srcutiny.c +0
-2cookie =get_state_synchronize_srcu (ssp);if (ULONG_CMP_GE (READ_ONCE (ssp->srcu_idx_max), cookie)) { -preempt_enable ();return ; }WRITE_ONCE (ssp->srcu_idx_max, cookie);@@ -194,7 +193,6 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp)else if (list_empty (&ssp->srcu_work.entry))list_add (&ssp->srcu_work.entry, &srcu_boot_list); } -preempt_enable (); }/* Signature · 1 line
2.48.1
Paul E. McKenney
maintainerQuoted 36 lines · Zqiang
Quoted 36 lines · Zqiang
Quoted 34 lines · Joel Fernandes
Quoted 14 lines
[..]
Quoted 11 lines
kernel/rcu/srcutiny.c| 4 +---1 file changed, 1 insertion(+), 3 deletions(-)kernel/rcu/srcutiny.c +0
-0@@ -181,10 +181,9 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp) {unsigned long cookie;Quoted 6 lines
kernel/rcu/srcutiny.c static void srcu_gp_start_if_needed(struct srcu_struct *ssp) · line 184
Quoted 2 lines
kernel/rcu/srcutiny.c +1
-1-preempt_disable ();// Needed for PREEMPT_LAZY +lockdep_assert_preemption_disabled ();nit: Do we still want to keep the comment that the expectation of preemption being disabled is for the LAZY case?
Good point, and I do believe that we do. Zqiang, any reason not to add this comment back in?
in rcu-tree, this commit:
(
935147775c977"EXP srcu: Enable Tiny SRCU On allCONFIG_SMP=nkernels")make preempt disable needed for
CONFIG_PREEMPT=yorCONFIG_PREEMPT_LAZY=ywhen theCONFIG_SMP=n. do we need to replace "Needed forPREEMPT_LAZY" comments with "Needed for PREEMPT orPREEMPT_LAZY"?
Quoted 8 lines
Quoted 5 lines
Good point as well, thank you! And I need to decide whether I should send that patch upstream. Its original purpose was to test PREEMPT_LAZY=y better than could be tested with
PREEMPT_LAZY.Thoughts?
I will add "Needed for
PREEMPT_LAZY" comments, if this commit (935147775c977) is send to upstream, will update comments again in the future.
That sounds good to me, thank you!
Thanx, Paul
Quoted 40 lines
Thanks
ZqiangQuoted 37 lines
Thanx, Paul
Quoted 33 lines
Thanks
ZqiangThanx, Paul
Quoted 24 lines
thanks,
- Joel
Quoted 17 lines
kernel/rcu/srcutiny.c +0
-2cookie =get_state_synchronize_srcu (ssp);if (ULONG_CMP_GE (READ_ONCE (ssp->srcu_idx_max), cookie)) { -preempt_enable ();return ; }WRITE_ONCE (ssp->srcu_idx_max, cookie);@@ -194,7 +193,6 @@ static void srcu_gp_start_if_needed(struct srcu_struct *ssp)else if (list_empty (&ssp->srcu_work.entry))list_add (&ssp->srcu_work.entry, &srcu_boot_list); } -preempt_enable (); }/* Signature · 1 line
2.48.1