From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B4B8C44E665 for ; Wed, 19 Aug 2026 10:19:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787134761; cv=none; b=tr2qUVn23WGFMzbq5Rj8GlavGGlVFCm7MP0MBWLEYhoyTih+/zsBWgGDK2v1A5d7Uf89rF5SbWOGTboVhlEOFCVio7WRsS9kaMYzX1YUowYmrQ/eOz9AXemXDdYFwGxvdjBMg1ypw+Hg7wLVhVw3c9UXM+eXRuIMOQ4mMjtvvdI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787134761; c=relaxed/simple; bh=OSxsFE0vN+HGb6Pb0xkferHwFyBK67C33OR7goleXFo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=L86e+Wq21UE3k0XDcK0C6yBG9org863QKiTosdge7H4PMmcLcd16BQ4j1NZVZLrrkQle1CJmOQF2uRbOxd76j/IUmXCLVacSWt0heRCICA4AvBZ+m7SpMxYCHEtc/HPjOUCqSESKU7qG3VSwR42asC7vrlYoIyuSIsEPAEkwFW4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=qSMvZkSs; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="qSMvZkSs" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0304A153B; Wed, 19 Aug 2026 03:19:15 -0700 (PDT) Received: from [192.168.178.6] (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E91F63F66F; Wed, 19 Aug 2026 03:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1787134758; bh=OSxsFE0vN+HGb6Pb0xkferHwFyBK67C33OR7goleXFo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=qSMvZkSs50Jx3oAXh1iaxya55pBDTB6WrdHTGSRBAbu0U7nFueJLWdYV2qd0SOqWw xMnOzLRpHtHFxmnEhbbwAIGtugFstjz/AjnH7r62oAqt8wsWiu4ztah3tLXOCFr5mg oRMtATLEPgFs5jkdlMkykPI362u1JgXDGGWxJlxA= Message-ID: <6bc853d0-a30f-46e1-bf6a-963daa87cd7a@arm.com> Date: Wed, 19 Aug 2026 12:19:15 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] sched/topology: Add a cpus_read_lock to rebuild_sched_domains() To: Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org Cc: Ben Segall , Ingo Molnar , Juri Lelli , K Prateek Nayak , Mel Gorman , Peter Zijlstra , Steven Rostedt , Tim Chen , Valentin Schneider , Vincent Guittot , "chen.yu@linux.dev" , "Chen, Yu C" References: <20260813073855.ji2UrtVh@linutronix.de> Content-Language: en-GB From: Dietmar Eggemann In-Reply-To: <20260813073855.ji2UrtVh@linutronix.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 13.08.26 09:38, Sebastian Andrzej Siewior wrote: > A read from /proc/sys/kernel/sched_rt_runtime_us leads to backtrace due > to missing cpu_hotplug_lock with CONFIG_CPUSETS=n. The callchain is > sched_rt_handler() -> partition_sched_domains() -> sched_cache_set() -> > static_key_enable_cpuslocked(&sched_cache_present). > > sched_cache_set() itself is also invoked from sched_init_domains() which > is early during the boot, holding just the sched_domains_mutex_lock(). > Here is no warning because it happens before user space is running (and > hotplug operations are not possible). > > There is also sched_cache_active_set() which acquires the hotplug lock > before invoking any of the _cpuslocked() functions. > > This is only a problem with CONFIG_CPUSETS=n because in the =y case the > other implementation of rebuild_sched_domains acquires the CPU-hotplug > lock. > > Acquire CPU hotplug lock before in rebuild_sched_domains(), before > partition_sched_domains() is invoked for the CONFIG_CPUSETS=n case. > > Fixes: a7660ce1590fc ("sched/cache: Fix has_multi_llcs iff at least one partition has multiple LLCs") > Signed-off-by: Sebastian Andrzej Siewior > --- > v1…v2: https://lore.kernel.org/all/20260812095800.gl06ANul@linutronix.de/ > - Move the lock from partition_sched_domains() to > rebuild_sched_domains() in the CONFIG_CPUSETS=n since this is the > only affected case. Noticed by Yu C Chen and Tim Chen. > > include/linux/cpuset.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h > index 65d76a38974ba..bf3999daa080a 100644 > --- a/include/linux/cpuset.h > +++ b/include/linux/cpuset.h > @@ -273,6 +273,7 @@ static inline void dl_rebuild_rd_accounting(void) > > static inline void rebuild_sched_domains(void) > { > + guard(cpus_read_lock)(); > partition_sched_domains(1, NULL, NULL); > } > This also fixes the EAS specific rebuild_sched_domains_energy() case which gets invoked when we start/stop EAS e.g. while doing a CPUfreq governor change: schedutil to any other governor (e.g. ondemand). grep -h . /sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_governor schedutil schedutil schedutil schedutil schedutil schedutil for f in /sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_governor; do echo ondemand > "$f"; done [ 142.900976] ------------[ cut here ]------------ [ 142.900990] WARNING: kernel/cpu.c:527 at lockdep_assert_cpus_held+0x44/0x60, CPU#5: kworker/5:1/90 [ 142.918755] Modules linked in: [ 142.921841] CPU: 5 UID: 0 PID: 90 Comm: kworker/5:1 Not tainted 7.2.0-rc7-00035-g68e37487810a-dirty #87 PREEMPT [ 142.932059] Hardware name: ARM Juno development board (r0) (DT) [ 142.938003] Workqueue: events rebuild_sd_workfn [ 142.942572] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 142.949563] pc : lockdep_assert_cpus_held+0x44/0x60 [ 142.954473] lr : lockdep_assert_cpus_held+0x40/0x60 ... [ 143.034566] Call trace: [ 143.037025] lockdep_assert_cpus_held+0x44/0x60 (P) [ 143.041939] static_key_enable_cpuslocked+0x24/0xc8 [ 143.046857] partition_sched_domains+0x36c/0xb60 [ 143.051509] rebuild_sched_domains_energy+0x5c/0x78 ... [ 143.110230] ---[ end trace 0000000000000000 ]--- [ 143.115374] ------------[ cut here ]------------ [ 143.115384] WARNING: kernel/cpu.c:527 at lockdep_assert_cpus_held+0x44/0x60, CPU#5: kworker/5:1/90 [ 143.133300] Modules linked in: [ 143.136383] CPU: 5 UID: 0 PID: 90 Comm: kworker/5:1 Tainted: G W 7.2.0-rc7-00035-g68e37487810a-dirty #87 PREEMPT [ 143.148167] Tainted: [W]=WARN [ 143.151147] Hardware name: ARM Juno development board (r0) (DT) [ 143.157088] Workqueue: events rebuild_sd_workfn [ 143.161654] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 143.168644] pc : lockdep_assert_cpus_held+0x44/0x60 [ 143.173554] lr : lockdep_assert_cpus_held+0x40/0x60 [ 143.253643] Call trace: [ 143.256100] lockdep_assert_cpus_held+0x44/0x60 (P) [ 143.261013] _sched_cache_active_set+0x2c/0xec [ 143.265490] partition_sched_domains+0x370/0xb60 [ 143.270141] rebuild_sched_domains_energy+0x5c/0x78 ... Tested-by: Dietmar Eggemann