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 784A3C25B0C for ; Thu, 11 Aug 2022 15:57:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237102AbiHKP5m (ORCPT ); Thu, 11 Aug 2022 11:57:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237090AbiHKPzn (ORCPT ); Thu, 11 Aug 2022 11:55:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE09498D16; Thu, 11 Aug 2022 08:46:39 -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 E0459B82162; Thu, 11 Aug 2022 15:46:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F702C433C1; Thu, 11 Aug 2022 15:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660232796; bh=ab1NpgsRg6Rc2IpZcFwYvCfoLl4CqmgM/POgnNTq2rg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rT54BLhUjOHAEJht+EEF805sP5zdTaLlHwbEZLFFeiOpY0eToKw9zVy0p48KJSWTM hqwOh2vY4Wko0VCb+qXUz3SRUiBAkM4LP1toYdSVK0huY/gsCEoOCtuaGYj0wHsfe/ GnMwCmnqUh19i9I+kZBiyA4VKgKiDN2YZFdP1/OQnaLnIB+QBe/XdqkpafQRHE7ts0 B4ls6gvGhsEpVyvY6T/v7PPBo2ll/DxopSaiYBdXXUklQ7649DDZKmimnJEzob8Kkm rPctO0roG4EyDafM6qO3w0JN72mLVAaOMxYP7iUmETWDImfclG7EQHTiwkMAV6MAZo GpFvR5JAM8wJg== 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.18 38/93] rcuscale: Fix smp_processor_id()-in-preemptible warnings Date: Thu, 11 Aug 2022 11:41:32 -0400 Message-Id: <20220811154237.1531313-38-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220811154237.1531313-1-sashal@kernel.org> References: <20220811154237.1531313-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: stable@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 5e4f1f83d38e..fefaeda87de1 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