Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp877734pxb; Thu, 5 Nov 2020 15:50:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqigw0BksT+l2lqZeJ68DhfFz6GmuJoJhHWh9Bs1k1KkP/A9GWmu1TFeU5UqUah800A3Cg X-Received: by 2002:a05:6402:1119:: with SMTP id u25mr5495189edv.37.1604620232823; Thu, 05 Nov 2020 15:50:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604620232; cv=none; d=google.com; s=arc-20160816; b=DuBg4wXNxV88hp9XOcnxI1TUKQ998mKVmkvtX/qzOy1asFfa8HkNPuwa7gT6Hjbn8G qtIw3fHICW9K6OQ2qSUrek5Azv+nZt5bf9ZWKGcI7RJ8dioAdgs6dBivEQ1tjSJGVsTN noorjZfVIroYV32FNOmcAXBDlzhIT3SKu4ZWEBZphBAFqb887MsjXVPsl79+9iQJ4FDW onHpMQsO34BQTZkx7pxo1vR9dvYT5Zd+fPMotvnNz89uLhXjbqPXCoKBdLbO6Y7UKyxT fi0CnOkU5PV1PUuHepsvH8gMqGFTW6y46b1gEBdjmKuaxJxsUm7jHSJXtynPGmUuIfj4 8NTQ== 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=nsbTZr0+y2eq8wZpZaLX+y0zJprmDKD5xgUaf9vb3QU=; b=w6vXhIz9h+m3AoJjQpSoYduntHUKbM51mNHxBKFfVU9tfi/pgb3peDuP6w5zLVSoHr GLRGBFfDDHqD66LMeOwxPb5fBLScMsxYK0VSKyHLL9Gyc0+xovtV2gn5x8QBi0OwqwfG PdyxbNoR6WsGB8WFYilT9fXHSur4xnhlLlhlm0XXh2jOpPqgtNz+AjpsW/DGTnZnPy+Y OvmMlxT0qVBlFjijqyjmsfdYteE12Nk0bQe7BLjzA7QI11L3/kFYZo4zPM70m62fWO+S fTZNT6jkkaeIWsfGzsYW574FwcAXZa1w6pUIiE9TBTkY6fPKem1XE0e02CtnuVL7RCrb h6FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TRlObfci; 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 v8si2500974edi.25.2020.11.05.15.50.10; Thu, 05 Nov 2020 15:50:32 -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=TRlObfci; 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 S1732820AbgKEXrc (ORCPT + 99 others); Thu, 5 Nov 2020 18:47:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:45930 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732591AbgKEXrY (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 A964F217A0; 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=8dAvn0YKpaz7R2OElvDxDCJwZrTX1on4SeZcENj0nOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TRlObfciPu0Cyo7hxhJdSgMCmQsK8Xo5ljFZbNAKSBMaiauNSmk92uqfCVLxN+zn6 VI5ga2/UMvWo3xbggwyC9AWXhYW/RqUGK2a+rYxOgzlVd0/GReIziw83A1EcPkk/yl Lo/f5+2nNuq1N+k94FT1I12p/TaOhEc9Hy/MOow8= 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 05/28] torture: Make torture_stutter() use hrtimer Date: Thu, 5 Nov 2020 15:46:56 -0800 Message-Id: <20201105234719.23307-5-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" The torture_stutter() function uses schedule_timeout_interruptible() to time the stutter duration, but this can miss race conditions due to its being time-synchronized with everything else that is based on the timer wheels. This commit therefore converts torture_stutter() to use the high-resolution timers via schedule_hrtimeout(), and also to fuzz the stutter interval. While in the area, this commit also limits the spin-loop portion of the stutter_wait() function's wait loop to two jiffies, down from about one second. Signed-off-by: Paul E. McKenney --- kernel/torture.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/kernel/torture.c b/kernel/torture.c index 5488ad2..d8bdd9a 100644 --- a/kernel/torture.c +++ b/kernel/torture.c @@ -641,20 +641,27 @@ EXPORT_SYMBOL_GPL(stutter_wait); */ static int torture_stutter(void *arg) { + ktime_t delay; + DEFINE_TORTURE_RANDOM(rand); int wtime; VERBOSE_TOROUT_STRING("torture_stutter task started"); do { if (!torture_must_stop() && stutter > 1) { wtime = stutter; - if (stutter > HZ + 1) { + if (stutter > 2) { WRITE_ONCE(stutter_pause_test, 1); - wtime = stutter - HZ - 1; - schedule_timeout_interruptible(wtime); - wtime = HZ + 1; + wtime = stutter - 3; + delay = ktime_divns(NSEC_PER_SEC * wtime, HZ); + delay += (torture_random(&rand) >> 3) % NSEC_PER_MSEC; + set_current_state(TASK_INTERRUPTIBLE); + schedule_hrtimeout(&delay, HRTIMER_MODE_REL); + wtime = 2; } WRITE_ONCE(stutter_pause_test, 2); - schedule_timeout_interruptible(wtime); + delay = ktime_divns(NSEC_PER_SEC * wtime, HZ); + set_current_state(TASK_INTERRUPTIBLE); + schedule_hrtimeout(&delay, HRTIMER_MODE_REL); } WRITE_ONCE(stutter_pause_test, 0); if (!torture_must_stop()) -- 2.9.5