From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6E23360ED6 for ; Fri, 22 May 2026 07:29:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779434951; cv=none; b=kff8h+kek0zelFskCEIoyuHohQRvyVHK2qhzaBBTl3gqS88OdSmBUMFLTKF4tvKKnYuwiABdmBizRIGYaFMNU7ziWqcdLziCK6z1lELZMYO3rcM5lFQVssExM87FoBNEIF0htvxCJ6DLz037Q7tbSJO02S7KoqCiiFjWMdZl7A4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779434951; c=relaxed/simple; bh=mLIhvrDsaj6gz1EUYWPzrkIFbOJxplfGniFo4Ai0PAE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uBStMEsQ9+Ug597dMjZaJR/pL0aApmkxBCLbzRfluPqvsQGRSq/2TOUPaSh3hzQzOvfkBXH5GEV7AF3BmIupFyrcsQ2AnMeRThi975CVqypyI4ZzLmN+VN3IyZBPLmvSVmatiXaTOTxvnD04SjBnTto2iZQo5hAqHuNODT9UEzs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=XoEb35wW; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="XoEb35wW" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=KAWqDkTphm3sQXbP8Gya9wqYxs62Rt/gFMlIhmie/78=; b=XoEb35wWBnew4vuw1kbpVXybrz 0A8YoymK6sLgnfgvZ1JRMN9eA2xvsx21w/kzaarz256+4Nyz2/KcOggyACb/h1fQYwx3iKJqT7b7k UgEKkybQwgZGSrQKlG3lsSU4tm8ZLR2uBx7Iqr6/GCaoTaz95H/wOEG/aSGI0Ws+ntvT9fom10Rtn iLhkGqVvgUrhaEg1ACAtBwKcQxBE7iY3fj6R59/NgKF4p+pgN4+6ksmpF+B2tKNYsB9h50mkh3xow 3N1i0DABqe5SSsiEW/w8QCXAq6OYH9pDU9hnFucy3tvdIIuTF/sqT00gxLVO91m4F+ROjwk79PmQU S337gbiw==; Received: from 2001-1c00-8d85-4b00-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:4b00:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.99.1 #2 (Red Hat Linux)) id 1wQKJT-00000009lj8-34Sh; Fri, 22 May 2026 07:28:55 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id BE542300329; Fri, 22 May 2026 09:28:53 +0200 (CEST) Date: Fri, 22 May 2026 09:28:53 +0200 From: Peter Zijlstra To: Andrea Righi Cc: Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , Marek Szyprowski , linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched/fair: Restore RCU read lock in set_cpu_sd_state_{busy,idle}() Message-ID: <20260522072853.GL3126523@noisy.programming.kicks-ass.net> References: <20260521205115.1689545-1-arighi@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260521205115.1689545-1-arighi@nvidia.com> On Thu, May 21, 2026 at 10:51:15PM +0200, Andrea Righi wrote: > Commit c9d93a73ce87 ("sched/fair: Drop redundant RCU read lock in NOHZ > kick path") removed the rcu_read_lock()/unlock() pair from > set_cpu_sd_state_busy() and set_cpu_sd_state_idle() on the assumption > that all callers run in a safe context for rcu_dereference_all(): IRQs > disabled or cpus_write_lock() held. > > That assumption is wrong for the CPU hotplug teardown path. When CPUs > are taken offline, set_cpu_sd_state_busy() is invoked via: > > cpuhp/N kthread > cpuhp_thread_fun() > cpuhp_invoke_callback() > sched_cpu_deactivate() > nohz_balance_exit_idle() > set_cpu_sd_state_busy() > rcu_dereference_all(per_cpu(sd_llc, cpu)) > > Restore the rcu_read_lock()/unlock() pair in both helpers; > nohz_balancer_kick() is left as is, since its IRQ-disabled context is > genuinely sufficient. > > Fixes: c9d93a73ce87 ("sched/fair: Drop redundant RCU read lock in NOHZ kick path") > Reported-by: Marek Szyprowski > Closes: https://lore.kernel.org/all/38fe0a1d-1a48-435a-910a-c278024d9ac9@samsung.com/ > Signed-off-by: Andrea Righi So the obvious alternative is to disable RCU in the one caller that doesn't play ball. Was that considered? --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -8699,7 +8699,8 @@ int sched_cpu_deactivate(unsigned int cp * Remove CPU from nohz.idle_cpus_mask to prevent participating in * load balancing when not active */ - nohz_balance_exit_idle(rq); + scoped_guard (rcu) + nohz_balance_exit_idle(rq); set_cpu_active(cpu, false);