Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1671157

Re: [RFC v2 1/2] swait: add idle variants which don't contribute to load average

From "Luis R. Rodriguez" <mcgrof@kernel.org>
Newsgroups linux.kernel
Subject Re: [RFC v2 1/2] swait: add idle variants which don't contribute to load average
Date 2017-06-20 23:40 +0200
Message-ID <tUz2q-5x0-35@gated-at.bofh.it> (permalink)
References <tSGrn-5cj-11@gated-at.bofh.it> <tSI0a-63s-7@gated-at.bofh.it> <tSI0a-63s-5@gated-at.bofh.it> <tSNCx-1dK-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Jun 16, 2017 at 08:47:32AM +0800, Boqun Feng wrote:
> On Thu, Jun 15, 2017 at 11:48:19AM -0700, Luis R. Rodriguez wrote:
> > There are cases where folks are using an interruptible swait when
> > using kthreads. This is rather confusing given you'd expect
> > interruptible waits to be -- interruptible, but kthreads are not
> > interruptible ! The reason for such practice though is to avoid
> > having these kthreads contribute to the system load average.
> > 
> > When systems are idle some kthreads may spend a lot of time blocking if
> > using swait_event_timeout(). This would contribute to the system load
> > average. On systems without preemption this would mean the load average
> > of an idle system is bumped to 2 instead of 0. On systems with PREEMPT=y
> > this would mean the load average of an idle system is bumped to 3
> > instead of 0.
> > 
> > This adds proper API using TASK_IDLE to make such goals explicit and
> > avoid confusion.
> > 
> > Suggested-by: "Eric W. Biederman" <ebiederm@xmission.com>
> > Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
> > ---
> >  include/linux/swait.h | 25 +++++++++++++++++++++++++
> >  1 file changed, 25 insertions(+)
> > 
> > diff --git a/include/linux/swait.h b/include/linux/swait.h
> > index 2c700694d50a..105c70e23286 100644
> > --- a/include/linux/swait.h
> > +++ b/include/linux/swait.h
> > @@ -194,4 +194,29 @@ do {									\
> >  	__ret;								\
> >  })
> >  
> > +#define __swait_event_idle(wq, condition)				\
> > +	___swait_event(wq, condition, TASK_IDLE, 0, schedule())
> > +
> > +#define swait_event_idle(wq, condition)					\
> 
> Better to have some comments before to describe the purpose of this API?
> Something like:
> 
> /**
>  * swait_event_idle - wait uninterruptibly without system load contribution
>  * @wq: the waitqueue to wait on
>  * @condition: a C expression for the event to wait for
>  *
>  * The process is put to sleep (TASK_IDLE) until the
>  * @condition evaluates to true or a signal is received.

Except we get no signals.

>  * The @condition is checked each time the waitqueue @wq is woken up.
>  *
>  * This function is mostly used when a kthread waits some condition and
>  * doesn't want to contribute to system load
>  */
> 
> so is for swait_event_idle_timeout().

Will add for both calls and elaborate on the return value for the timeout case.

  Luis

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: [RFC v2 1/2] swait: add idle variants which don't contribute to  load average "Luis R. Rodriguez" <mcgrof@kernel.org> - 2017-06-20 23:40 +0200

csiph-web