All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] rcu: Speed up calling of RCU tasks callbacks
@ 2018-05-24 22:49 Steven Rostedt
  2018-05-24 23:19 ` Joel Fernandes
  2018-05-25 20:11 ` Paul E. McKenney
  0 siblings, 2 replies; 6+ messages in thread
From: Steven Rostedt @ 2018-05-24 22:49 UTC (permalink / raw)
  To: LKML
  Cc: Paul E. McKenney, Joel Fernandes, Peter Zilstra, Ingo Molnar,
	Boqun Feng, byungchul.park, kernel-team, Josh Triplett,
	Lai Jiangshan, Mathieu Desnoyers


From: Steven Rostedt (VMware) <rostedt@goodmis.org>

Joel Fernandes found that the synchronize_rcu_tasks() was taking a
significant amount of time. He demonstrated it with the following test:

 # cd /sys/kernel/tracing
 # while [ 1 ]; do x=1; done &
 # echo '__schedule_bug:traceon' > set_ftrace_filter
 # time echo '!__schedule_bug:traceon' > set_ftrace_filter;

real	0m1.064s
user	0m0.000s
sys	0m0.004s

Where it takes a little over a second to perform the synchronize,
because there's a loop that waits 1 second at a time for tasks to get
through their quiescent points when there's a task that must be waited
for.

After discussion we came up with a simple way to wait for holdouts but
increase the time for each iteration of the loop but no more than a
full second.

With the new patch we have:

 # time echo '!__schedule_bug:traceon' > set_ftrace_filter;

real	0m0.131s
user	0m0.000s
sys	0m0.004s

Which drops it down to 13% of what the original wait time was.

Link: http://lkml.kernel.org/r/20180523063815.198302-2-joel@joelfernandes.org
Reported-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Suggested-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
index 68fa19a5e7bd..452e47841a86 100644
--- a/kernel/rcu/update.c
+++ b/kernel/rcu/update.c
@@ -715,6 +715,7 @@ static int __noreturn rcu_tasks_kthread(void *arg)
 	struct rcu_head *list;
 	struct rcu_head *next;
 	LIST_HEAD(rcu_tasks_holdouts);
+	int fract;
 
 	/* Run on housekeeping CPUs by default.  Sysadm can move if desired. */
 	housekeeping_affine(current, HK_FLAG_RCU);
@@ -796,13 +797,25 @@ static int __noreturn rcu_tasks_kthread(void *arg)
 		 * holdouts.  When the list is empty, we are done.
 		 */
 		lastreport = jiffies;
-		while (!list_empty(&rcu_tasks_holdouts)) {
+
+		/* Start off with HZ/10 wait and slowly back off to 1 HZ wait*/
+		fract = 10;
+
+		for (;;) {
 			bool firstreport;
 			bool needreport;
 			int rtst;
 			struct task_struct *t1;
 
-			schedule_timeout_interruptible(HZ);
+			if (list_empty(&rcu_tasks_holdouts))
+				break;
+
+			/* Slowly back off waiting for holdouts */
+			schedule_timeout_interruptible(HZ/fract);
+
+			if (fract > 1)
+				fract--;
+
 			rtst = READ_ONCE(rcu_task_stall_timeout);
 			needreport = rtst > 0 &&
 				     time_after(jiffies, lastreport + rtst);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v4] rcu: Speed up calling of RCU tasks callbacks
  2018-05-24 22:49 [PATCH v4] rcu: Speed up calling of RCU tasks callbacks Steven Rostedt
@ 2018-05-24 23:19 ` Joel Fernandes
  2018-05-24 23:22   ` Steven Rostedt
  2018-05-25 20:11 ` Paul E. McKenney
  1 sibling, 1 reply; 6+ messages in thread
From: Joel Fernandes @ 2018-05-24 23:19 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Paul E. McKenney, Peter Zilstra, Ingo Molnar, Boqun Feng,
	byungchul.park, kernel-team, Josh Triplett, Lai Jiangshan,
	Mathieu Desnoyers

On Thu, May 24, 2018 at 06:49:46PM -0400, Steven Rostedt wrote:
> 
> From: Steven Rostedt (VMware) <rostedt@goodmis.org>
> 
> Joel Fernandes found that the synchronize_rcu_tasks() was taking a
> significant amount of time. He demonstrated it with the following test:
> 
>  # cd /sys/kernel/tracing
>  # while [ 1 ]; do x=1; done &
>  # echo '__schedule_bug:traceon' > set_ftrace_filter
>  # time echo '!__schedule_bug:traceon' > set_ftrace_filter;
> 
> real	0m1.064s
> user	0m0.000s
> sys	0m0.004s
> 
> Where it takes a little over a second to perform the synchronize,
> because there's a loop that waits 1 second at a time for tasks to get
> through their quiescent points when there's a task that must be waited
> for.
> 
> After discussion we came up with a simple way to wait for holdouts but
> increase the time for each iteration of the loop but no more than a
> full second.
> 
> With the new patch we have:
> 
>  # time echo '!__schedule_bug:traceon' > set_ftrace_filter;
> 
> real	0m0.131s
> user	0m0.000s
> sys	0m0.004s
> 
> Which drops it down to 13% of what the original wait time was.

Should be 90% of original?

> 
> Link: http://lkml.kernel.org/r/20180523063815.198302-2-joel@joelfernandes.org
> Reported-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> Suggested-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
> diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
> index 68fa19a5e7bd..452e47841a86 100644
> --- a/kernel/rcu/update.c
> +++ b/kernel/rcu/update.c
> @@ -715,6 +715,7 @@ static int __noreturn rcu_tasks_kthread(void *arg)
>  	struct rcu_head *list;
>  	struct rcu_head *next;
>  	LIST_HEAD(rcu_tasks_holdouts);
> +	int fract;
>  
>  	/* Run on housekeeping CPUs by default.  Sysadm can move if desired. */
>  	housekeeping_affine(current, HK_FLAG_RCU);
> @@ -796,13 +797,25 @@ static int __noreturn rcu_tasks_kthread(void *arg)
>  		 * holdouts.  When the list is empty, we are done.
>  		 */
>  		lastreport = jiffies;
> -		while (!list_empty(&rcu_tasks_holdouts)) {
> +
> +		/* Start off with HZ/10 wait and slowly back off to 1 HZ wait*/
> +		fract = 10;
> +
> +		for (;;) {
>  			bool firstreport;
>  			bool needreport;
>  			int rtst;
>  			struct task_struct *t1;
>  
> -			schedule_timeout_interruptible(HZ);
> +			if (list_empty(&rcu_tasks_holdouts))
> +				break;
> +
> +			/* Slowly back off waiting for holdouts */
> +			schedule_timeout_interruptible(HZ/fract);
> +
> +			if (fract > 1)
> +				fract--;
> +

Other than minor change log change, looks good to me:

Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>

thanks,

 - Joel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4] rcu: Speed up calling of RCU tasks callbacks
  2018-05-24 23:19 ` Joel Fernandes
@ 2018-05-24 23:22   ` Steven Rostedt
  2018-05-24 23:26     ` Randy Dunlap
  0 siblings, 1 reply; 6+ messages in thread
From: Steven Rostedt @ 2018-05-24 23:22 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: LKML, Paul E. McKenney, Peter Zilstra, Ingo Molnar, Boqun Feng,
	byungchul.park, kernel-team, Josh Triplett, Lai Jiangshan,
	Mathieu Desnoyers

On Thu, 24 May 2018 16:19:18 -0700
Joel Fernandes <joel@joelfernandes.org> wrote:

> On Thu, May 24, 2018 at 06:49:46PM -0400, Steven Rostedt wrote:
> > 
> > From: Steven Rostedt (VMware) <rostedt@goodmis.org>
> > 
> > Joel Fernandes found that the synchronize_rcu_tasks() was taking a
> > significant amount of time. He demonstrated it with the following test:
> > 
> >  # cd /sys/kernel/tracing
> >  # while [ 1 ]; do x=1; done &
> >  # echo '__schedule_bug:traceon' > set_ftrace_filter
> >  # time echo '!__schedule_bug:traceon' > set_ftrace_filter;
> > 
> > real	0m1.064s
> > user	0m0.000s
> > sys	0m0.004s
> > 
> > Where it takes a little over a second to perform the synchronize,
> > because there's a loop that waits 1 second at a time for tasks to get
> > through their quiescent points when there's a task that must be waited
> > for.
> > 
> > After discussion we came up with a simple way to wait for holdouts but
> > increase the time for each iteration of the loop but no more than a
> > full second.
> > 
> > With the new patch we have:
> > 
> >  # time echo '!__schedule_bug:traceon' > set_ftrace_filter;
> > 
> > real	0m0.131s
> > user	0m0.000s
> > sys	0m0.004s
> > 
> > Which drops it down to 13% of what the original wait time was.  
> 
> Should be 90% of original?

That would be if I said "drops it down X" but I said "drops it down to
X of what the original wait time was". And 0.131 is 13% of 1.064. :-)

> Other than minor change log change, looks good to me:
> 
> Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>

Awesome, thanks!

-- Steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4] rcu: Speed up calling of RCU tasks callbacks
  2018-05-24 23:22   ` Steven Rostedt
@ 2018-05-24 23:26     ` Randy Dunlap
  2018-05-25  0:14       ` Randy Dunlap
  0 siblings, 1 reply; 6+ messages in thread
From: Randy Dunlap @ 2018-05-24 23:26 UTC (permalink / raw)
  To: Steven Rostedt, Joel Fernandes
  Cc: LKML, Paul E. McKenney, Peter Zilstra, Ingo Molnar, Boqun Feng,
	byungchul.park, kernel-team, Josh Triplett, Lai Jiangshan,
	Mathieu Desnoyers

On 05/24/2018 04:22 PM, Steven Rostedt wrote:
> On Thu, 24 May 2018 16:19:18 -0700
> Joel Fernandes <joel@joelfernandes.org> wrote:
> 
>> On Thu, May 24, 2018 at 06:49:46PM -0400, Steven Rostedt wrote:
>>>
>>> From: Steven Rostedt (VMware) <rostedt@goodmis.org>
>>>
>>> Joel Fernandes found that the synchronize_rcu_tasks() was taking a
>>> significant amount of time. He demonstrated it with the following test:
>>>
>>>  # cd /sys/kernel/tracing
>>>  # while [ 1 ]; do x=1; done &
>>>  # echo '__schedule_bug:traceon' > set_ftrace_filter
>>>  # time echo '!__schedule_bug:traceon' > set_ftrace_filter;
>>>
>>> real	0m1.064s
>>> user	0m0.000s
>>> sys	0m0.004s
>>>
>>> Where it takes a little over a second to perform the synchronize,
>>> because there's a loop that waits 1 second at a time for tasks to get
>>> through their quiescent points when there's a task that must be waited
>>> for.
>>>
>>> After discussion we came up with a simple way to wait for holdouts but
>>> increase the time for each iteration of the loop but no more than a
>>> full second.
>>>
>>> With the new patch we have:
>>>
>>>  # time echo '!__schedule_bug:traceon' > set_ftrace_filter;
>>>
>>> real	0m0.131s
>>> user	0m0.000s
>>> sys	0m0.004s
>>>
>>> Which drops it down to 13% of what the original wait time was.  
>>
>> Should be 90% of original?
> 
> That would be if I said "drops it down X" but I said "drops it down to
> X of what the original wait time was". And 0.131 is 13% of 1.064. :-)

I think that you are confusing "drops it down to" with "drops it down by".
You said the former.  You should say the latter.
IOW, I agree with Joel.

>> Other than minor change log change, looks good to me:
>>
>> Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> 
> Awesome, thanks!
> 
> -- Steve
> 


-- 
~Randy

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4] rcu: Speed up calling of RCU tasks callbacks
  2018-05-24 23:26     ` Randy Dunlap
@ 2018-05-25  0:14       ` Randy Dunlap
  0 siblings, 0 replies; 6+ messages in thread
From: Randy Dunlap @ 2018-05-25  0:14 UTC (permalink / raw)
  To: Steven Rostedt, Joel Fernandes
  Cc: LKML, Paul E. McKenney, Peter Zilstra, Ingo Molnar, Boqun Feng,
	byungchul.park, kernel-team, Josh Triplett, Lai Jiangshan,
	Mathieu Desnoyers

On 05/24/2018 04:26 PM, Randy Dunlap wrote:
> On 05/24/2018 04:22 PM, Steven Rostedt wrote:
>> On Thu, 24 May 2018 16:19:18 -0700
>> Joel Fernandes <joel@joelfernandes.org> wrote:
>>
>>> On Thu, May 24, 2018 at 06:49:46PM -0400, Steven Rostedt wrote:
>>>>
>>>> From: Steven Rostedt (VMware) <rostedt@goodmis.org>
>>>>
>>>> Joel Fernandes found that the synchronize_rcu_tasks() was taking a
>>>> significant amount of time. He demonstrated it with the following test:
>>>>
>>>>  # cd /sys/kernel/tracing
>>>>  # while [ 1 ]; do x=1; done &
>>>>  # echo '__schedule_bug:traceon' > set_ftrace_filter
>>>>  # time echo '!__schedule_bug:traceon' > set_ftrace_filter;
>>>>
>>>> real	0m1.064s
>>>> user	0m0.000s
>>>> sys	0m0.004s
>>>>
>>>> Where it takes a little over a second to perform the synchronize,
>>>> because there's a loop that waits 1 second at a time for tasks to get
>>>> through their quiescent points when there's a task that must be waited
>>>> for.
>>>>
>>>> After discussion we came up with a simple way to wait for holdouts but
>>>> increase the time for each iteration of the loop but no more than a
>>>> full second.
>>>>
>>>> With the new patch we have:
>>>>
>>>>  # time echo '!__schedule_bug:traceon' > set_ftrace_filter;
>>>>
>>>> real	0m0.131s
>>>> user	0m0.000s
>>>> sys	0m0.004s
>>>>
>>>> Which drops it down to 13% of what the original wait time was.  
>>>
>>> Should be 90% of original?
>>
>> That would be if I said "drops it down X" but I said "drops it down to
>> X of what the original wait time was". And 0.131 is 13% of 1.064. :-)
> 
> I think that you are confusing "drops it down to" with "drops it down by".
> You said the former.  You should say the latter.
> IOW, I agree with Joel.


Please forget this.  After reading the numbers, your comments look correct.


-- 
~Randy

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4] rcu: Speed up calling of RCU tasks callbacks
  2018-05-24 22:49 [PATCH v4] rcu: Speed up calling of RCU tasks callbacks Steven Rostedt
  2018-05-24 23:19 ` Joel Fernandes
@ 2018-05-25 20:11 ` Paul E. McKenney
  1 sibling, 0 replies; 6+ messages in thread
From: Paul E. McKenney @ 2018-05-25 20:11 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Joel Fernandes, Peter Zilstra, Ingo Molnar, Boqun Feng,
	byungchul.park, kernel-team, Josh Triplett, Lai Jiangshan,
	Mathieu Desnoyers

On Thu, May 24, 2018 at 06:49:46PM -0400, Steven Rostedt wrote:
> 
> From: Steven Rostedt (VMware) <rostedt@goodmis.org>
> 
> Joel Fernandes found that the synchronize_rcu_tasks() was taking a
> significant amount of time. He demonstrated it with the following test:
> 
>  # cd /sys/kernel/tracing
>  # while [ 1 ]; do x=1; done &
>  # echo '__schedule_bug:traceon' > set_ftrace_filter
>  # time echo '!__schedule_bug:traceon' > set_ftrace_filter;
> 
> real	0m1.064s
> user	0m0.000s
> sys	0m0.004s
> 
> Where it takes a little over a second to perform the synchronize,
> because there's a loop that waits 1 second at a time for tasks to get
> through their quiescent points when there's a task that must be waited
> for.
> 
> After discussion we came up with a simple way to wait for holdouts but
> increase the time for each iteration of the loop but no more than a
> full second.
> 
> With the new patch we have:
> 
>  # time echo '!__schedule_bug:traceon' > set_ftrace_filter;
> 
> real	0m0.131s
> user	0m0.000s
> sys	0m0.004s
> 
> Which drops it down to 13% of what the original wait time was.
> 
> Link: http://lkml.kernel.org/r/20180523063815.198302-2-joel@joelfernandes.org
> Reported-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> Suggested-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

I queued both commits, thank you all!

							Thanx, Paul

> ---
> diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
> index 68fa19a5e7bd..452e47841a86 100644
> --- a/kernel/rcu/update.c
> +++ b/kernel/rcu/update.c
> @@ -715,6 +715,7 @@ static int __noreturn rcu_tasks_kthread(void *arg)
>  	struct rcu_head *list;
>  	struct rcu_head *next;
>  	LIST_HEAD(rcu_tasks_holdouts);
> +	int fract;
> 
>  	/* Run on housekeeping CPUs by default.  Sysadm can move if desired. */
>  	housekeeping_affine(current, HK_FLAG_RCU);
> @@ -796,13 +797,25 @@ static int __noreturn rcu_tasks_kthread(void *arg)
>  		 * holdouts.  When the list is empty, we are done.
>  		 */
>  		lastreport = jiffies;
> -		while (!list_empty(&rcu_tasks_holdouts)) {
> +
> +		/* Start off with HZ/10 wait and slowly back off to 1 HZ wait*/
> +		fract = 10;
> +
> +		for (;;) {
>  			bool firstreport;
>  			bool needreport;
>  			int rtst;
>  			struct task_struct *t1;
> 
> -			schedule_timeout_interruptible(HZ);
> +			if (list_empty(&rcu_tasks_holdouts))
> +				break;
> +
> +			/* Slowly back off waiting for holdouts */
> +			schedule_timeout_interruptible(HZ/fract);
> +
> +			if (fract > 1)
> +				fract--;
> +
>  			rtst = READ_ONCE(rcu_task_stall_timeout);
>  			needreport = rtst > 0 &&
>  				     time_after(jiffies, lastreport + rtst);
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-05-25 20:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-24 22:49 [PATCH v4] rcu: Speed up calling of RCU tasks callbacks Steven Rostedt
2018-05-24 23:19 ` Joel Fernandes
2018-05-24 23:22   ` Steven Rostedt
2018-05-24 23:26     ` Randy Dunlap
2018-05-25  0:14       ` Randy Dunlap
2018-05-25 20:11 ` Paul E. McKenney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.