From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752155AbdFOSs0 (ORCPT ); Thu, 15 Jun 2017 14:48:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:50004 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752063AbdFOSsY (ORCPT ); Thu, 15 Jun 2017 14:48:24 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C233235E1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mcgrof@kernel.org From: "Luis R. Rodriguez" To: peterz@infradead.org, paulmck@linux.vnet.ibm.com, oleg@redhat.com, josh@joshtriplett.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com Cc: paul.gortmaker@windriver.com, ebiederm@xmission.com, dmitry.torokhov@gmail.com, linux-kernel@vger.kernel.org, "Luis R. Rodriguez" Subject: [RFC v2 2/2] rcu: use idle versions of swait to make idle-hack clear Date: Thu, 15 Jun 2017 11:48:20 -0700 Message-Id: <20170615184820.22994-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170615184820.22994-1-mcgrof@kernel.org> References: <87zid92ns2.fsf@xmission.com> <20170615184820.22994-1-mcgrof@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org These RCU waits were set to use interruptible waits to avoid the kthreads contributing to system load average, even though they are not interruptible as they are spawned from a kthread. Use the new TASK_IDLE swaits which makes it clear our goal, and removes confusion about these paths possibly being interruptible -- they are not. When the system is idle the RCU grace-period kthread will spend all its time blocked inside the swait_event_interruptible(). If the interruptible() was not used, then this kthread would contribute to the load average. This means that an idle system would have a load average of 2 (or 3 if PREEMPT=y), rather than the load average of 0 that almost fifty years of UNIX has conditioned sysadms to expect. The same argument applies to swait_event_interruptible_timeout() use. The RCU grace-period kthread spends its time blocked inside this call while waiting for grace periods to complete. In particular, if there was only one busy CPU, but that CPU was frequently invoking call_rcu(), then the RCU grace-period kthread would spend almost all its time blocked inside the swait_event_interruptible_timeout(). This would mean that the load average would be 2 rather than the expected 1 for the single busy CPU. Signed-off-by: Luis R. Rodriguez --- kernel/rcu/tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 695fee7cafe0..1de8e55636c0 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2191,7 +2191,7 @@ static int __noreturn rcu_gp_kthread(void *arg) READ_ONCE(rsp->gpnum), TPS("reqwait")); rsp->gp_state = RCU_GP_WAIT_GPS; - swait_event_interruptible(rsp->gp_wq, + swait_event_idle(rsp->gp_wq, READ_ONCE(rsp->gp_flags) & RCU_GP_FLAG_INIT); rsp->gp_state = RCU_GP_DONE_GPS; @@ -2224,7 +2224,7 @@ static int __noreturn rcu_gp_kthread(void *arg) READ_ONCE(rsp->gpnum), TPS("fqswait")); rsp->gp_state = RCU_GP_WAIT_FQS; - ret = swait_event_interruptible_timeout(rsp->gp_wq, + ret = swait_event_idle_timeout(rsp->gp_wq, rcu_gp_fqs_check_wake(rsp, &gf), j); rsp->gp_state = RCU_GP_DOING_FQS; /* Locking provides needed memory barriers. */ -- 2.11.0