Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp878964pxb; Thu, 5 Nov 2020 15:53:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJybgopC+iQrqysRx0j1lNDE/mOBZNkthdZqMrnGH32kojvAa5ix91q99IltgWAOa4OC5AtZ X-Received: by 2002:a05:6402:143:: with SMTP id s3mr5079576edu.267.1604620404034; Thu, 05 Nov 2020 15:53:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604620404; cv=none; d=google.com; s=arc-20160816; b=lI7ZDmvsVKtBH9LQFfBsmaFAuTxBrkMoTVVGdaNYhH7ZYoRTqEky0K0Uq23wLu6vB/ UeGP8QORsn6VWv2PBDHdFMSKg8WZ8cAQcn8wz98oQt3ObUc5QP1THKSGplYfsFkfnp76 PKx7MkNdUd0WevWLTv6gxTyNx1YUWklXuJNi0oLvrpdroYIuKXxAPslvn5FE7PpZgYPK VOCLYIIUpWzgApC3CGsRND30lORb0kEdf2s5FYUC+b74ic2RNHwF6zCg/drBXCBkNhjQ KxUswVfjHGoz5boTOmi/bOf7SgXdhd/diE/hA9WkOh3ANOXKIvv6CCCxySgJP07Ywqew 3Rhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=Mt2b3Dh6LqFfnVmJLMzz6TS9Jxgtu9jPPt0xmb5I7iQ=; b=D9cNnOp34ZVSkjy66nrUah8jpgdrg28d3xhl+WMSP1frIH3ujBXLkMlv9TD60KA5Nf 57q4QxKkhlCx6jo/YSdlD6w4OEhehKBPFyTEftSafOFTDD6BayEEj4s1DTHfyzF1pVN+ DqGmQyKnGb+BxxoUDJQAAwU5dolLkc6dcA1nu0wOZr+H02D7AkbgoEpl5o3y0M28zvEp CyoDG6TzVDVJzGNzTy/e4eGefNlrqEU5YZDtL4yFUUqlyAtWzfch0a0yfbhvkQzllQ7C X0X0teyX6XW//p2D/xZlJyPmcUgjHmoF86MxYrpNL9KtFHCNvqQ1t4O3YO+orzHfl/oq Cnrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wfnrowlS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gb29si2419749ejc.439.2020.11.05.15.53.01; Thu, 05 Nov 2020 15:53:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wfnrowlS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733149AbgKEXs7 (ORCPT + 99 others); Thu, 5 Nov 2020 18:48:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:45970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732498AbgKEXrY (ORCPT ); Thu, 5 Nov 2020 18:47:24 -0500 Received: from paulmck-ThinkPad-P72.home (50-39-104-11.bvtn.or.frontiernet.net [50.39.104.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 475A82151B; Thu, 5 Nov 2020 23:47:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604620043; bh=RmqrHKJx6BYaq4MH6bNxDrXByH53ETHnBnon0isWHcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wfnrowlSUQ7MFGxQWY/ccC/2ZFvl3KPTjqXwT3OYFIfv/YtVUynz/C6e+PQFnw/yW XYgNUhekE1f5eqM2D2SPLkMO++qFi1MYMj/6q8zgDxK1mibDeI+3PV1RsA7NDrJMI7 pBfVKy0RrfZZRIgWPITewVpPirnctRtaimlbjUYQ= From: paulmck@kernel.org To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, mingo@kernel.org, jiangshanlai@gmail.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org, "Paul E. McKenney" Subject: [PATCH tip/core/rcu 04/28] torture: Periodically pause in stutter_wait() Date: Thu, 5 Nov 2020 15:46:55 -0800 Message-Id: <20201105234719.23307-4-paulmck@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20201105234658.GA23142@paulmck-ThinkPad-P72> References: <20201105234658.GA23142@paulmck-ThinkPad-P72> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Paul E. McKenney" Running locktorture scenario LOCK05 results in hangs: tools/testing/selftests/rcutorture/bin/kvm.sh --allcpus --torture lock --duration 3 --configs LOCK05 The lock_torture_writer() kthreads set themselves to MAX_NICE while running SCHED_OTHER. Other locktorture kthreads run at default niceness, also SCHED_OTHER. This results in these other locktorture kthreads indefinitely preempting the lock_torture_writer() kthreads. Note that the cond_resched() in the stutter_wait() function's loop is ineffective because this scenario is built with CONFIG_PREEMPT=y. It is not clear that such indefinite preemption is supposed to happen, but in the meantime this commit prevents kthreads running in stutter_wait() from being completely CPU-bound, thus allowing the other threads to get some CPU in a timely fashion. This commit also uses hrtimers to provide very short sleeps to avoid degrading the sudden-on testing that stutter is supposed to provide. Reviewed-by: Davidlohr Bueso Signed-off-by: Paul E. McKenney --- kernel/torture.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/kernel/torture.c b/kernel/torture.c index 1061492..5488ad2 100644 --- a/kernel/torture.c +++ b/kernel/torture.c @@ -602,8 +602,11 @@ static int stutter_gap; */ bool stutter_wait(const char *title) { - int spt; + ktime_t delay; + unsigned i = 0; + int oldnice; bool ret = false; + int spt; cond_resched_tasks_rcu_qs(); spt = READ_ONCE(stutter_pause_test); @@ -612,8 +615,17 @@ bool stutter_wait(const char *title) if (spt == 1) { schedule_timeout_interruptible(1); } else if (spt == 2) { - while (READ_ONCE(stutter_pause_test)) + oldnice = task_nice(current); + set_user_nice(current, MAX_NICE); + while (READ_ONCE(stutter_pause_test)) { + if (!(i++ & 0xffff)) { + set_current_state(TASK_INTERRUPTIBLE); + delay = 10 * NSEC_PER_USEC; + schedule_hrtimeout(&delay, HRTIMER_MODE_REL); + } cond_resched(); + } + set_user_nice(current, oldnice); } else { schedule_timeout_interruptible(round_jiffies_relative(HZ)); } -- 2.9.5