From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752139AbdFPUi6 (ORCPT ); Fri, 16 Jun 2017 16:38:58 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:41303 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750987AbdFPUi5 (ORCPT ); Fri, 16 Jun 2017 16:38:57 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: "Luis R. Rodriguez" Cc: peterz@infradead.org, paulmck@linux.vnet.ibm.com, oleg@redhat.com, josh@joshtriplett.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, paul.gortmaker@windriver.com, dmitry.torokhov@gmail.com, linux-kernel@vger.kernel.org References: <87zid92ns2.fsf@xmission.com> <20170615184820.22994-1-mcgrof@kernel.org> <20170615184820.22994-2-mcgrof@kernel.org> Date: Fri, 16 Jun 2017 15:31:51 -0500 In-Reply-To: <20170615184820.22994-2-mcgrof@kernel.org> (Luis R. Rodriguez's message of "Thu, 15 Jun 2017 11:48:19 -0700") Message-ID: <87k24bsmh4.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1dLy12-0000VP-4e;;;mid=<87k24bsmh4.fsf@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=67.3.213.87;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX19gWUoy784Angx+FUyoJQLxKUROGbAjXr4= X-SA-Exim-Connect-IP: 67.3.213.87 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;"Luis R. Rodriguez" X-Spam-Relay-Country: X-Spam-Timing: total 5540 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 3.3 (0.1%), b_tie_ro: 2.2 (0.0%), parse: 1.04 (0.0%), extract_message_metadata: 12 (0.2%), get_uri_detail_list: 1.63 (0.0%), tests_pri_-1000: 5 (0.1%), tests_pri_-950: 1.14 (0.0%), tests_pri_-900: 0.98 (0.0%), tests_pri_-400: 20 (0.4%), check_bayes: 19 (0.3%), b_tokenize: 6 (0.1%), b_tok_get_all: 6 (0.1%), b_comp_prob: 1.80 (0.0%), b_tok_touch_all: 2.7 (0.0%), b_finish: 0.61 (0.0%), tests_pri_0: 255 (4.6%), check_dkim_signature: 0.62 (0.0%), check_dkim_adsp: 3.3 (0.1%), tests_pri_500: 5238 (94.5%), poll_dns_idle: 5233 (94.5%), rewrite_mail: 0.00 (0.0%) Subject: Re: [RFC v2 1/2] swait: add idle variants which don't contribute to load average X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Luis R. Rodriguez" writes: > 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" > Signed-off-by: Luis R. Rodriguez > --- > 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) \ > +({ \ > + int __ret = 0; \ > + if (!(condition)) \ > + __ret = __swait_event_idle(wq, condition); \ > + __ret; \ > +}) The wait isn't interruptible so a return code doesn't make sense here. > +#define __swait_event_idle_timeout(wq, condition, timeout) \ > + ___swait_event(wq, ___wait_cond_timeout(condition), \ > + TASK_IDLE, timeout, \ > + __ret = schedule_timeout(__ret)) > + > +#define swait_event_idle_timeout(wq, condition, timeout) \ > +({ \ > + long __ret = timeout; \ > + if (!___wait_cond_timeout(condition)) \ > + __ret = __swait_event_idle_timeout(wq, \ > + condition, timeout); \ > + __ret; \ > +}) > + > #endif /* _LINUX_SWAIT_H */