linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC rcu/next] torture: Stop onoff task if there is only one cpu
@ 2016-05-02  2:30 Boqun Feng
  2016-05-02 17:18 ` Josh Triplett
  0 siblings, 1 reply; 3+ messages in thread
From: Boqun Feng @ 2016-05-02  2:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: Paul E. McKenney, Josh Triplett, Boqun Feng

If the whole system has only one cpu, that cpu won't be able to be
offlined, so there is no need onoff task is stil running.

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---

I hit something like the following while I was running rcutorture
in a guest with only one vCPU:

[   31.197457] rcu-torture:torture_onoff task: offlining 0
[   31.197508] rcu-torture:torture_onoff task: offline 0 failed: errno -16

I know this is an expected behavior, but think we could just stop
the onoff task if there is only one cpu.

 kernel/torture.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/torture.c b/kernel/torture.c
index fb39a06bbef5..a85b7d61d9dd 100644
--- a/kernel/torture.c
+++ b/kernel/torture.c
@@ -194,6 +194,12 @@ torture_onoff(void *arg)
 	for_each_online_cpu(cpu)
 		maxcpu = cpu;
 	WARN_ON(maxcpu < 0);
+
+	if (maxcpu == 0) {
+		VERBOSE_TOROUT_STRING("only one cpu is found, onoff is impossible");
+		goto stop;
+	}
+
 	if (onoff_holdoff > 0) {
 		VERBOSE_TOROUT_STRING("torture_onoff begin holdoff");
 		schedule_timeout_interruptible(onoff_holdoff);
@@ -209,6 +215,8 @@ torture_onoff(void *arg)
 				       &sum_online, &min_online, &max_online);
 		schedule_timeout_interruptible(onoff_interval);
 	}
+
+stop:
 	torture_kthread_stopping("torture_onoff");
 	return 0;
 }
-- 
2.8.0

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

* Re: [RFC rcu/next] torture: Stop onoff task if there is only one cpu
  2016-05-02  2:30 [RFC rcu/next] torture: Stop onoff task if there is only one cpu Boqun Feng
@ 2016-05-02 17:18 ` Josh Triplett
  2016-05-02 19:30   ` Paul E. McKenney
  0 siblings, 1 reply; 3+ messages in thread
From: Josh Triplett @ 2016-05-02 17:18 UTC (permalink / raw)
  To: Boqun Feng; +Cc: linux-kernel, Paul E. McKenney

On Mon, May 02, 2016 at 10:30:00AM +0800, Boqun Feng wrote:
> If the whole system has only one cpu, that cpu won't be able to be
> offlined, so there is no need onoff task is stil running.
> 
> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> ---
> 
> I hit something like the following while I was running rcutorture
> in a guest with only one vCPU:
> 
> [   31.197457] rcu-torture:torture_onoff task: offlining 0
> [   31.197508] rcu-torture:torture_onoff task: offline 0 failed: errno -16
> 
> I know this is an expected behavior, but think we could just stop
> the onoff task if there is only one cpu.

I find it a little bit unfortunate that this kicks off a thread just to
immediately exit that thread, rather than never starting it in the first
place.  However, it also seems like the most convenient solution here,
and I don't see much point in going out of the way to optimize this test
for uniprocessor systems.

Reviewed-by: Josh Triplett <josh@joshtriplett.org>

>  kernel/torture.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/kernel/torture.c b/kernel/torture.c
> index fb39a06bbef5..a85b7d61d9dd 100644
> --- a/kernel/torture.c
> +++ b/kernel/torture.c
> @@ -194,6 +194,12 @@ torture_onoff(void *arg)
>  	for_each_online_cpu(cpu)
>  		maxcpu = cpu;
>  	WARN_ON(maxcpu < 0);
> +
> +	if (maxcpu == 0) {
> +		VERBOSE_TOROUT_STRING("only one cpu is found, onoff is impossible");
> +		goto stop;
> +	}
> +
>  	if (onoff_holdoff > 0) {
>  		VERBOSE_TOROUT_STRING("torture_onoff begin holdoff");
>  		schedule_timeout_interruptible(onoff_holdoff);
> @@ -209,6 +215,8 @@ torture_onoff(void *arg)
>  				       &sum_online, &min_online, &max_online);
>  		schedule_timeout_interruptible(onoff_interval);
>  	}
> +
> +stop:
>  	torture_kthread_stopping("torture_onoff");
>  	return 0;
>  }
> -- 
> 2.8.0
> 

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

* Re: [RFC rcu/next] torture: Stop onoff task if there is only one cpu
  2016-05-02 17:18 ` Josh Triplett
@ 2016-05-02 19:30   ` Paul E. McKenney
  0 siblings, 0 replies; 3+ messages in thread
From: Paul E. McKenney @ 2016-05-02 19:30 UTC (permalink / raw)
  To: Josh Triplett; +Cc: Boqun Feng, linux-kernel

On Mon, May 02, 2016 at 10:18:49AM -0700, Josh Triplett wrote:
> On Mon, May 02, 2016 at 10:30:00AM +0800, Boqun Feng wrote:
> > If the whole system has only one cpu, that cpu won't be able to be
> > offlined, so there is no need onoff task is stil running.
> > 
> > Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> > ---
> > 
> > I hit something like the following while I was running rcutorture
> > in a guest with only one vCPU:
> > 
> > [   31.197457] rcu-torture:torture_onoff task: offlining 0
> > [   31.197508] rcu-torture:torture_onoff task: offline 0 failed: errno -16
> > 
> > I know this is an expected behavior, but think we could just stop
> > the onoff task if there is only one cpu.
> 
> I find it a little bit unfortunate that this kicks off a thread just to
> immediately exit that thread, rather than never starting it in the first
> place.  However, it also seems like the most convenient solution here,
> and I don't see much point in going out of the way to optimize this test
> for uniprocessor systems.
> 
> Reviewed-by: Josh Triplett <josh@joshtriplett.org>

Thank you both!  Queued for testing and further review.

								Thanx, Paul

> >  kernel/torture.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/kernel/torture.c b/kernel/torture.c
> > index fb39a06bbef5..a85b7d61d9dd 100644
> > --- a/kernel/torture.c
> > +++ b/kernel/torture.c
> > @@ -194,6 +194,12 @@ torture_onoff(void *arg)
> >  	for_each_online_cpu(cpu)
> >  		maxcpu = cpu;
> >  	WARN_ON(maxcpu < 0);
> > +
> > +	if (maxcpu == 0) {
> > +		VERBOSE_TOROUT_STRING("only one cpu is found, onoff is impossible");
> > +		goto stop;
> > +	}
> > +
> >  	if (onoff_holdoff > 0) {
> >  		VERBOSE_TOROUT_STRING("torture_onoff begin holdoff");
> >  		schedule_timeout_interruptible(onoff_holdoff);
> > @@ -209,6 +215,8 @@ torture_onoff(void *arg)
> >  				       &sum_online, &min_online, &max_online);
> >  		schedule_timeout_interruptible(onoff_interval);
> >  	}
> > +
> > +stop:
> >  	torture_kthread_stopping("torture_onoff");
> >  	return 0;
> >  }
> > -- 
> > 2.8.0
> > 
> 

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

end of thread, other threads:[~2016-05-02 19:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-02  2:30 [RFC rcu/next] torture: Stop onoff task if there is only one cpu Boqun Feng
2016-05-02 17:18 ` Josh Triplett
2016-05-02 19:30   ` 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).