rcu-tasks: Remove unnecessary lazy_jiffies in call_rcu_tasks_generic_timer()
PATCH 1/1 rcu-tasks: Remove unnecessary lazy_jiffies in call_rcu_tasks_generic_timer()
The rcu_tasks_percpu structure's->lazy_timer is queued only when the rcu_tasks structure's->lazy_jiffies is not equal to zero in call_rcu_tasks_generic(), if the lazy_timer callback is invoked, that means the lazy_jiffes is not equal to zero, this commit therefore remove lazy_jiffies check in call_rcu_tasks_generic_timer().
--- kernel/rcu/tasks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tasks.h +1 -1
@@ -299,7 +299,7 @@ static void call_rcu_tasks_generic_timer(struct timer_list *tlp) rtp = rtpcp->rtpp;raw_spin_lock_irqsave_rcu_node (rtpcp, flags); -if (!rcu_segcblist_empty (&rtpcp->cblist) && rtp->lazy_jiffies) { +if (!rcu_segcblist_empty (&rtpcp->cblist)) {if (!rtpcp->urgent_gp) rtpcp->urgent_gp =1 ; needwake = true;
Signature · 1 line
2.17.1
Paul E. McKenney
maintainerQuoted 16 lines · Zqiang
The
rcu_tasks_percpustructure's->lazy_timer is queued only when thercu_tasksstructure's->lazy_jiffies is not equal to zero incall_rcu_tasks_generic(), if thelazy_timercallback is invoked, that means thelazy_jiffesis not equal to zero, this commit therefore removelazy_jiffiescheck incall_rcu_tasks_generic_timer().Signed-off-by Zqiang <[email protected]>--- kernel/rcu/tasks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/tasks.h +0
-0
kernel/rcu/tasks.h static void call_rcu_tasks_generic_timer(struct timer_list *tlp) · line 302
Quoted 5 lines
kernel/rcu/tasks.h +1
-1@@ -299,7 +299,7 @@ static void call_rcu_tasks_generic_timer(struct timer_list *tlp) rtp = rtpcp->rtpp;raw_spin_lock_irqsave_rcu_node (rtpcp, flags); -if (!rcu_segcblist_empty (&rtpcp->cblist) && rtp->lazy_jiffies) { +if (!rcu_segcblist_empty (&rtpcp->cblist)) {
Good eyes!
But did you test with something like a WARN_ON_ONCE(rtp->lazy_jiffies)?
Thanx, Paul
Quoted 6 lines
kernel/rcu/tasks.h +0
-0if (!rtpcp->urgent_gp) rtpcp->urgent_gp =1 ; needwake = true;Signature · 1 line
2.17.1
Quoted 19 lines · Zqiang
Quoted 17 lines
The
rcu_tasks_percpustructure's->lazy_timer is queued only when thercu_tasksstructure's->lazy_jiffies is not equal to zero incall_rcu_tasks_generic(), if thelazy_timercallback is invoked, that means thelazy_jiffesis not equal to zero, this commit therefore removelazy_jiffiescheck incall_rcu_tasks_generic_timer().Signed-off-by Zqiang <[email protected]>--- kernel/rcu/tasks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/tasks.h +0
-0@@ -299,7 +299,7 @@ static void call_rcu_tasks_generic_timer(struct timer_list *tlp)
Quoted 8 lines
kernel/rcu/tasks.h static void call_rcu_tasks_generic_timer(struct timer_list *tlp) · line 302
Quoted 4 lines
kernel/rcu/tasks.h +1
-1rtp = rtpcp->rtpp;raw_spin_lock_irqsave_rcu_node (rtpcp, flags); -if (!rcu_segcblist_empty (&rtpcp->cblist) && rtp->lazy_jiffies) { +if (!rcu_segcblist_empty (&rtpcp->cblist)) {Good eyes!
But did you test with something like a
WARN_ON_ONCE(rtp->lazy_jiffies)?
Hi, Paul
+ if (!rcu_segcblist_empty(&rtpcp->cblist) &&
!WARN_ON_ONCE(!rtp->lazy_jiffies))
I've done tests like this:
1. runqemu nographic kvm slirp qemuparams="-smp 4 -m 2048M -drive file=$PWD/share.img,if=virtio" bootparams="rcupdate.rcu_tasks_trace_lazy_ms=0" -d
2. insmod torture.ko
insmod rcutorture.ko torture_type=tasks-tracing fwd_progress=4
3. bpftrace -e 't:timer:timer_expire_entry /args->function == kaddr("call_rcu_tasks_generic_timer")/
{printf("comm:%s,cpu:%d,stack:%s,func:%s\n", comm, cpu, kstack, ksym(args->function)); }'
The call_rcu_tasks_generic_timer() has never been executed.
Thanks
Zqiang
Quoted 9 lines
Thanx, Paul
Quoted 6 lines
kernel/rcu/tasks.h +0
-1if (!rtpcp->urgent_gp) rtpcp->urgent_gp =1 ; needwake = true; --2.17.1
Paul E. McKenney
maintainerQuoted 42 lines · Z qiang
Quoted 19 lines · Zqiang
Quoted 17 lines
The
rcu_tasks_percpustructure's->lazy_timer is queued only when thercu_tasksstructure's->lazy_jiffies is not equal to zero incall_rcu_tasks_generic(), if thelazy_timercallback is invoked, that means thelazy_jiffesis not equal to zero, this commit therefore removelazy_jiffiescheck incall_rcu_tasks_generic_timer().Signed-off-by Zqiang <[email protected]>--- kernel/rcu/tasks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/tasks.h +0
-0@@ -299,7 +299,7 @@ static void call_rcu_tasks_generic_timer(struct timer_list *tlp)Quoted 8 lines
kernel/rcu/tasks.h static void call_rcu_tasks_generic_timer(struct timer_list *tlp) · line 302
Quoted 4 lines
kernel/rcu/tasks.h +1
-1rtp = rtpcp->rtpp;raw_spin_lock_irqsave_rcu_node (rtpcp, flags); -if (!rcu_segcblist_empty (&rtpcp->cblist) && rtp->lazy_jiffies) { +if (!rcu_segcblist_empty (&rtpcp->cblist)) {Good eyes!
But did you test with something like a
WARN_ON_ONCE(rtp->lazy_jiffies)?Hi, Paul
+ if (!rcu_segcblist_empty(&rtpcp->cblist) &&
!WARN_ON_ONCE(!rtp->lazy_jiffies))I've done tests like this:
1. runqemu nographic kvm slirp qemuparams="-smp 4 -m 2048M -drive file=$PWD/share.img,if=virtio" bootparams="rcupdate.rcu_tasks_trace_lazy_ms=0" -d
2. insmod torture.ko
insmod rcutorture.ko torture_type=tasks-tracing fwd_progress=4
Quoted 7 lines
3. bpftrace -e 't:timer:timer_expire_entry /args->function == kaddr("call_rcu_tasks_generic_timer")/
{
printf("comm:%s,cpu:%d,stack:%s,func:%s\n", comm, cpu, kstack, ksym(args->function)); }'The
call_rcu_tasks_generic_timer()has never been executed.
Very good!
Then if we get a couple of acks or reviews from the others acknowledging that if they ever make ->lazy_jiffies be changeable at runtime, they will remember to do something to adjust this logic appropriately, I will take it. ;-)
Thanx, Paul
Quoted 13 lines
Thanks
ZqiangQuoted 9 lines
Thanx, Paul
Quoted 6 lines
kernel/rcu/tasks.h +0
-1if (!rtpcp->urgent_gp) rtpcp->urgent_gp =1 ; needwake = true; --2.17.1
Quoted 50 lines · Z qiang
Quoted 48 lines
Quoted 19 lines · Zqiang
Quoted 17 lines
The
rcu_tasks_percpustructure's->lazy_timer is queued only when thercu_tasksstructure's->lazy_jiffies is not equal to zero incall_rcu_tasks_generic(), if thelazy_timercallback is invoked, that means thelazy_jiffesis not equal to zero, this commit therefore removelazy_jiffiescheck incall_rcu_tasks_generic_timer().Signed-off-by Zqiang <[email protected]>--- kernel/rcu/tasks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/tasks.h +0
-0@@ -299,7 +299,7 @@ static void call_rcu_tasks_generic_timer(struct timer_list *tlp)Quoted 8 lines
kernel/rcu/tasks.h static void call_rcu_tasks_generic_timer(struct timer_list *tlp) · line 302
Quoted 4 lines
kernel/rcu/tasks.h +1
-1rtp = rtpcp->rtpp;raw_spin_lock_irqsave_rcu_node (rtpcp, flags); -if (!rcu_segcblist_empty (&rtpcp->cblist) && rtp->lazy_jiffies) { +if (!rcu_segcblist_empty (&rtpcp->cblist)) {Good eyes!
But did you test with something like a
WARN_ON_ONCE(rtp->lazy_jiffies)?Hi, Paul
+ if (!rcu_segcblist_empty(&rtpcp->cblist) &&
!WARN_ON_ONCE(!rtp->lazy_jiffies))I've done tests like this:
1. runqemu nographic kvm slirp qemuparams="-smp 4 -m 2048M -drive file=$PWD/share.img,if=virtio" bootparams="rcupdate.rcu_tasks_trace_lazy_ms=0" -d
2. insmod torture.ko
insmod rcutorture.ko torture_type=tasks-tracing fwd_progress=43. bpftrace -e 't:timer:timer_expire_entry /args->function == kaddr("call_rcu_tasks_generic_timer")/
{
printf("comm:%s,cpu:%d,stack:%s,func:%s\n", comm, cpu, kstack, ksym(args->function)); }'
Quoted 9 lines
Quoted 1 line
The
call_rcu_tasks_generic_timer()has never been executed.Very good!
Then if we get a couple of acks or reviews from the others acknowledging that if they ever make ->lazy_jiffies be changeable at runtime, they will remember to do something to adjust this logic appropriately, I will take it. ;-)
Hi, Paul
Would it be better to modify it as follows? set needwake not depend on lazy_jiffies, if ->lazy_jiffies be changed at runtime, and set it to zero, will miss the chance to wake up gp kthreads.
kernel/rcu/tasks.h +0 -0
@@ -299,11 +299,12 @@ static void call_rcu_tasks_generic_timer(struct
timer_list *tlp)
rtp = rtpcp->rtpp;
raw_spin_lock_irqsave_rcu_node(rtpcp, flags);
- if (!rcu_segcblist_empty(&rtpcp->cblist) && rtp->lazy_jiffies) {
+ if (!rcu_segcblist_empty(&rtpcp->cblist)) {
if (!rtpcp->urgent_gp)
rtpcp->urgent_gp = 1;
needwake = true;
- mod_timer(&rtpcp->lazy_timer, rcu_tasks_lazy_time(rtp));
+ if (rtp->lazy_jiffies)
+ mod_timer(&rtpcp->lazy_timer, rcu_tasks_lazy_time(rtp));
}
raw_spin_unlock_irqrestore_rcu_node(rtpcp, flags);
if (needwake)Thanks
Zqiang
Quoted 15 lines
Thanx, Paul
Quoted 13 lines
Thanks
ZqiangQuoted 9 lines
Thanx, Paul
Quoted 6 lines
kernel/rcu/tasks.h +0
-1if (!rtpcp->urgent_gp) rtpcp->urgent_gp =1 ; needwake = true; --2.17.1
Paul E. McKenney
maintainerQuoted 83 lines · Z qiang
Quoted 48 lines · Z qiang
Quoted 47 lines
Quoted 18 lines · Zqiang
Quoted 17 lines
The
rcu_tasks_percpustructure's->lazy_timer is queued only when thercu_tasksstructure's->lazy_jiffies is not equal to zero incall_rcu_tasks_generic(), if thelazy_timercallback is invoked, that means thelazy_jiffesis not equal to zero, this commit therefore removelazy_jiffiescheck incall_rcu_tasks_generic_timer().Signed-off-by Zqiang <[email protected]>--- kernel/rcu/tasks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/tasks.h +0
-0@@ -299,7 +299,7 @@ static void call_rcu_tasks_generic_timer(struct timer_list *tlp)Quoted 8 lines
kernel/rcu/tasks.h static void call_rcu_tasks_generic_timer(struct timer_list *tlp) · line 302
Quoted 4 lines
kernel/rcu/tasks.h +1
-1rtp = rtpcp->rtpp;raw_spin_lock_irqsave_rcu_node (rtpcp, flags); -if (!rcu_segcblist_empty (&rtpcp->cblist) && rtp->lazy_jiffies) { +if (!rcu_segcblist_empty (&rtpcp->cblist)) {Good eyes!
But did you test with something like a
WARN_ON_ONCE(rtp->lazy_jiffies)?Hi, Paul
+ if (!rcu_segcblist_empty(&rtpcp->cblist) &&
!WARN_ON_ONCE(!rtp->lazy_jiffies))I've done tests like this:
1. runqemu nographic kvm slirp qemuparams="-smp 4 -m 2048M -drive file=$PWD/share.img,if=virtio" bootparams="rcupdate.rcu_tasks_trace_lazy_ms=0" -d
2. insmod torture.ko
insmod rcutorture.ko torture_type=tasks-tracing fwd_progress=43. bpftrace -e 't:timer:timer_expire_entry /args->function == kaddr("call_rcu_tasks_generic_timer")/
{
printf("comm:%s,cpu:%d,stack:%s,func:%s\n", comm, cpu, kstack, ksym(args->function)); }'Quoted 9 lines
Quoted 1 line
The
call_rcu_tasks_generic_timer()has never been executed.Very good!
Then if we get a couple of acks or reviews from the others acknowledging that if they ever make ->lazy_jiffies be changeable at runtime, they will remember to do something to adjust this logic appropriately, I will take it. ;-)
Hi, Paul
Would it be better to modify it as follows? set needwake not depend on
lazy_jiffies, if ->lazy_jiffies be changed at runtime, and set it to zero, will miss the chance to wake up gp kthreads.kernel/rcu/tasks.h +3
-2@@ -299,11 +299,12 @@ static void call_rcu_tasks_generic_timer(struct timer_list *tlp) rtp = rtpcp->rtpp;raw_spin_lock_irqsave_rcu_node (rtpcp, flags); -if (!rcu_segcblist_empty (&rtpcp->cblist) && rtp->lazy_jiffies) { +if (!rcu_segcblist_empty (&rtpcp->cblist)) {if (!rtpcp->urgent_gp) rtpcp->urgent_gp =1 ; needwake = true; -mod_timer (&rtpcp->lazy_timer,rcu_tasks_lazy_time (rtp)); +if (rtp->lazy_jiffies) +mod_timer (&rtpcp->lazy_timer,rcu_tasks_lazy_time (rtp)); }raw_spin_unlock_irqrestore_rcu_node (rtpcp, flags);
Quoted 1 line
if (needwake)
Interesting approach!
But how does that avoid defeating laziness by doing the wakeup early?
Thanx, Paul
Quoted 19 lines
Thanks
ZqiangQuoted 15 lines
Thanx, Paul
Quoted 13 lines
Thanks
ZqiangQuoted 9 lines
Thanx, Paul
Quoted 6 lines
kernel/rcu/tasks.h +0
-1if (!rtpcp->urgent_gp) rtpcp->urgent_gp =1 ; needwake = true; --2.17.1
Quoted 89 lines · Z qiang
Quoted 83 lines
Quoted 48 lines · Z qiang
Quoted 47 lines
Quoted 18 lines · Zqiang
Quoted 17 lines
The
rcu_tasks_percpustructure's->lazy_timer is queued only when thercu_tasksstructure's->lazy_jiffies is not equal to zero incall_rcu_tasks_generic(), if thelazy_timercallback is invoked, that means thelazy_jiffesis not equal to zero, this commit therefore removelazy_jiffiescheck incall_rcu_tasks_generic_timer().Signed-off-by Zqiang <[email protected]>--- kernel/rcu/tasks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/tasks.h +0
-0@@ -299,7 +299,7 @@ static void call_rcu_tasks_generic_timer(struct timer_list *tlp)Quoted 8 lines
kernel/rcu/tasks.h static void call_rcu_tasks_generic_timer(struct timer_list *tlp) · line 302
Quoted 4 lines
kernel/rcu/tasks.h +1
-1rtp = rtpcp->rtpp;raw_spin_lock_irqsave_rcu_node (rtpcp, flags); -if (!rcu_segcblist_empty (&rtpcp->cblist) && rtp->lazy_jiffies) { +if (!rcu_segcblist_empty (&rtpcp->cblist)) {Good eyes!
But did you test with something like a
WARN_ON_ONCE(rtp->lazy_jiffies)?Hi, Paul
+ if (!rcu_segcblist_empty(&rtpcp->cblist) &&
!WARN_ON_ONCE(!rtp->lazy_jiffies))I've done tests like this:
1. runqemu nographic kvm slirp qemuparams="-smp 4 -m 2048M -drive file=$PWD/share.img,if=virtio" bootparams="rcupdate.rcu_tasks_trace_lazy_ms=0" -d
2. insmod torture.ko
insmod rcutorture.ko torture_type=tasks-tracing fwd_progress=43. bpftrace -e 't:timer:timer_expire_entry /args->function == kaddr("call_rcu_tasks_generic_timer")/
{
printf("comm:%s,cpu:%d,stack:%s,func:%s\n", comm, cpu, kstack, ksym(args->function)); }'Quoted 9 lines
Quoted 1 line
The
call_rcu_tasks_generic_timer()has never been executed.Very good!
Then if we get a couple of acks or reviews from the others acknowledging that if they ever make ->lazy_jiffies be changeable at runtime, they will remember to do something to adjust this logic appropriately, I will take it. ;-)
Hi, Paul
Would it be better to modify it as follows? set needwake not depend on
lazy_jiffies, if ->lazy_jiffies be changed at runtime, and set it to zero, will miss the chance to wake up gp kthreads.kernel/rcu/tasks.h +3
-2@@ -299,11 +299,12 @@ static void call_rcu_tasks_generic_timer(struct timer_list *tlp) rtp = rtpcp->rtpp;raw_spin_lock_irqsave_rcu_node (rtpcp, flags); -if (!rcu_segcblist_empty (&rtpcp->cblist) && rtp->lazy_jiffies) { +if (!rcu_segcblist_empty (&rtpcp->cblist)) {if (!rtpcp->urgent_gp) rtpcp->urgent_gp =1 ; needwake = true; -mod_timer (&rtpcp->lazy_timer,rcu_tasks_lazy_time (rtp)); +if (rtp->lazy_jiffies) +mod_timer (&rtpcp->lazy_timer,rcu_tasks_lazy_time (rtp)); }raw_spin_unlock_irqrestore_rcu_node (rtpcp, flags);Quoted 1 line
if (needwake)
Interesting approach!
Quoted 1 line
But how does that avoid defeating laziness by doing the wakeup early?
Hello, Paul
Does this mean that if cblist is empty, we will miss the opportunity to enqueue the timer again? If so, we can move mod_timer() outside the if condition.
or I didn't understand your question?
Thanks
Zqiang
Quoted 22 lines
Thanx, Paul
Quoted 19 lines
Thanks
ZqiangQuoted 15 lines
Thanx, Paul
Quoted 13 lines
Thanks
ZqiangQuoted 9 lines
Thanx, Paul
Quoted 6 lines
kernel/rcu/tasks.h +0
-1if (!rtpcp->urgent_gp) rtpcp->urgent_gp =1 ; needwake = true; --2.17.1
Paul E. McKenney
maintainerQuoted 88 lines · Z qiang
Quoted 88 lines · Z qiang
Quoted 83 lines
Quoted 48 lines · Z qiang
Quoted 47 lines
Quoted 18 lines · Zqiang
Quoted 17 lines
The
rcu_tasks_percpustructure's->lazy_timer is queued only when thercu_tasksstructure's->lazy_jiffies is not equal to zero incall_rcu_tasks_generic(), if thelazy_timercallback is invoked, that means thelazy_jiffesis not equal to zero, this commit therefore removelazy_jiffiescheck incall_rcu_tasks_generic_timer().Signed-off-by Zqiang <[email protected]>--- kernel/rcu/tasks.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/tasks.h +0
-0@@ -299,7 +299,7 @@ static void call_rcu_tasks_generic_timer(struct timer_list *tlp)Quoted 8 lines
kernel/rcu/tasks.h static void call_rcu_tasks_generic_timer(struct timer_list *tlp) · line 302
Quoted 4 lines
kernel/rcu/tasks.h +1
-1rtp = rtpcp->rtpp;raw_spin_lock_irqsave_rcu_node (rtpcp, flags); -if (!rcu_segcblist_empty (&rtpcp->cblist) && rtp->lazy_jiffies) { +if (!rcu_segcblist_empty (&rtpcp->cblist)) {Good eyes!
But did you test with something like a
WARN_ON_ONCE(rtp->lazy_jiffies)?Hi, Paul
+ if (!rcu_segcblist_empty(&rtpcp->cblist) &&
!WARN_ON_ONCE(!rtp->lazy_jiffies))I've done tests like this:
1. runqemu nographic kvm slirp qemuparams="-smp 4 -m 2048M -drive file=$PWD/share.img,if=virtio" bootparams="rcupdate.rcu_tasks_trace_lazy_ms=0" -d
2. insmod torture.ko
insmod rcutorture.ko torture_type=tasks-tracing fwd_progress=43. bpftrace -e 't:timer:timer_expire_entry /args->function == kaddr("call_rcu_tasks_generic_timer")/
{
printf("comm:%s,cpu:%d,stack:%s,func:%s\n", comm, cpu, kstack, ksym(args->function)); }'Quoted 9 lines
Quoted 1 line
The
call_rcu_tasks_generic_timer()has never been executed.Very good!
Then if we get a couple of acks or reviews from the others acknowledging that if they ever make ->lazy_jiffies be changeable at runtime, they will remember to do something to adjust this logic appropriately, I will take it. ;-)
Hi, Paul
Would it be better to modify it as follows? set needwake not depend on
lazy_jiffies, if ->lazy_jiffies be changed at runtime, and set it to zero, will miss the chance to wake up gp kthreads.kernel/rcu/tasks.h +3
-2@@ -299,11 +299,12 @@ static void call_rcu_tasks_generic_timer(struct timer_list *tlp) rtp = rtpcp->rtpp;raw_spin_lock_irqsave_rcu_node (rtpcp, flags); -if (!rcu_segcblist_empty (&rtpcp->cblist) && rtp->lazy_jiffies) { +if (!rcu_segcblist_empty (&rtpcp->cblist)) {if (!rtpcp->urgent_gp) rtpcp->urgent_gp =1 ; needwake = true; -mod_timer (&rtpcp->lazy_timer,rcu_tasks_lazy_time (rtp)); +if (rtp->lazy_jiffies) +mod_timer (&rtpcp->lazy_timer,rcu_tasks_lazy_time (rtp)); }raw_spin_unlock_irqrestore_rcu_node (rtpcp, flags);Quoted 1 line
if (needwake)
Interesting approach!
Quoted 8 lines
Quoted 1 line
But how does that avoid defeating laziness by doing the wakeup early?
Hello, Paul
Does this mean that if cblist is empty, we will miss the opportunity to enqueue the timer again? If so, we can move
mod_timer()outside the if condition.
or I didn't understand your question?
Never mind! I was getting confused, and forgetting that this code has already seen a timeout.
Let's see what others think.
Thanx, Paul
Quoted 26 lines
Thanks
ZqiangQuoted 22 lines
Thanx, Paul
Quoted 19 lines
Thanks
ZqiangQuoted 15 lines
Thanx, Paul
Quoted 13 lines
Thanks
ZqiangQuoted 9 lines
Thanx, Paul
Quoted 6 lines
kernel/rcu/tasks.h +0
-1if (!rtpcp->urgent_gp) rtpcp->urgent_gp =1 ; needwake = true; --2.17.1