From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5757C19F2A for ; Thu, 11 Aug 2022 16:19:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237648AbiHKQTB (ORCPT ); Thu, 11 Aug 2022 12:19:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236771AbiHKQSR (ORCPT ); Thu, 11 Aug 2022 12:18:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E9F2BED; Thu, 11 Aug 2022 09:00:25 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 63BB6B82173; Thu, 11 Aug 2022 16:00:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C670EC433D7; Thu, 11 Aug 2022 16:00:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660233623; bh=T/XPVYTEQhOeweUY/f/EJxCNJvwxGVeJfXUn9bHh6k8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dlVvRo3aog7u9dd4sL0REb+haD+pV2jHTAKhFMWORKYTwat2CZRjFCFeeZHrMYwES ruqqIwKIVRjH9lvqtNmh4ftPkqgwjHMGizVZpAhV5DKOOdCPrCvAllsO2AUGhr6Dp5 sYaet5Dg+EaHEAFcaefnUEryI6ubWDedaPashAycvyEK+2xeaksWu/hKt4A6gLtMqB cJV3UI2RABcCSzjQNpWQnN9ei7DC6ZbVmAKweIOvciO7YJ5EPLG5n4OK7DsEOkJkyo 6I/2dXfNku5bDLFhxpVBcnvWboiKuBsUKXM4e8b94NI55/ZBtlGCPJPYcAByeX4/Rc 0vioJAPax4h2g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zqiang , "Paul E . McKenney" , Sasha Levin , dave@stgolabs.net, josh@joshtriplett.org, frederic@kernel.org, quic_neeraju@quicinc.com, rcu@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 33/69] rcuscale: Fix smp_processor_id()-in-preemptible warnings Date: Thu, 11 Aug 2022 11:55:42 -0400 Message-Id: <20220811155632.1536867-33-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220811155632.1536867-1-sashal@kernel.org> References: <20220811155632.1536867-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zqiang [ Upstream commit 92366810644d5675043c792abb70eaf974a77384 ] Systems built with CONFIG_DEBUG_PREEMPT=y can trigger the following BUG while running the rcuscale performance test: BUG: using smp_processor_id() in preemptible [00000000] code: rcu_scale_write/69 CPU: 0 PID: 66 Comm: rcu_scale_write Not tainted 5.18.0-rc7-next-20220517-yoctodev-standard+ caller is debug_smp_processor_id+0x17/0x20 Call Trace: dump_stack_lvl+0x49/0x5e dump_stack+0x10/0x12 check_preemption_disabled+0xdf/0xf0 debug_smp_processor_id+0x17/0x20 rcu_scale_writer+0x2b5/0x580 kthread+0x177/0x1b0 ret_from_fork+0x22/0x30 Reproduction method: runqemu kvm slirp nographic qemuparams="-m 4096 -smp 8" bootparams="isolcpus=2,3 nohz_full=2,3 rcu_nocbs=2,3 rcutree.dump_tree=1 rcuscale.shutdown=false rcuscale.gp_async=true" -d The problem is that the rcu_scale_writer() kthreads fail to set the PF_NO_SETAFFINITY flags, which causes is_percpu_thread() to assume that the kthread's affinity might change at any time, thus the BUG noted above. This commit therefore causes rcu_scale_writer() to set PF_NO_SETAFFINITY in its kthread's ->flags field, thus preventing this BUG. Signed-off-by: Zqiang Signed-off-by: Paul E. McKenney Signed-off-by: Sasha Levin --- kernel/rcu/rcuscale.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c index 2cc34a22a506..525b1687ab3e 100644 --- a/kernel/rcu/rcuscale.c +++ b/kernel/rcu/rcuscale.c @@ -399,6 +399,7 @@ rcu_scale_writer(void *arg) VERBOSE_SCALEOUT_STRING("rcu_scale_writer task started"); WARN_ON(!wdpp); set_cpus_allowed_ptr(current, cpumask_of(me % nr_cpu_ids)); + current->flags |= PF_NO_SETAFFINITY; sched_set_fifo_low(current); if (holdoff) -- 2.35.1