Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp169862rwl; Wed, 4 Jan 2023 17:11:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXulju6BDVLUR6M45oesu++bWzjQEPEb1c0sA36CssCGNQotVS1MYeSof9VUB8VrFPqL7qNr X-Received: by 2002:a17:90b:2342:b0:223:fdb2:2341 with SMTP id ms2-20020a17090b234200b00223fdb22341mr53268917pjb.27.1672881060458; Wed, 04 Jan 2023 17:11:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672881060; cv=none; d=google.com; s=arc-20160816; b=Rdfqe6+WJqr8gN9XSsEo3tMbxoNEiFV7IZZ+2SshIVXid0gaOLLtG98uRDEudejDoS cffTEYxy8gGjAj2PF5LXoCbLRn+gTIStYStH9lb1hHnPF9I84alyvnV3jBGxmPnyRjiX rLuBzaO6TwV8haisT75WEF/CAgs5TX2E0xXXq3PDkksPfl2X0FBmlwjeIsD5ZJ5V2LkI HAbcPkO+lAegJEqvKaqcYC19uBzPM3G1c77Tepp/lODAtacb9yvv0TfPtFiC2T7E2TOq Wz/2sFR1GQpsD8TDf43/QN4n0/AQW69Ft+E7v0hhA82XJQsIIQE8uskH31TaRcv56O1W gfmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nn9WsAO5D/E1K1jp4ghToueC1YLMoGTld8jyFUEEZqQ=; b=CkoV9HStBcCQeBnjvxK4nGJsbeQRcu3vILTJqDKBu1Yly5Ufz+tigHUnbzJiFJvh3b A6XH7gSb3Qy4RCiGD/Pq8cphrQGaDqC4CD4aoLMB3RpHp9NDYCMgtAih3Nf2L+mgquvb N2FI6WkVKb3eU6B1SKquRh2Q1lQxPNFJQXzXMWZl/0yzuqDgefe+tmMufdbycnKAXHJU TBiy6Dic7BnvHZ14LeQT2O3H4dLl7hc/ETlv2bvluv7ySzROF1huHuRWQy+qoFCr/5rF 1NkKDJPF6rhET6Jbast3XmuFyq2hctIYGjIiRZ80c3QPvp0nyhOBDHxbn+Y6+9Cv/K1e bsgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PnU+Yhqi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lb7-20020a17090b4a4700b002265fe84432si544792pjb.44.2023.01.04.17.10.53; Wed, 04 Jan 2023 17:11:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PnU+Yhqi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229755AbjAEAty (ORCPT + 56 others); Wed, 4 Jan 2023 19:49:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230235AbjAEAtJ (ORCPT ); Wed, 4 Jan 2023 19:49:09 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5B4E4A1B9; Wed, 4 Jan 2023 16:45:42 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 73C2D618A6; Thu, 5 Jan 2023 00:45:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DF63C433AF; Thu, 5 Jan 2023 00:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672879503; bh=ZC44hmsWKq5LKstc1mABPFNWTm5UBg7AJtRBZoxlpu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PnU+YhqiP1tuA8VdokEYO92/3U9BeI9W4Dq0q5h2Y5iyZS8lJqsEQ5XDnI7IniHBM +lRNnJrEkC93tVEJGwBiYxtskaDx3eoGzMHV4kJK4IBmvaztAoeZtX6B9OvC0xISIz BmX+CT7rWKYDK2b/16XpgMwXXf3CIwK2M7En8autzrkgHOfOI1AXBxUkzwCY+3UrHm USk+XnACWyK3SIP2l5ncBK98nB6LH8xJ6JIIZi/t04uUgtrhxhNX9xHzpEDtB39oOF em/unGNy0NyN6b9rgXJ6H5jgfrKjPEdTSxbNUCayuFeR6/BwnPxf+H86SSrs1c0QXY jJi03WbVTaFZA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id F05205C1C89; Wed, 4 Jan 2023 16:45:02 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Joel Fernandes (Google)" , Paul McKenney , Frederic Weisbecker , Zhouyi Zhou , stable@vger.kernel.org, Davidlohr Bueso Subject: [PATCH rcu 7/7] torture: Fix hang during kthread shutdown phase Date: Wed, 4 Jan 2023 16:45:01 -0800 Message-Id: <20230105004501.1771332-13-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20230105004454.GA1771168@paulmck-ThinkPad-P17-Gen-1> References: <20230105004454.GA1771168@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Joel Fernandes (Google)" During rcutorture shutdown, the rcu_torture_cleanup() function calls torture_cleanup_begin(), which sets the fullstop global variable to FULLSTOP_RMMOD. This causes the rcutorture threads for readers and fakewriters to exit all of their "while" loops and start shutting down. They then call torture_kthread_stopping(), which in turn waits for kthread_stop() to be called. However, rcu_torture_cleanup() has not yet called kthread_stop() on those threads, and before it gets a chance to do so, multiple instances of torture_kthread_stopping() invoke schedule_timeout_interruptible(1) in a tight loop. Tracing confirms that TIMER_SOFTIRQ can then continuously execute timer callbacks. If that TIMER_SOFTIRQ preempts the task executing rcu_torture_cleanup(), that task might never invoke kthread_stop(). This commit improves this situation by increasing the timeout passed to schedule_timeout_interruptible() from one jiffy to 1/20th of a second. This change prevents TIMER_SOFTIRQ from monopolizing its CPU, thus allowing rcu_torture_cleanup() to carry out the needed kthread_stop() invocations. Testing has shown 100 runs of TREE07 passing reliably, as oppose to the tens-of-percent failure rates seen beforehand. Cc: Paul McKenney Cc: Frederic Weisbecker Cc: Zhouyi Zhou Cc: # 6.0.x Signed-off-by: Joel Fernandes (Google) Tested-by: Zhouyi Zhou Reviewed-by: Davidlohr Bueso Signed-off-by: Paul E. McKenney --- kernel/torture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/torture.c b/kernel/torture.c index 29afc62f2bfec..1a0519b836ac9 100644 --- a/kernel/torture.c +++ b/kernel/torture.c @@ -915,7 +915,7 @@ void torture_kthread_stopping(char *title) VERBOSE_TOROUT_STRING(buf); while (!kthread_should_stop()) { torture_shutdown_absorb(title); - schedule_timeout_uninterruptible(1); + schedule_timeout_uninterruptible(HZ / 20); } } EXPORT_SYMBOL_GPL(torture_kthread_stopping); -- 2.31.1.189.g2e36527f23