[v2] rcutorture: Convert schedule_timeout_uninterruptible() to mdelay() in rcu_torture_stall()
Message ID | 20230320032422.4010801-1-qiang1.zhang@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1002424wrt; Sun, 19 Mar 2023 20:55:46 -0700 (PDT) X-Google-Smtp-Source: AK7set8SpAHltYzYtwuwoEkdK/3lWOp0GyDc4koE2uBCT6XJP76D8IZdAJ58X8ZPhYXqJAdlMwx/ X-Received: by 2002:a05:6a21:7882:b0:d9:ec4b:82c5 with SMTP id bf2-20020a056a21788200b000d9ec4b82c5mr736200pzc.1.1679284546514; Sun, 19 Mar 2023 20:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679284546; cv=none; d=google.com; s=arc-20160816; b=WfsuA8Uyr/1VIl7X71ZzlILKs0tBM3GOB1qIzc+I1AZjagTY1YEuMO7lR22AUq5h6t 2wy4QJAb+/3ufsEjV/gQ6dryXoBgbeJIuxXUPOWnGU1tcKJnGq1RSVu+/fS0mnMXbNcr wBE5UiqRzc8DIEfK+/faUfXXbfIasY+ubBmlHppUiEpDgykqlS4PSZ4qDKcAVl7+c1pV 3TzhP2DCbosjImjpqOgEw3G0O9DVlM4iLbRM4X81ofb5m4SfWXW8APvArX2dUPbb5aTk z+zFpRZEdnft5XsJ+6H+MqjmLOqVvZSqvQcC4ShBeWrx8dmbpql/d7EeCwZEh/la4ENT xxNA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=r7bRRNy5n6BTKJEwvpiWYUJLWPHeJ46YERst3Xfsj2c=; b=fBQi/HTJ5rbDDOr0VWQd4oVYhSvVE4/LQLxBIYy7PgI8WfFYJS7usK3a0GfcTuu/px 0LVFFnak7Vgz/d0Xy1oXwLcBIUADyS28WevpekKcYNGTNiocv5d34wWjn4S3+edze3gN wkodQN+VQPDSWE792GUuMGxs7eIYQs1uVJYMxRQiIcuv7BLFILdtRHUU7btbAEnnVOTG Xo40jqqomXxRRHuNdjKGi9aNHgbsAVodvL/jY7LPPW4jLkYlplqWFjgRzzuIJgkdGZrM q2FEyxpQrRnEou4zHT22WE1DhOH7FSpPRGZ+JfTNnFldBjlHIdIt4EZIyWvXfu6gIuDq qfoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QJ5+Kqwe; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t16-20020a63f350000000b005098d6245b6si7526050pgj.151.2023.03.19.20.55.32; Sun, 19 Mar 2023 20:55:46 -0700 (PDT) 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=@intel.com header.s=Intel header.b=QJ5+Kqwe; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229837AbjCTDT7 (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Sun, 19 Mar 2023 23:19:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229841AbjCTDTv (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 19 Mar 2023 23:19:51 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13681168A9; Sun, 19 Mar 2023 20:19:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679282387; x=1710818387; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Y/3oX6k69l7HpvCmddKmZ0LkHuSXoSFxCBBErt+mKrU=; b=QJ5+KqwesqfuYsrmzFnJ8OeyOCYLT0YOCXHMSFHvXoXmXRJcM7mrKN4d gLCJ35VtZvZLqPHrPB1DwzxN+J9p2xvNvANWuUyk50iq/4i89CXR/cXuG PXlYrxrsdZaMipvsD4lryLMjlXs0NYf4E9OMySVdAUlPCCjEk9G1ZG7vl dlUYfpefKmHmySbFuBr19NmOCsFZLa7BcasCdlvbHqNeQjNVroodmTPe+ qXWWjxKNg3tqFy0p1MGl8xOyQQczd6LhjaXKNoH7HvDQ9EA/wOqDS+MDU fzg3c2A/uPOo/v7Mb0zylG/1QdNdSj9/rBQk7jLgRJF+4kTWCvyJDl47y g==; X-IronPort-AV: E=McAfee;i="6600,9927,10654"; a="337280867" X-IronPort-AV: E=Sophos;i="5.98,274,1673942400"; d="scan'208";a="337280867" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Mar 2023 20:19:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10654"; a="770032018" X-IronPort-AV: E=Sophos;i="5.98,274,1673942400"; d="scan'208";a="770032018" Received: from zq-optiplex-7090.bj.intel.com ([10.238.156.129]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Mar 2023 20:19:45 -0700 From: Zqiang <qiang1.zhang@intel.com> To: paulmck@kernel.org, frederic@kernel.org, joel@joelfernandes.org Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] rcutorture: Convert schedule_timeout_uninterruptible() to mdelay() in rcu_torture_stall() Date: Mon, 20 Mar 2023 11:24:22 +0800 Message-Id: <20230320032422.4010801-1-qiang1.zhang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760857472651532049?= X-GMAIL-MSGID: =?utf-8?q?1760857472651532049?= |
Series |
[v2] rcutorture: Convert schedule_timeout_uninterruptible() to mdelay() in rcu_torture_stall()
|
|
Commit Message
Zqiang
March 20, 2023, 3:24 a.m. UTC
For kernels built with enable PREEMPT_NONE and CONFIG_DEBUG_ATOMIC_SLEEP,
running the RCU stall tests.
runqemu kvm slirp nographic qemuparams="-m 1024 -smp 4"
bootparams="nokaslr console=ttyS0 rcutorture.stall_cpu=30
rcutorture.stall_no_softlockup=1 rcutorture.stall_cpu_irqsoff=1
rcutorture.stall_cpu_block=1" -d
[ 10.841071] rcu-torture: rcu_torture_stall begin CPU stall
[ 10.841073] rcu_torture_stall start on CPU 3.
[ 10.841077] BUG: scheduling while atomic: rcu_torture_sta/66/0x0000000
....
[ 10.841108] Call Trace:
[ 10.841110] <TASK>
[ 10.841112] dump_stack_lvl+0x64/0xb0
[ 10.841118] dump_stack+0x10/0x20
[ 10.841121] __schedule_bug+0x8b/0xb0
[ 10.841126] __schedule+0x2172/0x2940
[ 10.841157] schedule+0x9b/0x150
[ 10.841160] schedule_timeout+0x2e8/0x4f0
[ 10.841192] schedule_timeout_uninterruptible+0x47/0x50
[ 10.841195] rcu_torture_stall+0x2e8/0x300
[ 10.841199] kthread+0x175/0x1a0
[ 10.841206] ret_from_fork+0x2c/0x50
The above calltrace occurs in the local_irq_disable/enable() critical
section call schedule_timeout(), and invoke schedule_timeout() also
implies a quiescent state, of course it also fails to trigger RCU stall,
this commit therefore use mdelay() instead of schedule_timeout() to
trigger RCU stall.
Suggested-by: Joel Fernandes <joel@joelfernandes.org>
Signed-off-by: Zqiang <qiang1.zhang@intel.com>
---
kernel/rcu/rcutorture.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hi Qiang, > From: Zqiang <qiang1.zhang@intel.com> > Sent: Monday, March 20, 2023 11:24 AM > To: paulmck@kernel.org; frederic@kernel.org; joel@joelfernandes.org > Cc: rcu@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: [PATCH v2] rcutorture: Convert schedule_timeout_uninterruptible() > to mdelay() in rcu_torture_stall() > > For kernels built with enable PREEMPT_NONE and s/enable/enabling/ > CONFIG_DEBUG_ATOMIC_SLEEP, running the RCU stall tests. s/running/run > > runqemu kvm slirp nographic qemuparams="-m 1024 -smp 4" > bootparams="nokaslr console=ttyS0 rcutorture.stall_cpu=30 > rcutorture.stall_no_softlockup=1 rcutorture.stall_cpu_irqsoff=1 > rcutorture.stall_cpu_block=1" -d > > [ 10.841071] rcu-torture: rcu_torture_stall begin CPU stall > [ 10.841073] rcu_torture_stall start on CPU 3. > [ 10.841077] BUG: scheduling while atomic: rcu_torture_sta/66/0x0000000 > .... > [ 10.841108] Call Trace: > [ 10.841110] <TASK> > [ 10.841112] dump_stack_lvl+0x64/0xb0 > [ 10.841118] dump_stack+0x10/0x20 > [ 10.841121] __schedule_bug+0x8b/0xb0 > [ 10.841126] __schedule+0x2172/0x2940 > [ 10.841157] schedule+0x9b/0x150 > [ 10.841160] schedule_timeout+0x2e8/0x4f0 > [ 10.841192] schedule_timeout_uninterruptible+0x47/0x50 > [ 10.841195] rcu_torture_stall+0x2e8/0x300 > [ 10.841199] kthread+0x175/0x1a0 > [ 10.841206] ret_from_fork+0x2c/0x50 > > The above calltrace occurs in the local_irq_disable/enable() critical section > call schedule_timeout(), and invoke schedule_timeout() also implies a > quiescent state, of course it also fails to trigger RCU stall, this commit > therefore use mdelay() instead of schedule_timeout() to trigger RCU stall. Tweak the commit description above to fix some grammar errors: The above call trace occurred in the local_irq_disable/enable() critical section when calling schedule_timeout() from rcu_torture_stall(). Invoking schedule_timeout() also implies a quiescent state, of course, it also fails to trigger RCU stall. This commit, therefore, uses mdelay() instead of schedule_timeout() to trigger the RCU stall. > Suggested-by: Joel Fernandes <joel@joelfernandes.org> > Signed-off-by: Zqiang <qiang1.zhang@intel.com> I didn't reproduce the call trace after applying your patch. So, with the above minor fixes, then Tested-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com> Thanks -Qiuxu > --- > kernel/rcu/rcutorture.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index > d06c2da04c34..a08a72bef5f1 100644 > --- a/kernel/rcu/rcutorture.c > +++ b/kernel/rcu/rcutorture.c > @@ -2472,7 +2472,7 @@ static int rcu_torture_stall(void *args) #ifdef > CONFIG_PREEMPTION > preempt_schedule(); > #else > - schedule_timeout_uninterruptible(HZ); > + mdelay(jiffies_to_msecs(HZ)); > #endif > } else if (stall_no_softlockup) { > touch_softlockup_watchdog(); > -- > 2.25.1
On Mon, Mar 20, 2023 at 11:24:22AM +0800, Zqiang wrote: > For kernels built with enable PREEMPT_NONE and CONFIG_DEBUG_ATOMIC_SLEEP, > running the RCU stall tests. > > runqemu kvm slirp nographic qemuparams="-m 1024 -smp 4" > bootparams="nokaslr console=ttyS0 rcutorture.stall_cpu=30 > rcutorture.stall_no_softlockup=1 rcutorture.stall_cpu_irqsoff=1 > rcutorture.stall_cpu_block=1" -d > > [ 10.841071] rcu-torture: rcu_torture_stall begin CPU stall > [ 10.841073] rcu_torture_stall start on CPU 3. > [ 10.841077] BUG: scheduling while atomic: rcu_torture_sta/66/0x0000000 > .... > [ 10.841108] Call Trace: > [ 10.841110] <TASK> > [ 10.841112] dump_stack_lvl+0x64/0xb0 > [ 10.841118] dump_stack+0x10/0x20 > [ 10.841121] __schedule_bug+0x8b/0xb0 > [ 10.841126] __schedule+0x2172/0x2940 > [ 10.841157] schedule+0x9b/0x150 > [ 10.841160] schedule_timeout+0x2e8/0x4f0 > [ 10.841192] schedule_timeout_uninterruptible+0x47/0x50 > [ 10.841195] rcu_torture_stall+0x2e8/0x300 > [ 10.841199] kthread+0x175/0x1a0 > [ 10.841206] ret_from_fork+0x2c/0x50 > > The above calltrace occurs in the local_irq_disable/enable() critical > section call schedule_timeout(), and invoke schedule_timeout() also > implies a quiescent state, of course it also fails to trigger RCU stall, > this commit therefore use mdelay() instead of schedule_timeout() to > trigger RCU stall. > > Suggested-by: Joel Fernandes <joel@joelfernandes.org> > Signed-off-by: Zqiang <qiang1.zhang@intel.com> > --- > kernel/rcu/rcutorture.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c > index d06c2da04c34..a08a72bef5f1 100644 > --- a/kernel/rcu/rcutorture.c > +++ b/kernel/rcu/rcutorture.c > @@ -2472,7 +2472,7 @@ static int rcu_torture_stall(void *args) Right here there is: if (stall_cpu_block) { In other words, the rcutorture.stall_cpu_block module parameter says to block, even if it is a bad thing to do. The point of this is to verify the error messages that are supposed to be printed on the console when this happens. > #ifdef CONFIG_PREEMPTION > preempt_schedule(); > #else > - schedule_timeout_uninterruptible(HZ); > + mdelay(jiffies_to_msecs(HZ)); So this really needs to stay schedule_timeout_uninterruptible(HZ). So should there be a change to kernel-parameters.txt to make it more clear that this is intended behavior? Thanx, Paul > #endif > } else if (stall_no_softlockup) { > touch_softlockup_watchdog(); > -- > 2.25.1 >
> For kernels built with enable PREEMPT_NONE and CONFIG_DEBUG_ATOMIC_SLEEP, > running the RCU stall tests. > > runqemu kvm slirp nographic qemuparams="-m 1024 -smp 4" > bootparams="nokaslr console=ttyS0 rcutorture.stall_cpu=30 > rcutorture.stall_no_softlockup=1 rcutorture.stall_cpu_irqsoff=1 > rcutorture.stall_cpu_block=1" -d > > [ 10.841071] rcu-torture: rcu_torture_stall begin CPU stall > [ 10.841073] rcu_torture_stall start on CPU 3. > [ 10.841077] BUG: scheduling while atomic: rcu_torture_sta/66/0x0000000 > .... > [ 10.841108] Call Trace: > [ 10.841110] <TASK> > [ 10.841112] dump_stack_lvl+0x64/0xb0 > [ 10.841118] dump_stack+0x10/0x20 > [ 10.841121] __schedule_bug+0x8b/0xb0 > [ 10.841126] __schedule+0x2172/0x2940 > [ 10.841157] schedule+0x9b/0x150 > [ 10.841160] schedule_timeout+0x2e8/0x4f0 > [ 10.841192] schedule_timeout_uninterruptible+0x47/0x50 > [ 10.841195] rcu_torture_stall+0x2e8/0x300 > [ 10.841199] kthread+0x175/0x1a0 > [ 10.841206] ret_from_fork+0x2c/0x50 > > The above calltrace occurs in the local_irq_disable/enable() critical > section call schedule_timeout(), and invoke schedule_timeout() also > implies a quiescent state, of course it also fails to trigger RCU stall, > this commit therefore use mdelay() instead of schedule_timeout() to > trigger RCU stall. > > Suggested-by: Joel Fernandes <joel@joelfernandes.org> > Signed-off-by: Zqiang <qiang1.zhang@intel.com> > --- > kernel/rcu/rcutorture.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c > index d06c2da04c34..a08a72bef5f1 100644 > --- a/kernel/rcu/rcutorture.c > +++ b/kernel/rcu/rcutorture.c > @@ -2472,7 +2472,7 @@ static int rcu_torture_stall(void *args) > >Right here there is: > > if (stall_cpu_block) { > >In other words, the rcutorture.stall_cpu_block module parameter says to >block, even if it is a bad thing to do. The point of this is to verify >the error messages that are supposed to be printed on the console when >this happens. > > #ifdef CONFIG_PREEMPTION > preempt_schedule(); > #else > - schedule_timeout_uninterruptible(HZ); > + mdelay(jiffies_to_msecs(HZ)); > >So this really needs to stay schedule_timeout_uninterruptible(HZ). But invoke schedule_timeout_uninterruptible(HZ) implies a quiescent state, this will not cause an RCU stall to occur, and still in the RCU read critical section(PREEMPT_COUNT=y). It didn't happen RCU stall when I tested with the following parameters for rcutorture.stall_cpu=30 rcutorture.stall_no_softlockup=1 rcutorture.stall_cpu_irqsoff=1 rcutorture.stall_cpu_block=1 Thanks Zqiang > >So should there be a change to kernel-parameters.txt to make it >more clear that this is intended behavior? > > Thanx, Paul > > #endif > } else if (stall_no_softlockup) { > touch_softlockup_watchdog(); > -- > 2.25.1 >
On Mon, Mar 20, 2023 at 11:05:17PM +0000, Zhang, Qiang1 wrote: > > For kernels built with enable PREEMPT_NONE and CONFIG_DEBUG_ATOMIC_SLEEP, > > running the RCU stall tests. > > > > runqemu kvm slirp nographic qemuparams="-m 1024 -smp 4" > > bootparams="nokaslr console=ttyS0 rcutorture.stall_cpu=30 > > rcutorture.stall_no_softlockup=1 rcutorture.stall_cpu_irqsoff=1 > > rcutorture.stall_cpu_block=1" -d > > > > [ 10.841071] rcu-torture: rcu_torture_stall begin CPU stall > > [ 10.841073] rcu_torture_stall start on CPU 3. > > [ 10.841077] BUG: scheduling while atomic: rcu_torture_sta/66/0x0000000 > > .... > > [ 10.841108] Call Trace: > > [ 10.841110] <TASK> > > [ 10.841112] dump_stack_lvl+0x64/0xb0 > > [ 10.841118] dump_stack+0x10/0x20 > > [ 10.841121] __schedule_bug+0x8b/0xb0 > > [ 10.841126] __schedule+0x2172/0x2940 > > [ 10.841157] schedule+0x9b/0x150 > > [ 10.841160] schedule_timeout+0x2e8/0x4f0 > > [ 10.841192] schedule_timeout_uninterruptible+0x47/0x50 > > [ 10.841195] rcu_torture_stall+0x2e8/0x300 > > [ 10.841199] kthread+0x175/0x1a0 > > [ 10.841206] ret_from_fork+0x2c/0x50 > > > > The above calltrace occurs in the local_irq_disable/enable() critical > > section call schedule_timeout(), and invoke schedule_timeout() also > > implies a quiescent state, of course it also fails to trigger RCU stall, > > this commit therefore use mdelay() instead of schedule_timeout() to > > trigger RCU stall. > > > > Suggested-by: Joel Fernandes <joel@joelfernandes.org> > > Signed-off-by: Zqiang <qiang1.zhang@intel.com> > > --- > > kernel/rcu/rcutorture.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c > > index d06c2da04c34..a08a72bef5f1 100644 > > --- a/kernel/rcu/rcutorture.c > > +++ b/kernel/rcu/rcutorture.c > > @@ -2472,7 +2472,7 @@ static int rcu_torture_stall(void *args) > > > >Right here there is: > > > > if (stall_cpu_block) { > > > >In other words, the rcutorture.stall_cpu_block module parameter says to > >block, even if it is a bad thing to do. The point of this is to verify > >the error messages that are supposed to be printed on the console when > >this happens. > > > > #ifdef CONFIG_PREEMPTION > > preempt_schedule(); > > #else > > - schedule_timeout_uninterruptible(HZ); > > + mdelay(jiffies_to_msecs(HZ)); > > > >So this really needs to stay schedule_timeout_uninterruptible(HZ). > > But invoke schedule_timeout_uninterruptible(HZ) implies a quiescent state, > this will not cause an RCU stall to occur, and still in the RCU read critical section(PREEMPT_COUNT=y). > > It didn't happen RCU stall when I tested with the following parameters for > rcutorture.stall_cpu=30 > rcutorture.stall_no_softlockup=1 > rcutorture.stall_cpu_irqsoff=1 > rcutorture.stall_cpu_block=1 Understood. If you want that RCU CPU stall in a CONFIG_PREEMPTION=n kernel, you should not use rcutorture.stall_cpu_block=1. In a CONFIG_PREEMPTION=y kernel, rcutorture.stall_cpu_block=1 forces the grace period to be stalled on a task rather than a CPU, exercising a different part of the RCU CPU stall warning code. In a CONFIG_PREEMPTION=n kernel, using rcutorture.stall_cpu_block=1 forces the CPU to go through a quiescent state, as you say. It can also cause lockdep and scheduling-while-atomic complaints, depending on exactly what type of RCU reader is in effect. So these are test-the-diagnostics parameters. The mdelay() instead makes rcutorture.stall_cpu_block=1 do the same thing as does rcutorture.stall_cpu_block=0 for CONFIG_PREEMPTION=n kernels, right? Thanx, Paul > Thanks > Zqiang > > > > >So should there be a change to kernel-parameters.txt to make it > >more clear that this is intended behavior? > > > > Thanx, Paul > > > > #endif > > } else if (stall_no_softlockup) { > > touch_softlockup_watchdog(); > > -- > > 2.25.1 > >
> > For kernels built with enable PREEMPT_NONE and CONFIG_DEBUG_ATOMIC_SLEEP, > > running the RCU stall tests. > > > > runqemu kvm slirp nographic qemuparams="-m 1024 -smp 4" > > bootparams="nokaslr console=ttyS0 rcutorture.stall_cpu=30 > > rcutorture.stall_no_softlockup=1 rcutorture.stall_cpu_irqsoff=1 > > rcutorture.stall_cpu_block=1" -d > > > > [ 10.841071] rcu-torture: rcu_torture_stall begin CPU stall > > [ 10.841073] rcu_torture_stall start on CPU 3. > > [ 10.841077] BUG: scheduling while atomic: rcu_torture_sta/66/0x0000000 > > .... > > [ 10.841108] Call Trace: > > [ 10.841110] <TASK> > > [ 10.841112] dump_stack_lvl+0x64/0xb0 > > [ 10.841118] dump_stack+0x10/0x20 > > [ 10.841121] __schedule_bug+0x8b/0xb0 > > [ 10.841126] __schedule+0x2172/0x2940 > > [ 10.841157] schedule+0x9b/0x150 > > [ 10.841160] schedule_timeout+0x2e8/0x4f0 > > [ 10.841192] schedule_timeout_uninterruptible+0x47/0x50 > > [ 10.841195] rcu_torture_stall+0x2e8/0x300 > > [ 10.841199] kthread+0x175/0x1a0 > > [ 10.841206] ret_from_fork+0x2c/0x50 > > > > The above calltrace occurs in the local_irq_disable/enable() critical > > section call schedule_timeout(), and invoke schedule_timeout() also > > implies a quiescent state, of course it also fails to trigger RCU stall, > > this commit therefore use mdelay() instead of schedule_timeout() to > > trigger RCU stall. > > > > Suggested-by: Joel Fernandes <joel@joelfernandes.org> > > Signed-off-by: Zqiang <qiang1.zhang@intel.com> > > --- > > kernel/rcu/rcutorture.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c > > index d06c2da04c34..a08a72bef5f1 100644 > > --- a/kernel/rcu/rcutorture.c > > +++ b/kernel/rcu/rcutorture.c > > @@ -2472,7 +2472,7 @@ static int rcu_torture_stall(void *args) > > > >Right here there is: > > > > if (stall_cpu_block) { > > > >In other words, the rcutorture.stall_cpu_block module parameter says to > >block, even if it is a bad thing to do. The point of this is to verify > >the error messages that are supposed to be printed on the console when > >this happens. > > > > #ifdef CONFIG_PREEMPTION > > preempt_schedule(); > > #else > > - schedule_timeout_uninterruptible(HZ); > > + mdelay(jiffies_to_msecs(HZ)); > > > >So this really needs to stay schedule_timeout_uninterruptible(HZ). > > But invoke schedule_timeout_uninterruptible(HZ) implies a quiescent state, > this will not cause an RCU stall to occur, and still in the RCU read critical section(PREEMPT_COUNT=y). > > It didn't happen RCU stall when I tested with the following parameters for > rcutorture.stall_cpu=30 > rcutorture.stall_no_softlockup=1 > rcutorture.stall_cpu_irqsoff=1 > rcutorture.stall_cpu_block=1 > >Understood. If you want that RCU CPU stall in a CONFIG_PREEMPTION=n >kernel, you should not use rcutorture.stall_cpu_block=1. > >In a CONFIG_PREEMPTION=y kernel, rcutorture.stall_cpu_block=1 forces >the grace period to be stalled on a task rather than a CPU, exercising >a different part of the RCU CPU stall warning code. > >In a CONFIG_PREEMPTION=n kernel, using rcutorture.stall_cpu_block=1 >forces the CPU to go through a quiescent state, as you say. It can >also cause lockdep and scheduling-while-atomic complaints, depending on >exactly what type of RCU reader is in effect. > >So these are test-the-diagnostics parameters. The mdelay() instead >makes rcutorture.stall_cpu_block=1 do the same thing as does >rcutorture.stall_cpu_block=0 for CONFIG_PREEMPTION=n kernels, right? Yes, maybe we can increase the description of the stall_cpu_block in kernel-parameters.txt. > > Thanx, Paul > > Thanks > Zqiang > > > > >So should there be a change to kernel-parameters.txt to make it > >more clear that this is intended behavior? Agree Thanks Zqiang > > > > Thanx, Paul > > > > #endif > > } else if (stall_no_softlockup) { > > touch_softlockup_watchdog(); > > -- > > 2.25.1 > >
> From: Paul E. McKenney <paulmck@kernel.org> > [...] > > But invoke schedule_timeout_uninterruptible(HZ) implies a quiescent > > state, this will not cause an RCU stall to occur, and still in the RCU read > critical section(PREEMPT_COUNT=y). > > > > It didn't happen RCU stall when I tested with the following parameters > > for > > rcutorture.stall_cpu=30 > > rcutorture.stall_no_softlockup=1 > > rcutorture.stall_cpu_irqsoff=1 > > rcutorture.stall_cpu_block=1 > > Understood. If you want that RCU CPU stall in a CONFIG_PREEMPTION=n > kernel, you should not use rcutorture.stall_cpu_block=1. > Verified. if rcutorture.stall_cpu_block=0, it can trigger the expected RCU CPU stall for either torture_type=srcu or torture_type=rcu. > In a CONFIG_PREEMPTION=y kernel, rcutorture.stall_cpu_block=1 forces the > grace period to be stalled on a task rather than a CPU, exercising a different > part of the RCU CPU stall warning code. > > In a CONFIG_PREEMPTION=n kernel, using rcutorture.stall_cpu_block=1 > forces the CPU to go through a quiescent state, as you say. It can also cause > lockdep and scheduling-while-atomic complaints, depending on exactly what > type of RCU reader is in effect. > Verified. If rcutorture.stall_cpu_block=1: There were lockdep and scheduling-while-atomic complaints for torture_type=rcu. No lockdep and scheduling-while-atomic complaints for torture_type=srcu. > So these are test-the-diagnostics parameters. The mdelay() instead makes > rcutorture.stall_cpu_block=1 do the same thing as does > rcutorture.stall_cpu_block=0 for CONFIG_PREEMPTION=n kernels, right? Good to know that these are test-the-diagnostics parameters and their expected behaviors. ;-) Thanks! -Qiuxu > Thanx, Paul
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index d06c2da04c34..a08a72bef5f1 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2472,7 +2472,7 @@ static int rcu_torture_stall(void *args) #ifdef CONFIG_PREEMPTION preempt_schedule(); #else - schedule_timeout_uninterruptible(HZ); + mdelay(jiffies_to_msecs(HZ)); #endif } else if (stall_no_softlockup) { touch_softlockup_watchdog();