* [PATCH 2/2] srcu: reduce scans of srcu_data in counter wrap check
@ 2018-01-31 19:42 Ildar Ismagilov
2018-02-03 9:18 ` Paul E. McKenney
0 siblings, 1 reply; 2+ messages in thread
From: Ildar Ismagilov @ 2018-01-31 19:42 UTC (permalink / raw)
Cc: devix84, Paul E. McKenney, Josh Triplett, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, linux-kernel
This patch reduce scans of srcu_data in case of a srcu_struct
tree have more than one levels
Signed-off-by: Ildar Ismagilov <devix84@gmail.com>
---
kernel/rcu/srcutree.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index c54617280245..2268381706d2 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -500,6 +500,7 @@ static void srcu_gp_end(struct srcu_struct *sp)
{
unsigned long cbdelay;
bool cbs;
+ bool last_lvl;
int cpu;
unsigned long flags;
unsigned long gpseq;
@@ -532,7 +533,8 @@ static void srcu_gp_end(struct srcu_struct *sp)
rcu_for_each_node_breadth_first(sp, snp) {
raw_spin_lock_irq_rcu_node(snp);
cbs = false;
- if (snp >= sp->level[rcu_num_lvls - 1])
+ last_lvl = snp >= sp->level[rcu_num_lvls - 1];
+ if (last_lvl)
cbs = snp->srcu_have_cbs[idx] == gpseq;
snp->srcu_have_cbs[idx] = gpseq;
rcu_seq_set_state(&snp->srcu_have_cbs[idx], 1);
@@ -545,7 +547,7 @@ static void srcu_gp_end(struct srcu_struct *sp)
srcu_schedule_cbs_snp(sp, snp, mask, cbdelay);
/* Occasionally prevent srcu_data counter wrap. */
- if (!(gpseq & counter_wrap_check))
+ if (!(gpseq & counter_wrap_check) && last_lvl)
for (cpu = snp->grplo; cpu <= snp->grphi; cpu++) {
sdp = per_cpu_ptr(sp->sda, cpu);
raw_spin_lock_irqsave_rcu_node(sdp, flags);
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/2] srcu: reduce scans of srcu_data in counter wrap check
2018-01-31 19:42 [PATCH 2/2] srcu: reduce scans of srcu_data in counter wrap check Ildar Ismagilov
@ 2018-02-03 9:18 ` Paul E. McKenney
0 siblings, 0 replies; 2+ messages in thread
From: Paul E. McKenney @ 2018-02-03 9:18 UTC (permalink / raw)
To: Ildar Ismagilov
Cc: Josh Triplett, Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan,
linux-kernel
On Wed, Jan 31, 2018 at 10:42:21PM +0300, Ildar Ismagilov wrote:
> This patch reduce scans of srcu_data in case of a srcu_struct
> tree have more than one levels
Good catch!!! Applied for testing and review.
I had to hand-apply this patch as well, and also fill out the commit log.
In addition, in the future, please capitalize the word in the Subject
line following the colon (":"). Please see below for the updated commit
and again please let me know if I messed something up.
Thanx, Paul
------------------------------------------------------------------------
commit bcec03ee2e43f2a24c61a99709d4dd1aa90438c2
Author: Ildar Ismagilov <devix84@gmail.com>
Date: Wed Jan 31 22:42:21 2018 +0300
srcu: Reduce scans of srcu_data in counter wrap check
Currently, given a multi-level srcu_node tree, SRCU can scan the full
set of srcu_data structures at each level when cleaning up after a grace
period. This, though harmless otherwise, represents pointless overhead.
This commit therefore eliminates this overhead by scanning the srcu_data
structures only when traversing the leaf srcu_node structures.
Signed-off-by: Ildar Ismagilov <devix84@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index ad3e1aa5e6ea..72dc6e39be14 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -527,6 +527,7 @@ static void srcu_gp_end(struct srcu_struct *sp)
{
unsigned long cbdelay;
bool cbs;
+ bool last_lvl;
int cpu;
unsigned long flags;
unsigned long gpseq;
@@ -559,7 +560,8 @@ static void srcu_gp_end(struct srcu_struct *sp)
rcu_for_each_node_breadth_first(sp, snp) {
spin_lock_irq_rcu_node(snp);
cbs = false;
- if (snp >= sp->level[rcu_num_lvls - 1])
+ last_lvl = snp >= sp->level[rcu_num_lvls - 1];
+ if (last_lvl)
cbs = snp->srcu_have_cbs[idx] == gpseq;
snp->srcu_have_cbs[idx] = gpseq;
rcu_seq_set_state(&snp->srcu_have_cbs[idx], 1);
@@ -572,7 +574,7 @@ static void srcu_gp_end(struct srcu_struct *sp)
srcu_schedule_cbs_snp(sp, snp, mask, cbdelay);
/* Occasionally prevent srcu_data counter wrap. */
- if (!(gpseq & counter_wrap_check))
+ if (!(gpseq & counter_wrap_check) && last_lvl)
for (cpu = snp->grplo; cpu <= snp->grphi; cpu++) {
sdp = per_cpu_ptr(sp->sda, cpu);
spin_lock_irqsave_rcu_node(sdp, flags);
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-03 20:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-31 19:42 [PATCH 2/2] srcu: reduce scans of srcu_data in counter wrap check Ildar Ismagilov
2018-02-03 9:18 ` Paul E. McKenney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).