From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1CB91262FFC; Thu, 1 Jan 2026 22:14:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305661; cv=none; b=o5YqJkRXc9AHFryX0Rw9ccsZ44ydXcjxHykbaVNOSeZcApA4XiIjo0BC8mwELMB46oaHhK1OVbNRsqIg6rtiH0r193nP3tQlVFc8E2thZC3UlsR09KbCb2ArkhSC2e0AEgWG7wYCgVEAEOpTur2mDD5SQa5DC6QD1TFP502gQ2U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305661; c=relaxed/simple; bh=geZF3QKFtYPcfbMIoxTZal+ERqEQTyvZvD0QQardL9c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MZnvWzpvHJcMDKftaPDiyGS68gSdiqx8/UfyxJKPKNDbIyFXwOxkLdmwCB+BKaKGXPS5EhTHxwiSf+19ZCLuz6J9nU94KeCE2T+d0YilRUlIe0K6VsBlBOWoBS1ca8OxqXKYsuRLLqNO8Y+DPkaA2g059DmhQc5vaCzuUWHMC7E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M/h534ng; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M/h534ng" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA78FC116D0; Thu, 1 Jan 2026 22:14:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305660; bh=geZF3QKFtYPcfbMIoxTZal+ERqEQTyvZvD0QQardL9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M/h534ngFuoRJjvdoJJs2OZzukd06FtL2b5SAxHmZGEKCcB5XuVr8mfuQGjBLJsFV Y/7VKrO44T9eNaMva+lwmWkTy479Lcrcv/2HGBDUj4lTItky5lI+2cgRYQ/VLzdBca Cy68hBnhExv7MBlWAh93Lxqo1XjRIj64jory4FE81jhU38SrAXzzpnThpMIqZzhFLl kvr/0tx7QmlEf0cYDudigYL2RH06h8zTlBiTPPP2SoA1qoLDHZH+zDUgUWXnLtJuLB Y7Ov4x5UmpafKNXoKqSDA4oQtkfIIA1x++LXWUXeQ1k8TS+JP8ZLl4zLeLyXhVYRVW 4UJvD8KxVhjqA== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 01/33] PCI: Prepare to protect against concurrent isolated cpuset change Date: Thu, 1 Jan 2026 23:13:26 +0100 Message-ID: <20260101221359.22298-2-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" HK_TYPE_DOMAIN will soon integrate cpuset isolated partitions and therefore be made modifiable at runtime. Synchronize against the cpumask update using RCU. The RCU locked section includes both the housekeeping CPU target election for the PCI probe work and the work enqueue. This way the housekeeping update side will simply need to flush the pending related works after updating the housekeeping mask in order to make sure that no PCI work ever executes on an isolated CPU. This part will be handled in a subsequent patch. Signed-off-by: Frederic Weisbecker Acked-by: Bjorn Helgaas --- drivers/pci/pci-driver.c | 47 ++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 7c2d9d596258..a6111140755c 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -302,9 +302,8 @@ struct drv_dev_and_id { const struct pci_device_id *id; }; =20 -static long local_pci_probe(void *_ddi) +static int local_pci_probe(struct drv_dev_and_id *ddi) { - struct drv_dev_and_id *ddi =3D _ddi; struct pci_dev *pci_dev =3D ddi->dev; struct pci_driver *pci_drv =3D ddi->drv; struct device *dev =3D &pci_dev->dev; @@ -338,6 +337,19 @@ static long local_pci_probe(void *_ddi) return 0; } =20 +struct pci_probe_arg { + struct drv_dev_and_id *ddi; + struct work_struct work; + int ret; +}; + +static void local_pci_probe_callback(struct work_struct *work) +{ + struct pci_probe_arg *arg =3D container_of(work, struct pci_probe_arg, wo= rk); + + arg->ret =3D local_pci_probe(arg->ddi); +} + static bool pci_physfn_is_probed(struct pci_dev *dev) { #ifdef CONFIG_PCI_IOV @@ -362,34 +374,51 @@ static int pci_call_probe(struct pci_driver *drv, str= uct pci_dev *dev, dev->is_probed =3D 1; =20 cpu_hotplug_disable(); - /* * Prevent nesting work_on_cpu() for the case where a Virtual Function * device is probed from work_on_cpu() of the Physical device. */ if (node < 0 || node >=3D MAX_NUMNODES || !node_online(node) || pci_physfn_is_probed(dev)) { - cpu =3D nr_cpu_ids; + error =3D local_pci_probe(&ddi); } else { cpumask_var_t wq_domain_mask; + struct pci_probe_arg arg =3D { .ddi =3D &ddi }; =20 if (!zalloc_cpumask_var(&wq_domain_mask, GFP_KERNEL)) { error =3D -ENOMEM; goto out; } + + INIT_WORK_ONSTACK(&arg.work, local_pci_probe_callback); + + /* + * The target election and the enqueue of the work must be within + * the same RCU read side section so that when the workqueue pool + * is flushed after a housekeeping cpumask update, further readers + * are guaranteed to queue the probing work to the appropriate + * targets. + */ + rcu_read_lock(); cpumask_and(wq_domain_mask, housekeeping_cpumask(HK_TYPE_WQ), housekeeping_cpumask(HK_TYPE_DOMAIN)); =20 cpu =3D cpumask_any_and(cpumask_of_node(node), wq_domain_mask); + if (cpu < nr_cpu_ids) { + schedule_work_on(cpu, &arg.work); + rcu_read_unlock(); + flush_work(&arg.work); + error =3D arg.ret; + } else { + rcu_read_unlock(); + error =3D local_pci_probe(&ddi); + } + free_cpumask_var(wq_domain_mask); + destroy_work_on_stack(&arg.work); } - - if (cpu < nr_cpu_ids) - error =3D work_on_cpu(cpu, local_pci_probe, &ddi); - else - error =3D local_pci_probe(&ddi); out: dev->is_probed =3D 0; cpu_hotplug_enable(); --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1B50626560B; Thu, 1 Jan 2026 22:14:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305669; cv=none; b=O7M6B6nYyFZuotHWtKbndEEQZmPsyT17Qz5FXgvIpgYmPRUgOfJp6WIELcXwQX8bN2VoJTkI7TmEA76EebunquHPDlUOPjS6ujkALaavrfuigdQSZK1TFFnEekm8s1Kr7xOjSVidPlGSMBm4d2eoqUg9YobZHw1qLrW9cNk+6Dg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305669; c=relaxed/simple; bh=11kVg/bDOXpa/yvnQMWYkjqm5C/SPwrAAGSvfZEuxSQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uUhVwkD6gCvbFumXiuUP8sktKIoAfC0ZG7SIiKijB2LVa/e1AH5AtyVM74eR/W3j4qkBhPg8cHvj7QPpEjtGWrqjPKEWeN9T93ik+aKEv+f/Ou0XTzWeSCTSLsu8zAXYCYVW4e9JtwQhk3Lij1QgxMJXYRS6sYt1uWf9vR6vtEU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XHSOvnWD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XHSOvnWD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12890C4CEF7; Thu, 1 Jan 2026 22:14:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305668; bh=11kVg/bDOXpa/yvnQMWYkjqm5C/SPwrAAGSvfZEuxSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XHSOvnWDEEPIMqCYfMXBMg4MhIZsJJORIQ+k+i2tF7q45UMX7h186aWMrbCkNouBS YVe51t94JfY7Ya8ZYWgrtim+Isr2ohIK9SZBwk3V0aqrpcydYDAOBy/9UQEV5FFqoi l5U51qfy7YC/g141GXTax/12TYrlkQBoiEdRejLUgcGnxCQuFIC55/BPIp8JTC1/Cl yOMdT0opdcsidMPDTHNZ7eRIUZqxlEPCmISKqtdr4YhJIaX5A6URq2unH6cUD+UvH3 K09zD+gnJ7kO1hWnE2OLNvZv0d6N1BLXHyRR+taO3yl/k1d9yGSN7XO2H4St6TmVva Gh9Lts/6aUEKQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 02/33] cpu: Revert "cpu/hotplug: Prevent self deadlock on CPU hot-unplug" Date: Thu, 1 Jan 2026 23:13:27 +0100 Message-ID: <20260101221359.22298-3-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 1) The commit: 2b8272ff4a70 ("cpu/hotplug: Prevent self deadlock on CPU hot-unplug") was added to fix an issue where the hotplug control task (BP) was throttled between CPUHP_AP_IDLE_DEAD and CPUHP_HRTIMERS_PREPARE waiting in the hrtimer blindspot for the bandwidth callback queued in the dead CPU. 2) Later on, the commit: 38685e2a0476 ("cpu/hotplug: Don't offline the last non-isolated CPU") plugged on the target selection for the workqueue offloaded CPU down process to prevent from destroying the last CPU domain. 3) Finally: 5c0930ccaad5 ("hrtimers: Push pending hrtimers away from outgoing CPU earl= ier") removed entirely the conditions for the race exposed and partially fixed in 1). The offloading of the CPU down process to a workqueue on another CPU then becomes unnecessary. But the last CPU belonging to scheduler domains must still remain online. Therefore revert the now obsolete commit 2b8272ff4a70b866106ae13c36be7ecbef5d5da2 and move the housekeeping check under the cpu_hotplug_lock write held. Since HK_TYPE_DOMAIN will include both isolcpus and cpuset isolated partition, the hotplug lock will synchronize against concurrent cpuset partition updates. Signed-off-by: Frederic Weisbecker --- kernel/cpu.c | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index 8df2d773fe3b..40b8496f47c5 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1410,6 +1410,16 @@ static int __ref _cpu_down(unsigned int cpu, int tas= ks_frozen, =20 cpus_write_lock(); =20 + /* + * Keep at least one housekeeping cpu onlined to avoid generating + * an empty sched_domain span. + */ + if (cpumask_any_and(cpu_online_mask, + housekeeping_cpumask(HK_TYPE_DOMAIN)) >=3D nr_cpu_ids) { + ret =3D -EBUSY; + goto out; + } + cpuhp_tasks_frozen =3D tasks_frozen; =20 prev_state =3D cpuhp_set_state(cpu, st, target); @@ -1456,22 +1466,8 @@ static int __ref _cpu_down(unsigned int cpu, int tas= ks_frozen, return ret; } =20 -struct cpu_down_work { - unsigned int cpu; - enum cpuhp_state target; -}; - -static long __cpu_down_maps_locked(void *arg) -{ - struct cpu_down_work *work =3D arg; - - return _cpu_down(work->cpu, 0, work->target); -} - static int cpu_down_maps_locked(unsigned int cpu, enum cpuhp_state target) { - struct cpu_down_work work =3D { .cpu =3D cpu, .target =3D target, }; - /* * If the platform does not support hotplug, report it explicitly to * differentiate it from a transient offlining failure. @@ -1480,18 +1476,7 @@ static int cpu_down_maps_locked(unsigned int cpu, en= um cpuhp_state target) return -EOPNOTSUPP; if (cpu_hotplug_disabled) return -EBUSY; - - /* - * Ensure that the control task does not run on the to be offlined - * CPU to prevent a deadlock against cfs_b->period_timer. - * Also keep at least one housekeeping cpu onlined to avoid generating - * an empty sched_domain span. - */ - for_each_cpu_and(cpu, cpu_online_mask, housekeeping_cpumask(HK_TYPE_DOMAI= N)) { - if (cpu !=3D work.cpu) - return work_on_cpu(cpu, __cpu_down_maps_locked, &work); - } - return -EBUSY; + return _cpu_down(cpu, 0, target); } =20 static int cpu_down(unsigned int cpu, enum cpuhp_state target) --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B2EF52512FF; Thu, 1 Jan 2026 22:14:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305677; cv=none; b=OFRBwhHd4v0C1LppPV5xYs7AmQYugJf6yamj0btXcWHyfRaqBuS1T4Nn0+8xQtoJ3k2SXfdU1+pRhydYE08QBmUUClrKbnTNOoJh5tx4mkq5ge2Lbda9suZVl2JByq8ms2E6YmsBY8qhO1GJajfkLAn0GJVlg97KwYk1S9ErcAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305677; c=relaxed/simple; bh=xkhk7ZGxynk2RcaH6iYDB0TKNwEPyWR7khi8Efbu4u0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DzPmafMoMgil8W9oSeSQMllEGcalRWTi4RW5PjKuc1iuPa6IgarVfLFAUBSl8AUu1Dwc5amUYnpb21yHq1+3yHf+8q88Tl/MXSfkI3xkw9EiXgTqrUhfsH8YnchZ/lowDDsPQNujMyzWcVoqDbjRlQeDiHpEzzjBVUEeyEpvToo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bPTqFrIP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bPTqFrIP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F29DC116D0; Thu, 1 Jan 2026 22:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305677; bh=xkhk7ZGxynk2RcaH6iYDB0TKNwEPyWR7khi8Efbu4u0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bPTqFrIPuMeDiUKjLJf1BdJZTy8900oENIeuIH1dkJxlc6njI1s0k74kL6OtDCJJ8 R0azKjfphZArLtU64G3kGqplYYG9rSP2gHe1okwairy5AcP1hIu/yPGli7wVh+MMLx Cf4HBRsfB7tB3ryzbCrOSwtSLh1ZhMMxFnpbplQa4efDNabKMfYGXmlvewbsq3eSLw Q1gD7Sfampvfq3ZlL6yE+MwTbAdJW22yf9odVWI6MJ/KVLI6k1vg2L2FqskDdTxYRE zgzfjdPOV14ZLPrpP77hkiEf1Z3io3x+v2KJKdO0dh6Rp9zb43IWkyhypLpv3OfYav /RgNIaTo+1D9Q== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 03/33] memcg: Prepare to protect against concurrent isolated cpuset change Date: Thu, 1 Jan 2026 23:13:28 +0100 Message-ID: <20260101221359.22298-4-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The HK_TYPE_DOMAIN housekeeping cpumask will soon be made modifiable at runtime. In order to synchronize against memcg workqueue to make sure that no asynchronous draining is pending or executing on a newly made isolated CPU, target and queue a drain work under the same RCU critical section. Whenever housekeeping will update the HK_TYPE_DOMAIN cpumask, a memcg workqueue flush will also be issued in a further change to make sure that no work remains pending after a CPU has been made isolated. Signed-off-by: Frederic Weisbecker --- mm/memcontrol.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index be810c1fbfc3..2289a0299331 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2003,6 +2003,19 @@ static bool is_memcg_drain_needed(struct memcg_stock= _pcp *stock, return flush; } =20 +static void schedule_drain_work(int cpu, struct work_struct *work) +{ + /* + * Protect housekeeping cpumask read and work enqueue together + * in the same RCU critical section so that later cpuset isolated + * partition update only need to wait for an RCU GP and flush the + * pending work on newly isolated CPUs. + */ + guard(rcu)(); + if (!cpu_is_isolated(cpu)) + schedule_work_on(cpu, work); +} + /* * Drains all per-CPU charge caches for given root_memcg resp. subtree * of the hierarchy under it. @@ -2032,8 +2045,8 @@ void drain_all_stock(struct mem_cgroup *root_memcg) &memcg_st->flags)) { if (cpu =3D=3D curcpu) drain_local_memcg_stock(&memcg_st->work); - else if (!cpu_is_isolated(cpu)) - schedule_work_on(cpu, &memcg_st->work); + else + schedule_drain_work(cpu, &memcg_st->work); } =20 if (!test_bit(FLUSHING_CACHED_CHARGE, &obj_st->flags) && @@ -2042,8 +2055,8 @@ void drain_all_stock(struct mem_cgroup *root_memcg) &obj_st->flags)) { if (cpu =3D=3D curcpu) drain_local_obj_stock(&obj_st->work); - else if (!cpu_is_isolated(cpu)) - schedule_work_on(cpu, &obj_st->work); + else + schedule_drain_work(cpu, &obj_st->work); } } migrate_enable(); --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CB6012512FF; Thu, 1 Jan 2026 22:14:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305685; cv=none; b=XKU/A4F6iB9BFokXMLT6DYxkB78dM+qLq2JsjM6CcT4gVPcUY6FymKJUhADDbdzJAwBBDqS40C75NmE9WBTuy2H4rVOnRwkmg4M5lTT9VZjggslOF0WPpMU/9jaIslmrsuawtfFIZpj8ncUXaP7QCN9VQrGyX165N1VCZGNhhB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305685; c=relaxed/simple; bh=gBHkj0y4jQxeMV2qzbEciSScfrXq1yZennkNx/2Itiw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hBFDRB6a7Kqds6GO74aU1qihKRDCGhSJWypjD2KBb+wGViarKrp5CtCtG4HbC+TGJmFR0Gz0rFlbKoi3HucAwV4tDjeh+kHRLYQHWW2xUTlUidVoeTuc3ooycH6WxdFI6wPw9DyjcXnHj4K/xnZOPgUEOz//y1FVO703XSl+qQg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eUUVJ4Ql; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eUUVJ4Ql" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E32CC4CEF7; Thu, 1 Jan 2026 22:14:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305685; bh=gBHkj0y4jQxeMV2qzbEciSScfrXq1yZennkNx/2Itiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eUUVJ4QlV2Ud1CrS6GjbiF6v46hq34xCiNh0ZJVjVwX1TXlPBFeyAEgU8UViw5n7D i59CAEMxlUC3VxC9iEwmbmBwuKfcfVzPUUaZD6pH8UiyBaJnaMjvHjrcuuVjuwPRY/ 88byT+kZctItQI+QgXaYFZ8RmSFVhJsjKDttq+hwL8Wx0ETwMm6W1gzDxv7AULKKam YJnAGrRKYx/MpQRZJU91JeeCHIxHJewdUxbzC9D5Z/RjPXLAk6MIhhlLqAIn3gDP0V HcXzQ3FppfamhiEne7w0DLSThz/ucPmLuVjZrVFub7h2zTJg0+6DD93qqzEmXwyKQN Z4zpqik3l7rJg== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 04/33] mm: vmstat: Prepare to protect against concurrent isolated cpuset change Date: Thu, 1 Jan 2026 23:13:29 +0100 Message-ID: <20260101221359.22298-5-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The HK_TYPE_DOMAIN housekeeping cpumask will soon be made modifiable at runtime. In order to synchronize against vmstat workqueue to make sure that no asynchronous vmstat work is pending or executing on a newly made isolated CPU, target and queue a vmstat work under the same RCU read side critical section. Whenever housekeeping will update the HK_TYPE_DOMAIN cpumask, a vmstat workqueue flush will also be issued in a further change to make sure that no work remains pending after a CPU has been made isolated. Signed-off-by: Frederic Weisbecker --- mm/vmstat.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index 65de88cdf40e..ed19c0d42de6 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -2144,11 +2144,13 @@ static void vmstat_shepherd(struct work_struct *w) * infrastructure ever noticing. Skip regular flushing from vmstat_sheph= erd * for all isolated CPUs to avoid interference with the isolated workloa= d. */ - if (cpu_is_isolated(cpu)) - continue; + scoped_guard(rcu) { + if (cpu_is_isolated(cpu)) + continue; =20 - if (!delayed_work_pending(dw) && need_update(cpu)) - queue_delayed_work_on(cpu, mm_percpu_wq, dw, 0); + if (!delayed_work_pending(dw) && need_update(cpu)) + queue_delayed_work_on(cpu, mm_percpu_wq, dw, 0); + } =20 cond_resched(); } --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 598CF26CE04; Thu, 1 Jan 2026 22:14:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305694; cv=none; b=JqFv+v/PQV/l+zTgv3/PgbdRwwKVSS/8G/ikpMJ3b6giK23Ot9HPTdhhrNFMbkn5P5xM4gJAdBkvEPSpXdv2dk1nA1bg4GgP6UO0WZAJ95kqlwdhL6emLiOQl9kdiCI5aoruD01NH/baYNq38Hw0vBh1AZUBoK6qPL5IGJEyV3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305694; c=relaxed/simple; bh=HhWObUaCwi4bgCO3C817jvURXsArjqmd8mmB3XQmmVY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nm23HRPQOr3AryBWXAP9VzhFFcIZeHwlX/pySUolgk/mTnlAiNJOUMwoVFRh/GvGN3wTw9ys8IYsRY4xMkGrylXV29WaZYlE6lwyH3Fr5QJNuPAokumNpxQfBUiacAo8WtZHnRgcCGRlv+iyrALMYujevkPgnGKY/1tNpuYVe30= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hThhxW/r; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hThhxW/r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE100C116D0; Thu, 1 Jan 2026 22:14:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305693; bh=HhWObUaCwi4bgCO3C817jvURXsArjqmd8mmB3XQmmVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hThhxW/r13awo16phbPQQ5e18yCVLIuhRzdsJIdU5vBKwFF6zis9e1PhqvNKeiaxE yNXDpt710ACQOYxh2GmJjvjzcHWU5Gd1xag5ereyYbgGEFnlSpeP8vAXu680/2diLX jo6v8CAvwNQTOAN0oaMH7e8idLVQhK/qSovtp8T/kaGnIkp4hP1m0QX0GPK2fjYvt8 7Za/OOJXaPJAarRlJy/HwZHD+iehQY2If61pGgbQr1X2ZCi82h3YyWRj3IzO0pDQz0 0+lv7FiSQ8XZfglJirakzrVfN6V0hzAM3xpAbnWoi0mG9peAtd27xWuskx9SkgyJNC SpF1uI0hnPzkA== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 05/33] sched/isolation: Save boot defined domain flags Date: Thu, 1 Jan 2026 23:13:30 +0100 Message-ID: <20260101221359.22298-6-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" HK_TYPE_DOMAIN will soon integrate not only boot defined isolcpus=3D CPUs but also cpuset isolated partitions. Housekeeping still needs a way to record what was initially passed to isolcpus=3D in order to keep these CPUs isolated after a cpuset isolated partition is modified or destroyed while containing some of them. Create a new HK_TYPE_DOMAIN_BOOT to keep track of those. Signed-off-by: Frederic Weisbecker Reviewed-by: Phil Auld Reviewed-by: Waiman Long --- include/linux/sched/isolation.h | 4 ++++ kernel/sched/isolation.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolatio= n.h index d8501f4709b5..c7cf6934489c 100644 --- a/include/linux/sched/isolation.h +++ b/include/linux/sched/isolation.h @@ -7,8 +7,12 @@ #include =20 enum hk_type { + /* Inverse of boot-time isolcpus=3D argument */ + HK_TYPE_DOMAIN_BOOT, HK_TYPE_DOMAIN, + /* Inverse of boot-time isolcpus=3Dmanaged_irq argument */ HK_TYPE_MANAGED_IRQ, + /* Inverse of boot-time nohz_full=3D or isolcpus=3Dnohz arguments */ HK_TYPE_KERNEL_NOISE, HK_TYPE_MAX, =20 diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index 3ad0d6df6a0a..11a623fa6320 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -11,6 +11,7 @@ #include "sched.h" =20 enum hk_flags { + HK_FLAG_DOMAIN_BOOT =3D BIT(HK_TYPE_DOMAIN_BOOT), HK_FLAG_DOMAIN =3D BIT(HK_TYPE_DOMAIN), HK_FLAG_MANAGED_IRQ =3D BIT(HK_TYPE_MANAGED_IRQ), HK_FLAG_KERNEL_NOISE =3D BIT(HK_TYPE_KERNEL_NOISE), @@ -239,7 +240,7 @@ static int __init housekeeping_isolcpus_setup(char *str) =20 if (!strncmp(str, "domain,", 7)) { str +=3D 7; - flags |=3D HK_FLAG_DOMAIN; + flags |=3D HK_FLAG_DOMAIN | HK_FLAG_DOMAIN_BOOT; continue; } =20 @@ -269,7 +270,7 @@ static int __init housekeeping_isolcpus_setup(char *str) =20 /* Default behaviour for isolcpus without flags */ if (!flags) - flags |=3D HK_FLAG_DOMAIN; + flags |=3D HK_FLAG_DOMAIN | HK_FLAG_DOMAIN_BOOT; =20 return housekeeping_setup(str, flags); } --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E394223E350; Thu, 1 Jan 2026 22:15:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305703; cv=none; b=CbaVqkGknD0PiARFUcLhfhA2UQ58U5DKtUj+j3aB0AMdS4SImwttMQCl05JiYsrsCe8ftIFDKj09thQYDgeTTMinh57Yfxm6DKedjxEOLrOSpeq5FSfI3Bl4pawWohozJO7XIjEMIqL1HArcKE+3IJ1z9V6ExtoTS62vTd31bxc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305703; c=relaxed/simple; bh=pTB9cNPcvPakmWV9jutt30tCCHfCDIAA9k4V/apVATM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tY9A/XL16rytjkGlgMQ50fCjDBf8t8Po78HbfyN+WIXgLseMbeBQ03Uxh9Ey7siyauuUridYUgvaL9ZUZgSFjuVjp2TuezYhyj66vc9/XiRnnITzXY0/KjZNP+KFcPbtBDUrl2EubsQ2wq+jzEKD8Pv2wIBV6OWrwCIkKadBlWg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZwXUOgHh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZwXUOgHh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D948C19421; Thu, 1 Jan 2026 22:14:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305702; bh=pTB9cNPcvPakmWV9jutt30tCCHfCDIAA9k4V/apVATM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZwXUOgHh5SZusqdj1MuBOnHQSG66GUsBSUq9kZmTGHcPWpcV945zTsBbzfhh9gRwQ 5Ys00+vpPwfvVsflAum3U8GgE/7M7GFNZ3ZSAEWEl4wzQYn/4oZiHZNc16OWnHbhK6 09XASD6Q7S/OOE+tB2MgcECKmN4VNWfVTTkcncpOgr+ODrxDK+HfyLvp+mOWp+C8vB vKwMCR2Q4jkz3xaDI9brAB9ZC+E9AEoFs6nNCBkXT5TDz+brTjkc2oXuPm73U0f0CM IRipKFdDs+YRB//iQcq7lQCUWK36mljq2Bo1Kr/r3JWkqQrQyod2Pxijbt0Fx/qBsL Zh21Loq+Sn1UA== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 06/33] cpuset: Convert boot_hk_cpus to use HK_TYPE_DOMAIN_BOOT Date: Thu, 1 Jan 2026 23:13:31 +0100 Message-ID: <20260101221359.22298-7-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" boot_hk_cpus is an ad-hoc copy of HK_TYPE_DOMAIN_BOOT. Remove it and use the official version. Signed-off-by: Frederic Weisbecker Reviewed-by: Phil Auld Reviewed-by: Chen Ridong Reviewed-by: Waiman Long --- kernel/cgroup/cpuset.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 6e6eb09b8db6..3afa72f8d579 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -88,12 +88,6 @@ static cpumask_var_t isolated_cpus; */ static bool isolated_cpus_updating; =20 -/* - * Housekeeping (HK_TYPE_DOMAIN) CPUs at boot - */ -static cpumask_var_t boot_hk_cpus; -static bool have_boot_isolcpus; - /* * A flag to force sched domain rebuild at the end of an operation. * It can be set in @@ -1453,15 +1447,16 @@ static bool isolated_cpus_can_update(struct cpumask= *add_cpus, * @new_cpus: cpu mask * Return: true if there is conflict, false otherwise * - * CPUs outside of boot_hk_cpus, if defined, can only be used in an + * CPUs outside of HK_TYPE_DOMAIN_BOOT, if defined, can only be used in an * isolated partition. */ static bool prstate_housekeeping_conflict(int prstate, struct cpumask *new= _cpus) { - if (!have_boot_isolcpus) + if (!housekeeping_enabled(HK_TYPE_DOMAIN_BOOT)) return false; =20 - if ((prstate !=3D PRS_ISOLATED) && !cpumask_subset(new_cpus, boot_hk_cpus= )) + if ((prstate !=3D PRS_ISOLATED) && + !cpumask_subset(new_cpus, housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT))) return true; =20 return false; @@ -3892,12 +3887,9 @@ int __init cpuset_init(void) =20 BUG_ON(!alloc_cpumask_var(&cpus_attach, GFP_KERNEL)); =20 - have_boot_isolcpus =3D housekeeping_enabled(HK_TYPE_DOMAIN); - if (have_boot_isolcpus) { - BUG_ON(!alloc_cpumask_var(&boot_hk_cpus, GFP_KERNEL)); - cpumask_copy(boot_hk_cpus, housekeeping_cpumask(HK_TYPE_DOMAIN)); - cpumask_andnot(isolated_cpus, cpu_possible_mask, boot_hk_cpus); - } + if (housekeeping_enabled(HK_TYPE_DOMAIN_BOOT)) + cpumask_andnot(isolated_cpus, cpu_possible_mask, + housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT)); =20 return 0; } --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 36824258CDF; Thu, 1 Jan 2026 22:15:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305711; cv=none; b=SFF0mQWRdmx6jNO5wO9yz/zXFKaoaVEmZKXGQN2O0O1PS0nzimasVyy5sDPTdycAOS28D/+wbRfbdu8vs724qEdG8OmsTxUd4+0QJdOBZgYAYvuwCIwKy4xfKr7K8nTGQYBrpfAn+OojId9YBdue8aEkXBAw6CanZo9arEKyWGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305711; c=relaxed/simple; bh=N56RJwx7Vb0djbwM5UfAAN+LOP0Kn2KqSnmCrDj/jJE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FaHaQ4ywaIDnjz6+985+4I9AW93x31dwc3P2gbX1ljrpXRWCuQWCCyd9Ez3YtwbIpIZfTFoBisaiPLb3aFfmV3xUTAVcADWm6Om1+Q9RRE6m9a/hGIF0Nj3Xzj1f4iRLLy8RjwOhOfdRIb2nDjUhjJg6bZGpSlCPDfTd/cUVcao= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K+EkEJDq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K+EkEJDq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E172BC4CEF7; Thu, 1 Jan 2026 22:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305710; bh=N56RJwx7Vb0djbwM5UfAAN+LOP0Kn2KqSnmCrDj/jJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K+EkEJDqQNm/aKnq+vMpcP7vYZHuTriYqBlXhkhZG9M7p9Lyqw5TPyIN1vavhqcbU UHgyZlBi1wsopSwML+3pVUl4QgKZUfttQHhClVetTMrVGwUeao98oJTrni+4ybTLJh MOA/E4b7hCFINh+fxMDb2P+r5M75YoVdlWX4FQdAQzMyMH+5XXNCwgADrrbWSGOJnm KRxKzdM4UExyDT0E5oHbUbF2sl8KKJFcJhaFpGF1xKqHlRHo97gonkL4qmRP6ebt7s E1Jolp6xdr7Vzr45pANOyXltQsVStN/N/HO3wQ8cLcTD8/TNMjIq3gWaJ+0Gq1lr0v Y5fCkSwsE8YKw== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 07/33] driver core: cpu: Convert /sys/devices/system/cpu/isolated to use HK_TYPE_DOMAIN_BOOT Date: Thu, 1 Jan 2026 23:13:32 +0100 Message-ID: <20260101221359.22298-8-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Make sure /sys/devices/system/cpu/isolated only prints what was passed through the isolcpus=3D parameter before HK_TYPE_DOMAIN will also integrate cpuset isolated partitions. Signed-off-by: Frederic Weisbecker --- drivers/base/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index c6c57b6f61c6..3e3fa031e605 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -291,7 +291,7 @@ static ssize_t print_cpus_isolated(struct device *dev, return -ENOMEM; =20 cpumask_andnot(isolated, cpu_possible_mask, - housekeeping_cpumask(HK_TYPE_DOMAIN)); + housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT)); len =3D sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(isolated)); =20 free_cpumask_var(isolated); --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 AC56C27FD43; Thu, 1 Jan 2026 22:15:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305719; cv=none; b=h65y2JD5GiMdGjJD7TW1o4FaJlX5ilTOFbu9IUZukotoumT9yMrF11nYSc1/0/0I/ODyZMz1i5cN9zRWTippreZ8OhGUbqcVjCkve5s3+UgGKB8CEmrGCUd2ptnrTdiPhg4QGbrgjyOSwYI3diEh2FF2qwRoGas0DILC7i90z/c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305719; c=relaxed/simple; bh=gHL1k3Ce/0Yqnu3RKEhMFCTtXjaAjQ9JVob0E5Uoa3s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ohtXE3HXMBzNG5DwIFRPUGyaUZVwUYsx8CzQ2Lw0vK66ubQRHcW5AwoYUZE91z3Ibe1Vk6rDBHJlXqlAM+aoQr0Irig4u8BIo05kRDsaQiM3R8w+adfii+Iux5xAxeX6CP+Qt/gYT7vdTif+FfKOiEEREvn8WYWptgL/TnC8QWo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rGzeR2j4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rGzeR2j4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C277C116D0; Thu, 1 Jan 2026 22:15:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305719; bh=gHL1k3Ce/0Yqnu3RKEhMFCTtXjaAjQ9JVob0E5Uoa3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rGzeR2j4rIaZ/Ba3+tEX6uButAsa/DeTyFZ/qjWHwok0cL1okdkghC1KZAaPrZp0q mfWsThlZYCgTqIaay4c3bwM47lAtXt+WzoxXr/DRH5Et9ydvT7Pu4ei2X5wjV9AxHA dFnsWRWLPe1KcJuDdIklMPPQp0cvCwu+GCWTlHWqn0B1vpor2tzZywc91kiABl8iKs YBO6MC2AEqYWd0yHUjy2+T1E1ucmMfomGE3kA7Zm2U1nRI1Xk3wIAHNfdLkoAXnsRZ 3qMTyge8nki18nhfgnzrUVMZarInnosGSTjx5GDRWOBBUVeMhrYFL/xY8k+FpWop4O 2BNn6OPJ4Bz7g== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 08/33] net: Keep ignoring isolated cpuset change Date: Thu, 1 Jan 2026 23:13:33 +0100 Message-ID: <20260101221359.22298-9-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" RPS cpumask can be overriden through sysfs/syctl. The boot defined isolated CPUs are then excluded from that cpumask. However HK_TYPE_DOMAIN will soon integrate cpuset isolated CPUs updates and the RPS infrastructure needs more thoughts to be able to propagate such changes and synchronize against them. Keep handling only what was passed through "isolcpus=3D" for now. Signed-off-by: Frederic Weisbecker --- net/core/net-sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index ca878525ad7c..07624b682b08 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -1022,7 +1022,7 @@ static int netdev_rx_queue_set_rps_mask(struct netdev= _rx_queue *queue, int rps_cpumask_housekeeping(struct cpumask *mask) { if (!cpumask_empty(mask)) { - cpumask_and(mask, mask, housekeeping_cpumask(HK_TYPE_DOMAIN)); + cpumask_and(mask, mask, housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT)); cpumask_and(mask, mask, housekeeping_cpumask(HK_TYPE_WQ)); if (cpumask_empty(mask)) return -EINVAL; --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 36C6B248F5A; Thu, 1 Jan 2026 22:15:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305728; cv=none; b=CqLmemREAU9UhC5ZNU1K+zg9vNrzbli/RIEoTP/2UemA0DlKBZvH717jyumJbXSU9s6f0bLPRjHWfE15PlrXgz9vQY6fLeI+YJe2CB/5ohEeYPEN3hd9zbG3LbcLxutSyn6EnXwhq9Nyo6kKGetXOOGsYJEaHJLeXhFKh6nnkMo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305728; c=relaxed/simple; bh=CSBqMHaVS4LYUH4nZYK0n1Q3mrGckGoVFLRQaFReEXw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q8E/5mnFS3BqM7hUQM7NrwqR/ADfc7o0U7Ed0eEK4P3WxvIH7JiF14G35vXztLl76ON1beo+PhJo216cjI6HzkV/dz+SsqBWGLKNjSIwUfiT3jVHyi72o+/w6uzeB3EmbSBTwQrBfr26BM3qilGWEuYw1Jy37rRMbD29ofjqy1A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PjJIQyPZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PjJIQyPZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1B51C4CEF7; Thu, 1 Jan 2026 22:15:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305727; bh=CSBqMHaVS4LYUH4nZYK0n1Q3mrGckGoVFLRQaFReEXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PjJIQyPZ3gNH+xw/gL3DNsTYhPXKrLZGi+D4wZQyD/V9H6meQ28ftUtJ322hNWm6R 5KdjwiHSktvOFFoVDCyBtYLnU9HjLsgFkaWgfhBfA2hcf29PmqGHSFCZ492lymdaj5 55ZgJnaLIL5LkrhelQb0w4bW/QTmDSGT6kndD4EuRqOLUBKqJZmcOhCgZ903eSxams /TbBRyvx2meH/0HFPN546AYKBNER7m35Pbjlx1R/LHKVmP4MUyfEYZlHYfCYgB0T8p DwjBvugnF9Y55uPBHcwYxhBnmLhu3yZKw0Wk4nZK8QmCVpCskJyWtXmhuh9oEZ39S6 2palunZI8oI9Q== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 09/33] block: Protect against concurrent isolated cpuset change Date: Thu, 1 Jan 2026 23:13:34 +0100 Message-ID: <20260101221359.22298-10-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The block subsystem prevents running the workqueue to isolated CPUs, including those defined by cpuset isolated partitions. Since HK_TYPE_DOMAIN will soon contain both and be subject to runtime modifications, synchronize against housekeeping using the relevant lock. For full support of cpuset changes, the block subsystem may need to propagate changes to isolated cpumask through the workqueue in the future. Signed-off-by: Frederic Weisbecker Acked-by: Jens Axboe --- block/blk-mq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 1978eef95dca..0037af1216f3 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -4257,12 +4257,16 @@ static void blk_mq_map_swqueue(struct request_queue= *q) =20 /* * Rule out isolated CPUs from hctx->cpumask to avoid - * running block kworker on isolated CPUs + * running block kworker on isolated CPUs. + * FIXME: cpuset should propagate further changes to isolated CPUs + * here. */ + rcu_read_lock(); for_each_cpu(cpu, hctx->cpumask) { if (cpu_is_isolated(cpu)) cpumask_clear_cpu(cpu, hctx->cpumask); } + rcu_read_unlock(); =20 /* * Initialize batch roundrobin counts --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B1DE02E2F14; Thu, 1 Jan 2026 22:15:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305736; cv=none; b=DK+0VYJXEKDFlb8xK4qSjUeXclVwMfBwykzxjJpbEiMD+hT7MHKmAz+9DZZA8wClIf7PdFC5V8QutFAd9z2Ut7+rsC9tT/mHdtBqQl9qFl8V2nb9ahGRwU7SkT0R5N4Fzfk+G7xKSJhvB+SfvHuvQI6iVq9LRe3KCiYBHcvFyvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305736; c=relaxed/simple; bh=cfBsUi49kwBpo1bGsw5oqJU14C2/JcinY0oHFYzJ/us=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=obEm7YxJqbb3TDpNL0iggInIXq0rUYOOfyG1IwACDNFEQU+NKszqyEeAu0mXRQnCapvRG3lSSrCps/BPDnLZ8vZ7qfdlL+1kb5kYVY5C1GsG6J+dOnDNBfbCvBUSuE86+Ckqtj/Foyt4/nHcMJj9qFz7fqCiLSzJ0NzaekUL4YU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nlQMgj1n; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nlQMgj1n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 208B9C116D0; Thu, 1 Jan 2026 22:15:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305736; bh=cfBsUi49kwBpo1bGsw5oqJU14C2/JcinY0oHFYzJ/us=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nlQMgj1nTTXW18RtyL+xyRQjFuVUjFVIkw9w4/qbqxrf81g8r3KSDa05VKVN/bxA/ vIKSiCe2IhhaJyJCtEzi9RsJO0Kbx8cxJXCZHBVgFZymaDNc7SBubaq2+9W8AmTG/R Eq6yt71iRpiTnQdzSIiKHmq7FzyJIJ71LVV0/jxsh8Dr0Psex4G5jmxaJgSgs/9rC7 WvO1V9EwXxqIAxixAFfaI6OkeVse14raZBGXjJ1BvNu7ayX38rhmGCtOOAwATE9ajn kudc2CaRsC2rzY4fk5JPxN5Wf/5Y1n6opCaB/29876e/JqEDRp56ZY7BLWOVS3cV8r BETHMalvbdJ4w== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 10/33] timers/migration: Prevent from lockdep false positive warning Date: Thu, 1 Jan 2026 23:13:35 +0100 Message-ID: <20260101221359.22298-11-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Testing housekeeping_cpu() will soon require that either the RCU "lock" is held or the cpuset mutex. When CPUs get isolated through cpuset, the change is propagated to timer migration such that isolation is also performed from the migration tree. However that propagation is done using workqueue which tests if the target is actually isolated before proceeding. Lockdep doesn't know that the workqueue caller holds cpuset mutex and that it waits for the work, making the housekeeping cpumask read safe. Shut down the future warning by removing this test. It is unecessary beyond hotplug, the workqueue is already targeted towards isolated CPUs. Signed-off-by: Frederic Weisbecker --- kernel/time/timer_migration.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/kernel/time/timer_migration.c b/kernel/time/timer_migration.c index 18dda1aa782d..3879575a4975 100644 --- a/kernel/time/timer_migration.c +++ b/kernel/time/timer_migration.c @@ -1497,7 +1497,7 @@ static int tmigr_clear_cpu_available(unsigned int cpu) return 0; } =20 -static int tmigr_set_cpu_available(unsigned int cpu) +static int __tmigr_set_cpu_available(unsigned int cpu) { struct tmigr_cpu *tmc =3D this_cpu_ptr(&tmigr_cpu); =20 @@ -1505,9 +1505,6 @@ static int tmigr_set_cpu_available(unsigned int cpu) if (WARN_ON_ONCE(!tmc->tmgroup)) return -EINVAL; =20 - if (tmigr_is_isolated(cpu)) - return 0; - guard(mutex)(&tmigr_available_mutex); =20 cpumask_set_cpu(cpu, tmigr_available_cpumask); @@ -1523,6 +1520,14 @@ static int tmigr_set_cpu_available(unsigned int cpu) return 0; } =20 +static int tmigr_set_cpu_available(unsigned int cpu) +{ + if (tmigr_is_isolated(cpu)) + return 0; + + return __tmigr_set_cpu_available(cpu); +} + static void tmigr_cpu_isolate(struct work_struct *ignored) { tmigr_clear_cpu_available(smp_processor_id()); @@ -1530,7 +1535,12 @@ static void tmigr_cpu_isolate(struct work_struct *ig= nored) =20 static void tmigr_cpu_unisolate(struct work_struct *ignored) { - tmigr_set_cpu_available(smp_processor_id()); + /* + * Don't call tmigr_is_isolated() ->housekeeping_cpu() directly because + * the cpuset mutex is correctly held by the workqueue caller but lockdep + * doesn't know that. + */ + __tmigr_set_cpu_available(smp_processor_id()); } =20 /** --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 60DE7274FDB; Thu, 1 Jan 2026 22:15:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305745; cv=none; b=UlkChb5WB17yRpxdLu4zSoSGQDZnmQPkbcQdfDykireL0ZaNVhNT9LPKLQJufJHiDQU8xhavz2yBb0tsBus9qz6rhEazpCuAzDctNIwmRpwZ2J2LhdqjeOpB7cBNy0B6EBBHau3tvt47bzUxAXQ0BGiRHa+BjOHy51MiVr2CxTE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305745; c=relaxed/simple; bh=JzP68aQ+gy8MFfasMpMI/FZxkM6LDJNtU1916wSaM4Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e8FU1Ic+xo4KnZSgluL9jxVr+A/AgRhrbCdMeyQV0sYCxiSqMRyT7PCTjXfEZYLfu0zYPI/jSXByZMZkuuyxhM/PDSW/I8ZeY+6mDWZEScGExqF7MdNHP0rAJ5UQ6ETvbQaPe2bWm0ZgjkDuAshLxTj7b+W57LQetRKnyNagNfQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EwXbskvK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EwXbskvK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9B3EC4CEF7; Thu, 1 Jan 2026 22:15:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305744; bh=JzP68aQ+gy8MFfasMpMI/FZxkM6LDJNtU1916wSaM4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EwXbskvKcD7Va7qJGFYsQ0tn0UygWfaV28ml73obDfEt2Rsj/99pH16UNZ5cR6iUo vbdeDrnnEdkiX0FQ1mimKP2wbxcY1aw0ZvNIjkMuXMyOqBY0x/9Iyh73ce4Y+w7I70 kHppkovnKnWEnZk5r0f1Bfjz7WMfMcePEOGtAT8lpEFS3sydbtVf2CFwBpNbWkr23U ZrBbHt43U9Kh1t59lnvVO5fcfcKHNrZLditSrGrPNY8TTkHUjYMzyAnmM4JTQawqP4 pB5g+F1jCHz7O8Vszz3059lsP/23VujUCBswiL8zX4qHVm8K2ERG+BbzVyWgnHE1rf akC0dHnN/5uHA== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 11/33] cpu: Provide lockdep check for CPU hotplug lock write-held Date: Thu, 1 Jan 2026 23:13:36 +0100 Message-ID: <20260101221359.22298-12-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" cpuset modifies partitions, including isolated, while holding the cpu hotplug lock read-held. This means that write-holding the CPU hotplug lock is safe to synchronize against housekeeping cpumask changes. Provide a lockdep check to validate that. Signed-off-by: Frederic Weisbecker --- include/linux/cpuhplock.h | 1 + include/linux/percpu-rwsem.h | 1 + kernel/cpu.c | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/include/linux/cpuhplock.h b/include/linux/cpuhplock.h index f7aa20f62b87..286b3ab92e15 100644 --- a/include/linux/cpuhplock.h +++ b/include/linux/cpuhplock.h @@ -13,6 +13,7 @@ struct device; =20 extern int lockdep_is_cpus_held(void); +extern int lockdep_is_cpus_write_held(void); =20 #ifdef CONFIG_HOTPLUG_CPU void cpus_write_lock(void); diff --git a/include/linux/percpu-rwsem.h b/include/linux/percpu-rwsem.h index 288f5235649a..c8cb010d655e 100644 --- a/include/linux/percpu-rwsem.h +++ b/include/linux/percpu-rwsem.h @@ -161,6 +161,7 @@ extern void percpu_free_rwsem(struct percpu_rw_semaphor= e *); __percpu_init_rwsem(sem, #sem, &rwsem_key); \ }) =20 +#define percpu_rwsem_is_write_held(sem) lockdep_is_held_type(sem, 0) #define percpu_rwsem_is_held(sem) lockdep_is_held(sem) #define percpu_rwsem_assert_held(sem) lockdep_assert_held(sem) =20 diff --git a/kernel/cpu.c b/kernel/cpu.c index 40b8496f47c5..01968a5c4a16 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -534,6 +534,11 @@ int lockdep_is_cpus_held(void) { return percpu_rwsem_is_held(&cpu_hotplug_lock); } + +int lockdep_is_cpus_write_held(void) +{ + return percpu_rwsem_is_write_held(&cpu_hotplug_lock); +} #endif =20 static void lockdep_acquire_cpus_lock(void) --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0E28B2F7AD2; Thu, 1 Jan 2026 22:15:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305753; cv=none; b=GEMKjKeH/WTXS4gulkZVTMUcVcZhh2j8AaYzfMhB9yQZAn04irTFsZkJ0Gu21r+SBwpcqoKhS9kCFo90F+3P+/6pYZhxnQO7t43qnE6z0ADCy9ObsHr1QYo3Hi466WZiQ7RhLD5U2xXhqBat8a0Bc4ohLb3s01hTpRbVchmCBKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305753; c=relaxed/simple; bh=v9YrBjmYoXXJcaUrCVcNEergJy1rpdNBj6w7mIgdodQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JDQt14zvqslTqdnhaMHEETA0EUVcT86dxy54c3LFGsM87BmkVUdw44nl3b+DB4HzqWXt9A+mpoa8ieveHLOVR9lRVSCy9+e54V7ujcPKz2pJwjk1RbKkCGAwJvPZHGmjJ2c0CCIb4On/cjHVTTUvEXso76OA7VfwlaeCPbn6c20= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SyFLLg0i; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SyFLLg0i" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 012EBC116D0; Thu, 1 Jan 2026 22:15:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305752; bh=v9YrBjmYoXXJcaUrCVcNEergJy1rpdNBj6w7mIgdodQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SyFLLg0iW6FU1eawRmvnINnCpxzead2omuxl9REafTvn+PFWHvz19FAsri2C1gbYz nmBMznsPhIHNzpbRATsRTyEQmSHDmZRSJpNzzQHYX4BxZkvQqQciqWraphJHo4otMG yKE6X1B02Y0h85ZIcFaIRchoCui9kzgnkUDtVsfAXxYLAi2HJxIA4Yd0JmB+Pqb/vJ KFlIaxmBoJqkoT94z2kMTPUGJ4vpk1jl7UDtwx5C++CbT7Zm18ygJQdm4fRZr6G4CD Tchm5MK1nQsZUtkbmbGbmnfdRBNoOl6ziRKujJrp7iJG93T0zheiYwTQ4Z5PaQM92J 1KWjLLM8diO1w== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 12/33] cpuset: Provide lockdep check for cpuset lock held Date: Thu, 1 Jan 2026 23:13:37 +0100 Message-ID: <20260101221359.22298-13-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" cpuset modifies partitions, including isolated, while holding the cpuset mutex. This means that holding the cpuset mutex is safe to synchronize against housekeeping cpumask changes. Provide a lockdep check to validate that. Signed-off-by: Frederic Weisbecker --- include/linux/cpuset.h | 2 ++ kernel/cgroup/cpuset.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h index a98d3330385c..1c49ffd2ca9b 100644 --- a/include/linux/cpuset.h +++ b/include/linux/cpuset.h @@ -18,6 +18,8 @@ #include #include =20 +extern bool lockdep_is_cpuset_held(void); + #ifdef CONFIG_CPUSETS =20 /* diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 3afa72f8d579..5e2e3514c22e 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -283,6 +283,13 @@ void cpuset_full_unlock(void) cpus_read_unlock(); } =20 +#ifdef CONFIG_LOCKDEP +bool lockdep_is_cpuset_held(void) +{ + return lockdep_is_held(&cpuset_mutex); +} +#endif + static DEFINE_SPINLOCK(callback_lock); =20 void cpuset_callback_lock_irq(void) --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 AC67D2749ED; Thu, 1 Jan 2026 22:16:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305762; cv=none; b=tI46Tm2065EDWN1U/ggNvFPYVnRXyhYpmEEvJP6BeMmuA3ZKTh3vjAfmqn53KTht24dc+Dpeu3vjam4bdx6uoKXoP4B30psfkZtk/aukteZMmy8G6T+gN0VX7B3vSTLVz0jyDaM3o3KrO4yjQHhZooEYrFu1qVjiWVVlbrV+AWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305762; c=relaxed/simple; bh=iE5HNXxcf5Yij69saaDAoVPz7iPaTsBAd7fg0JUxZYg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P73rtrC0sZ5tiIau3aiGLNeH/304bLJr4dKkCLNr6zxafSApIV9j1N5P+Qy/Rz30eDAUuH49S7spTrcuvtv3KQ6ekU/g0EOKHt/RjB58kVgrz6fH3T4GLkiC3CusmNabEzTVMdPe2vqTdkh2vT60y2kZMBwGPSgDToK64CjZ9WY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=muHvVB3a; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="muHvVB3a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2894CC4CEF7; Thu, 1 Jan 2026 22:15:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305761; bh=iE5HNXxcf5Yij69saaDAoVPz7iPaTsBAd7fg0JUxZYg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=muHvVB3a10Akl60W77jSSqSOLSGnLSzt0LX9ziUqhp8Su9a3CdhYAPDfiUBa8doE1 r2Uad3NKMWcSZCcgNPa9ukJd+x1X/iyvE6FcC0ciaQ48TMVcUN4ydVTs45NjRjDQOP ZNNBLqnW+1U3ELu0rDwrTFpZXz6tzS358v0g/cnSG4YYRsQ0dkTLH49M5MXv5F4aMs 0o48Y4d8UZFG/chECMx8CaKk+tLHp/fsT2Gc+3UJWOkH2OvtaGfXgZIUa0xoSh7sTh zPYWTnu9hq3WwMWJ3hibzDCEkzgcW2+xU7Xi8XbeAlobi16xrWr1aOHydKIAcItS3f OYx8qbidzQB9w== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 13/33] sched/isolation: Convert housekeeping cpumasks to rcu pointers Date: Thu, 1 Jan 2026 23:13:38 +0100 Message-ID: <20260101221359.22298-14-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" HK_TYPE_DOMAIN's cpumask will soon be made modifiable by cpuset. A synchronization mechanism is then needed to synchronize the updates with the housekeeping cpumask readers. Turn the housekeeping cpumasks into RCU pointers. Once a housekeeping cpumask will be modified, the update side will wait for an RCU grace period and propagate the change to interested subsystem when deemed necessary. Signed-off-by: Frederic Weisbecker --- kernel/sched/isolation.c | 58 +++++++++++++++++++++++++--------------- kernel/sched/sched.h | 1 + 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index 11a623fa6320..83be49ec2b06 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -21,7 +21,7 @@ DEFINE_STATIC_KEY_FALSE(housekeeping_overridden); EXPORT_SYMBOL_GPL(housekeeping_overridden); =20 struct housekeeping { - cpumask_var_t cpumasks[HK_TYPE_MAX]; + struct cpumask __rcu *cpumasks[HK_TYPE_MAX]; unsigned long flags; }; =20 @@ -33,17 +33,28 @@ bool housekeeping_enabled(enum hk_type type) } EXPORT_SYMBOL_GPL(housekeeping_enabled); =20 +const struct cpumask *housekeeping_cpumask(enum hk_type type) +{ + if (static_branch_unlikely(&housekeeping_overridden)) { + if (housekeeping.flags & BIT(type)) { + return rcu_dereference_check(housekeeping.cpumasks[type], 1); + } + } + return cpu_possible_mask; +} +EXPORT_SYMBOL_GPL(housekeeping_cpumask); + int housekeeping_any_cpu(enum hk_type type) { int cpu; =20 if (static_branch_unlikely(&housekeeping_overridden)) { if (housekeeping.flags & BIT(type)) { - cpu =3D sched_numa_find_closest(housekeeping.cpumasks[type], smp_proces= sor_id()); + cpu =3D sched_numa_find_closest(housekeeping_cpumask(type), smp_process= or_id()); if (cpu < nr_cpu_ids) return cpu; =20 - cpu =3D cpumask_any_and_distribute(housekeeping.cpumasks[type], cpu_onl= ine_mask); + cpu =3D cpumask_any_and_distribute(housekeeping_cpumask(type), cpu_onli= ne_mask); if (likely(cpu < nr_cpu_ids)) return cpu; /* @@ -59,28 +70,18 @@ int housekeeping_any_cpu(enum hk_type type) } EXPORT_SYMBOL_GPL(housekeeping_any_cpu); =20 -const struct cpumask *housekeeping_cpumask(enum hk_type type) -{ - if (static_branch_unlikely(&housekeeping_overridden)) - if (housekeeping.flags & BIT(type)) - return housekeeping.cpumasks[type]; - return cpu_possible_mask; -} -EXPORT_SYMBOL_GPL(housekeeping_cpumask); - void housekeeping_affine(struct task_struct *t, enum hk_type type) { if (static_branch_unlikely(&housekeeping_overridden)) if (housekeeping.flags & BIT(type)) - set_cpus_allowed_ptr(t, housekeeping.cpumasks[type]); + set_cpus_allowed_ptr(t, housekeeping_cpumask(type)); } EXPORT_SYMBOL_GPL(housekeeping_affine); =20 bool housekeeping_test_cpu(int cpu, enum hk_type type) { - if (static_branch_unlikely(&housekeeping_overridden)) - if (housekeeping.flags & BIT(type)) - return cpumask_test_cpu(cpu, housekeeping.cpumasks[type]); + if (static_branch_unlikely(&housekeeping_overridden) && housekeeping.flag= s & BIT(type)) + return cpumask_test_cpu(cpu, housekeeping_cpumask(type)); return true; } EXPORT_SYMBOL_GPL(housekeeping_test_cpu); @@ -96,20 +97,33 @@ void __init housekeeping_init(void) =20 if (housekeeping.flags & HK_FLAG_KERNEL_NOISE) sched_tick_offload_init(); - + /* + * Realloc with a proper allocator so that any cpumask update + * can indifferently free the old version with kfree(). + */ for_each_set_bit(type, &housekeeping.flags, HK_TYPE_MAX) { + struct cpumask *omask, *nmask =3D kmalloc(cpumask_size(), GFP_KERNEL); + + if (WARN_ON_ONCE(!nmask)) + return; + + omask =3D rcu_dereference(housekeeping.cpumasks[type]); + /* We need at least one CPU to handle housekeeping work */ - WARN_ON_ONCE(cpumask_empty(housekeeping.cpumasks[type])); + WARN_ON_ONCE(cpumask_empty(omask)); + cpumask_copy(nmask, omask); + RCU_INIT_POINTER(housekeeping.cpumasks[type], nmask); + memblock_free(omask, cpumask_size()); } } =20 static void __init housekeeping_setup_type(enum hk_type type, cpumask_var_t housekeeping_staging) { + struct cpumask *mask =3D memblock_alloc_or_panic(cpumask_size(), SMP_CACH= E_BYTES); =20 - alloc_bootmem_cpumask_var(&housekeeping.cpumasks[type]); - cpumask_copy(housekeeping.cpumasks[type], - housekeeping_staging); + cpumask_copy(mask, housekeeping_staging); + RCU_INIT_POINTER(housekeeping.cpumasks[type], mask); } =20 static int __init housekeeping_setup(char *str, unsigned long flags) @@ -162,7 +176,7 @@ static int __init housekeeping_setup(char *str, unsigne= d long flags) =20 for_each_set_bit(type, &iter_flags, HK_TYPE_MAX) { if (!cpumask_equal(housekeeping_staging, - housekeeping.cpumasks[type])) { + housekeeping_cpumask(type))) { pr_warn("Housekeeping: nohz_full=3D must match isolcpus=3D\n"); goto free_housekeeping_staging; } diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index d30cca6870f5..475bdab3b8db 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3E7812773CC; Thu, 1 Jan 2026 22:16:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305770; cv=none; b=K60Wc8wCnVQuiSl6Kis77nIzzuDG34iIMyGK4CECVGKn6va5VM47rQZWak30g8yVhwhaeL8jn0/memEdpRdIXOqYBM+Eljr0mHy+J87EPJvyz1pjkOORmaOsgpJZwn/70ak/uSzAPGY+luczqmxduZhBH/gq23z6DGXhH3HYl7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305770; c=relaxed/simple; bh=VAVvGGk/hiYe7kjBfHlKrxagm/s+WZiujWOCUr5/KMc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XSDEjiEJD8zlPhdRp6+UuE6unRMVM4FOdYK5bfhvo+0cxC3HhbV08OZi3uSeiTsqAiBwMt1uL4npgCg9x/TsLBsnMWRcUU/5erch6NFVlLGOquZ7l5JTRB+KzJRb8yvDg2lxPIXyupdlgw0uKjf/EV6WxquGP95nsN1gqKkuOvA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Or8D/OE3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Or8D/OE3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F599C116D0; Thu, 1 Jan 2026 22:16:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305769; bh=VAVvGGk/hiYe7kjBfHlKrxagm/s+WZiujWOCUr5/KMc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Or8D/OE3F2iQfSIvSaoXDKbg9oFgW+rpKcnzQGY+gFnOYUZtRGV7UtWFFP4izlopy 4CK5PEd5uY8upkFN/kQtdH9NOegBYBZZ8SfOUzzakWo1O3NkV+T0hwu8HrFu4q9Oxb rwXkJmmLrN7Ge64/Ly858e+xoEkjVByZxPUipVCsr5RC3qsPe+tf7JJphMS/wGTvu8 XNqcBnyDOlLj336DWBL66IwkB09N3yCqTVSbH6QpElPuD7lQnLPkjpsL6jynORQMzM wKesaDtmsEvmS26yYyguSew9HsU1mX++gy2/wObf6BqsrRbV6/eW9m/euUQgjzDQsz J60SHWUw5RlRA== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 14/33] cpuset: Update HK_TYPE_DOMAIN cpumask from cpuset Date: Thu, 1 Jan 2026 23:13:39 +0100 Message-ID: <20260101221359.22298-15-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Until now, HK_TYPE_DOMAIN used to only include boot defined isolated CPUs passed through isolcpus=3D boot option. Users interested in also knowing the runtime defined isolated CPUs through cpuset must use different APIs: cpuset_cpu_is_isolated(), cpu_is_isolated(), etc... There are many drawbacks to that approach: 1) Most interested subsystems want to know about all isolated CPUs, not just those defined on boot time. 2) cpuset_cpu_is_isolated() / cpu_is_isolated() are not synchronized with concurrent cpuset changes. 3) Further cpuset modifications are not propagated to subsystems Solve 1) and 2) and centralize all isolated CPUs within the HK_TYPE_DOMAIN housekeeping cpumask. Subsystems can rely on RCU to synchronize against concurrent changes. The propagation mentioned in 3) will be handled in further patches. Signed-off-by: Frederic Weisbecker Reviewed-by: Waiman Long Reviewed-by: Chen Ridong --- include/linux/sched/isolation.h | 7 ++++ kernel/cgroup/cpuset.c | 3 ++ kernel/sched/isolation.c | 73 ++++++++++++++++++++++++++++++--- kernel/sched/sched.h | 1 + 4 files changed, 78 insertions(+), 6 deletions(-) diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolatio= n.h index c7cf6934489c..d8d9baf44516 100644 --- a/include/linux/sched/isolation.h +++ b/include/linux/sched/isolation.h @@ -9,6 +9,11 @@ enum hk_type { /* Inverse of boot-time isolcpus=3D argument */ HK_TYPE_DOMAIN_BOOT, + /* + * Same as HK_TYPE_DOMAIN_BOOT but also includes the + * inverse of cpuset isolated partitions. As such it + * is always a subset of HK_TYPE_DOMAIN_BOOT. + */ HK_TYPE_DOMAIN, /* Inverse of boot-time isolcpus=3Dmanaged_irq argument */ HK_TYPE_MANAGED_IRQ, @@ -35,6 +40,7 @@ extern const struct cpumask *housekeeping_cpumask(enum hk= _type type); extern bool housekeeping_enabled(enum hk_type type); extern void housekeeping_affine(struct task_struct *t, enum hk_type type); extern bool housekeeping_test_cpu(int cpu, enum hk_type type); +extern int housekeeping_update(struct cpumask *isol_mask); extern void __init housekeeping_init(void); =20 #else @@ -62,6 +68,7 @@ static inline bool housekeeping_test_cpu(int cpu, enum hk= _type type) return true; } =20 +static inline int housekeeping_update(struct cpumask *isol_mask) { return = 0; } static inline void housekeeping_init(void) { } #endif /* CONFIG_CPU_ISOLATION */ =20 diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 5e2e3514c22e..1c0475e384dc 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1490,6 +1490,9 @@ static void update_isolation_cpumasks(void) ret =3D tmigr_isolated_exclude_cpumask(isolated_cpus); WARN_ON_ONCE(ret < 0); =20 + ret =3D housekeeping_update(isolated_cpus); + WARN_ON_ONCE(ret < 0); + isolated_cpus_updating =3D false; } =20 diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index 83be49ec2b06..c61b7ef3e98e 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -29,18 +29,48 @@ static struct housekeeping housekeeping; =20 bool housekeeping_enabled(enum hk_type type) { - return !!(housekeeping.flags & BIT(type)); + return !!(READ_ONCE(housekeeping.flags) & BIT(type)); } EXPORT_SYMBOL_GPL(housekeeping_enabled); =20 +static bool housekeeping_dereference_check(enum hk_type type) +{ + if (IS_ENABLED(CONFIG_LOCKDEP) && type =3D=3D HK_TYPE_DOMAIN) { + /* Cpuset isn't even writable yet? */ + if (system_state <=3D SYSTEM_SCHEDULING) + return true; + + /* CPU hotplug write locked, so cpuset partition can't be overwritten */ + if (IS_ENABLED(CONFIG_HOTPLUG_CPU) && lockdep_is_cpus_write_held()) + return true; + + /* Cpuset lock held, partitions not writable */ + if (IS_ENABLED(CONFIG_CPUSETS) && lockdep_is_cpuset_held()) + return true; + + return false; + } + + return true; +} + +static inline struct cpumask *housekeeping_cpumask_dereference(enum hk_typ= e type) +{ + return rcu_dereference_all_check(housekeeping.cpumasks[type], + housekeeping_dereference_check(type)); +} + const struct cpumask *housekeeping_cpumask(enum hk_type type) { + const struct cpumask *mask =3D NULL; + if (static_branch_unlikely(&housekeeping_overridden)) { - if (housekeeping.flags & BIT(type)) { - return rcu_dereference_check(housekeeping.cpumasks[type], 1); - } + if (READ_ONCE(housekeeping.flags) & BIT(type)) + mask =3D housekeeping_cpumask_dereference(type); } - return cpu_possible_mask; + if (!mask) + mask =3D cpu_possible_mask; + return mask; } EXPORT_SYMBOL_GPL(housekeeping_cpumask); =20 @@ -80,12 +110,43 @@ EXPORT_SYMBOL_GPL(housekeeping_affine); =20 bool housekeeping_test_cpu(int cpu, enum hk_type type) { - if (static_branch_unlikely(&housekeeping_overridden) && housekeeping.flag= s & BIT(type)) + if (static_branch_unlikely(&housekeeping_overridden) && + READ_ONCE(housekeeping.flags) & BIT(type)) return cpumask_test_cpu(cpu, housekeeping_cpumask(type)); return true; } EXPORT_SYMBOL_GPL(housekeeping_test_cpu); =20 +int housekeeping_update(struct cpumask *isol_mask) +{ + struct cpumask *trial, *old =3D NULL; + + trial =3D kmalloc(cpumask_size(), GFP_KERNEL); + if (!trial) + return -ENOMEM; + + cpumask_andnot(trial, housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT), isol_mas= k); + if (!cpumask_intersects(trial, cpu_online_mask)) { + kfree(trial); + return -EINVAL; + } + + if (!housekeeping.flags) + static_branch_enable(&housekeeping_overridden); + + if (housekeeping.flags & HK_FLAG_DOMAIN) + old =3D housekeeping_cpumask_dereference(HK_TYPE_DOMAIN); + else + WRITE_ONCE(housekeeping.flags, housekeeping.flags | HK_FLAG_DOMAIN); + rcu_assign_pointer(housekeeping.cpumasks[HK_TYPE_DOMAIN], trial); + + synchronize_rcu(); + + kfree(old); + + return 0; +} + void __init housekeeping_init(void) { enum hk_type type; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 475bdab3b8db..653e898a996a 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 04EBE25B2F4; Thu, 1 Jan 2026 22:16:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305778; cv=none; b=DVHOOrgOz4m1YGdydxbJtPqiq6XqHpGmDBNcXYThqEktbH3C8vDTA3KhHc0EAbAObbT5U7lFVs+0zOv9IJmFGX3TpMkZO48VRbooZVAMAy1gCZxdTThQsVTFCp1legTZkbAuRBh00FxuBWNhjgTe/2lcsTEsQqHwVcRyQOLxLdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305778; c=relaxed/simple; bh=dl/Gl7INrr4v6VbmH2ZxbRJCGrPgSwdt0Po/w4pDxAs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J5dF/cWyuyJE93lPMumgmlUEI/dRHuILT8DiDVNjZeTTmyD5PXi7tuXc4+34WA6ohtkdPeDjQVJheLY3HFLWtqSbTIzwIgKGz2eAW45F4u/4/1tfWrqtXECaDVmGbr7/x3fNzaeiRa9lnW6eUkWh/UMUxkf/7ifFJe8x/seNAXE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tE9ASF2s; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tE9ASF2s" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D504C19422; Thu, 1 Jan 2026 22:16:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305777; bh=dl/Gl7INrr4v6VbmH2ZxbRJCGrPgSwdt0Po/w4pDxAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tE9ASF2sUjjhls9gA7k5g71gEtpYoRfUnZFPFHh3murIT3cAGCQrlbuYA3q7Vygaf pUXdGKf8D/FpxTsH9vIINsIYaDEwekDRq1+dbT9B5ZKgPWrXm39XIVnHCQS2HdlrL/ B5tY4zv34wQKj3uOvnIxCNveQ5SIy8Pdzzz4UhJnfraBdfBnK2xCfB90p7LrRbch0q p3AWNAk6UKrkLcFOT3mqiEdqmsdkyr9V/G/DP+c9e/ufCXoqliVrRjNS2Y+UCKdvYX Ri88SSuI/C7wsddEehR5NWB5Zx76VDYmaM9jiJ/Usx2GOwCihgjnvf7CZ9jXjbKFrS L7EjFh/Xthybw== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 15/33] sched/isolation: Flush memcg workqueues on cpuset isolated partition change Date: Thu, 1 Jan 2026 23:13:40 +0100 Message-ID: <20260101221359.22298-16-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The HK_TYPE_DOMAIN housekeeping cpumask is now modifiable at runtime. In order to synchronize against memcg workqueue to make sure that no asynchronous draining is still pending or executing on a newly made isolated CPU, the housekeeping susbsystem must flush the memcg workqueues. However the memcg workqueues can't be flushed easily since they are queued to the main per-CPU workqueue pool. Solve this with creating a memcg specific pool and provide and use the appropriate flushing API. Acked-by: Shakeel Butt Signed-off-by: Frederic Weisbecker --- include/linux/memcontrol.h | 4 ++++ kernel/sched/isolation.c | 2 ++ kernel/sched/sched.h | 1 + mm/memcontrol.c | 12 +++++++++++- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 0651865a4564..5b004b95648b 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1037,6 +1037,8 @@ static inline u64 cgroup_id_from_mm(struct mm_struct = *mm) return id; } =20 +void mem_cgroup_flush_workqueue(void); + extern int mem_cgroup_init(void); #else /* CONFIG_MEMCG */ =20 @@ -1436,6 +1438,8 @@ static inline u64 cgroup_id_from_mm(struct mm_struct = *mm) return 0; } =20 +static inline void mem_cgroup_flush_workqueue(void) { } + static inline int mem_cgroup_init(void) { return 0; } #endif /* CONFIG_MEMCG */ =20 diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index c61b7ef3e98e..b5f9f974eac9 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -142,6 +142,8 @@ int housekeeping_update(struct cpumask *isol_mask) =20 synchronize_rcu(); =20 + mem_cgroup_flush_workqueue(); + kfree(old); =20 return 0; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 653e898a996a..65dfa48e54b7 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 2289a0299331..b3ca241bb1d6 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -96,6 +96,8 @@ static bool cgroup_memory_nokmem __ro_after_init; /* BPF memory accounting disabled? */ static bool cgroup_memory_nobpf __ro_after_init; =20 +static struct workqueue_struct *memcg_wq __ro_after_init; + static struct kmem_cache *memcg_cachep; static struct kmem_cache *memcg_pn_cachep; =20 @@ -2013,7 +2015,7 @@ static void schedule_drain_work(int cpu, struct work_= struct *work) */ guard(rcu)(); if (!cpu_is_isolated(cpu)) - schedule_work_on(cpu, work); + queue_work_on(cpu, memcg_wq, work); } =20 /* @@ -5125,6 +5127,11 @@ void mem_cgroup_sk_uncharge(const struct sock *sk, u= nsigned int nr_pages) refill_stock(memcg, nr_pages); } =20 +void mem_cgroup_flush_workqueue(void) +{ + flush_workqueue(memcg_wq); +} + static int __init cgroup_memory(char *s) { char *token; @@ -5167,6 +5174,9 @@ int __init mem_cgroup_init(void) cpuhp_setup_state_nocalls(CPUHP_MM_MEMCQ_DEAD, "mm/memctrl:dead", NULL, memcg_hotplug_cpu_dead); =20 + memcg_wq =3D alloc_workqueue("memcg", WQ_PERCPU, 0); + WARN_ON(!memcg_wq); + for_each_possible_cpu(cpu) { INIT_WORK(&per_cpu_ptr(&memcg_stock, cpu)->work, drain_local_memcg_stock); --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6C1CC2FDC22; Thu, 1 Jan 2026 22:16:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305785; cv=none; b=E0eWbA0Bqyfl4XlYV+/xfrKGzXxA7sr2rMYcZYm8lrT9Y8pehvmMqeN5pbfvnngd9f6MjgC2gRGSnezOm5BKhZnmLNwZ62H2FeAU27yHOgI2A3SnzdXmtCX6g10MSySbAU77c10/bFsitZJszeZPB+/eBj4WPAzJScZP+6pOd6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305785; c=relaxed/simple; bh=Ma4KHLlhGG+Y/BxDbCqZKmzyoCP7GgnhhguTZEp+mhM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b8AwNppmDftSWN6PJzNVZQDP+pDz3kWSRTbLlI1W0JnlQRuDnN+tqPkL4ESbf0P6iqXEzmmQ9p4dxWf5YJ3iiQ/rtq1pkjF0lvr2SJSUfiK/dOIqFvH13xVws6/OYHlCjlzQDKMpQBwL3l5FD7+/UIDUycK+w4AS59CmJ3l1IXc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vDQ2VZez; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vDQ2VZez" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01E39C4CEF7; Thu, 1 Jan 2026 22:16:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305785; bh=Ma4KHLlhGG+Y/BxDbCqZKmzyoCP7GgnhhguTZEp+mhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vDQ2VZezadsNVrv+yy5BwTYGs134lyzcTXGJaAR/0lCPMAKylClmPO9iy5OmPLCPC QkM90JtfvR1yW9W6KOSAtGT+EFjTxk/GJFj98bTOy2zYD/xXTiqXUJeEkt+tk7jAvt p/J6BIdd4CadQv6Z41u2gAPQALvHUERjY9JVmgZiJO/Smg1XCERmubpyST07qshx86 BM6hE176wATZGpOVO8twZjYsGfelV0voPrZlhfYDNWsuXO2jJ/fDN0lGTrrL4jRE2x 4IgriVAzgpcgDnkDKxjeJMQXwToxuKuirS/ogYI4xPehn0EHh+L/RT01vcaIied5Cv mCIF4K7Bad2fg== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 16/33] sched/isolation: Flush vmstat workqueues on cpuset isolated partition change Date: Thu, 1 Jan 2026 23:13:41 +0100 Message-ID: <20260101221359.22298-17-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The HK_TYPE_DOMAIN housekeeping cpumask is now modifiable at runtime. In order to synchronize against vmstat workqueue to make sure that no asynchronous vmstat work is still pending or executing on a newly made isolated CPU, the housekeeping susbsystem must flush the vmstat workqueues. This involves flushing the whole mm_percpu_wq workqueue, shared with LRU drain, introducing here a welcome side effect. Signed-off-by: Frederic Weisbecker --- include/linux/vmstat.h | 2 ++ kernel/sched/isolation.c | 1 + kernel/sched/sched.h | 1 + mm/vmstat.c | 5 +++++ 4 files changed, 9 insertions(+) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 3398a345bda8..1909b945b3ea 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -303,6 +303,7 @@ int calculate_pressure_threshold(struct zone *zone); int calculate_normal_threshold(struct zone *zone); void set_pgdat_percpu_threshold(pg_data_t *pgdat, int (*calculate_pressure)(struct zone *)); +void vmstat_flush_workqueue(void); #else /* CONFIG_SMP */ =20 /* @@ -403,6 +404,7 @@ static inline void __dec_node_page_state(struct page *p= age, static inline void refresh_zone_stat_thresholds(void) { } static inline void cpu_vm_stats_fold(int cpu) { } static inline void quiet_vmstat(void) { } +static inline void vmstat_flush_workqueue(void) { } =20 static inline void drain_zonestat(struct zone *zone, struct per_cpu_zonestat *pzstats) { } diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index b5f9f974eac9..ec3f15164fd1 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -143,6 +143,7 @@ int housekeeping_update(struct cpumask *isol_mask) synchronize_rcu(); =20 mem_cgroup_flush_workqueue(); + vmstat_flush_workqueue(); =20 kfree(old); =20 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 65dfa48e54b7..2d0c408fca0b 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include diff --git a/mm/vmstat.c b/mm/vmstat.c index ed19c0d42de6..d6e814c82952 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -2124,6 +2124,11 @@ static void vmstat_shepherd(struct work_struct *w); =20 static DECLARE_DEFERRABLE_WORK(shepherd, vmstat_shepherd); =20 +void vmstat_flush_workqueue(void) +{ + flush_workqueue(mm_percpu_wq); +} + static void vmstat_shepherd(struct work_struct *w) { int cpu; --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 809BB2FF148; Thu, 1 Jan 2026 22:16:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305793; cv=none; b=CGFesCTFMyaStD21+cG8GjOY7t79SYeF2qNtcokyq4QJjrDzdIitJdq0P6XeAX8pa/0PVse+SKWv+7ewAGRAgSzuOidocWplJRElAzhV7YBT981Js0p2y7GZGPbCmfyzwROp+med/EIj3v343OLyye6MxHYda5C4lmw39gRaGeM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305793; c=relaxed/simple; bh=zo5aSfx0QMPboEF9rtQzkEKHHU4qfSe8IulGuelb3CM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r9rC9J6BFz6XbLehUabbjpn23dnFdmHsJPE5n6l+meIw9FOWphwP1u65XunSh71PWm9ajkP+H9E8hMPXbuW0VKMHS/IEHl1GWQ2qAWxvakvTlQkN3MnVO5ChCKo5ZaR8Squj/9FHEzFfIza+r1uvF44ee+opqHBQ5gYdE57hmMQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=u9tYFxpS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="u9tYFxpS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7D5FC4CEF7; Thu, 1 Jan 2026 22:16:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305793; bh=zo5aSfx0QMPboEF9rtQzkEKHHU4qfSe8IulGuelb3CM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u9tYFxpSYf2EKg3LeJ/BtkTuCPU9/7dT78WisN7MsccYOL1QHOblp04XVLBMNEwNj Mh8U2spUyrhiJe8m5+VHU3f7oIGLsOOKSSXslxXcFB4f/pba3lwajZoONzqVrh7gdf YOspVtG+Metqa5k6ARTlWvkA6QJveUHG5hrI8G0JOKUikcHidi2E+ApPG0Qqnv8lpU ZQ82Zy4ZdHegSVFS8OXE0/OnFJWOKXtOCm1E2dFG2HpUqlPP9hNAcl5tLwu7A3XWtS boXzsWts9BMQaOG9OW8FSoOnj5eMdWd1TOkunLzcfZisfxU/6M8mavVCFQLbVzucKF 5aYSZvL5g4iJQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 17/33] PCI: Flush PCI probe workqueue on cpuset isolated partition change Date: Thu, 1 Jan 2026 23:13:42 +0100 Message-ID: <20260101221359.22298-18-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The HK_TYPE_DOMAIN housekeeping cpumask is now modifiable at runtime. In order to synchronize against PCI probe works and make sure that no asynchronous probing is still pending or executing on a newly isolated CPU, the housekeeping subsystem must flush the PCI probe works. However the PCI probe works can't be flushed easily since they are queued to the main per-CPU workqueue pool. Solve this with creating a PCI probe-specific pool and provide and use the appropriate flushing API. Signed-off-by: Frederic Weisbecker Acked-by: Bjorn Helgaas --- drivers/pci/pci-driver.c | 17 ++++++++++++++++- include/linux/pci.h | 3 +++ kernel/sched/isolation.c | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index a6111140755c..b902d8adf9a5 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -337,6 +337,8 @@ static int local_pci_probe(struct drv_dev_and_id *ddi) return 0; } =20 +static struct workqueue_struct *pci_probe_wq; + struct pci_probe_arg { struct drv_dev_and_id *ddi; struct work_struct work; @@ -407,7 +409,11 @@ static int pci_call_probe(struct pci_driver *drv, stru= ct pci_dev *dev, cpu =3D cpumask_any_and(cpumask_of_node(node), wq_domain_mask); if (cpu < nr_cpu_ids) { - schedule_work_on(cpu, &arg.work); + struct workqueue_struct *wq =3D pci_probe_wq; + + if (WARN_ON_ONCE(!wq)) + wq =3D system_percpu_wq; + queue_work_on(cpu, wq, &arg.work); rcu_read_unlock(); flush_work(&arg.work); error =3D arg.ret; @@ -425,6 +431,11 @@ static int pci_call_probe(struct pci_driver *drv, stru= ct pci_dev *dev, return error; } =20 +void pci_probe_flush_workqueue(void) +{ + flush_workqueue(pci_probe_wq); +} + /** * __pci_device_probe - check if a driver wants to claim a specific PCI de= vice * @drv: driver to call to check if it wants the PCI device @@ -1762,6 +1773,10 @@ static int __init pci_driver_init(void) { int ret; =20 + pci_probe_wq =3D alloc_workqueue("sync_wq", WQ_PERCPU, 0); + if (!pci_probe_wq) + return -ENOMEM; + ret =3D bus_register(&pci_bus_type); if (ret) return ret; diff --git a/include/linux/pci.h b/include/linux/pci.h index 864775651c6f..f14f467e50de 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1206,6 +1206,7 @@ struct pci_bus *pci_create_root_bus(struct device *pa= rent, int bus, struct pci_ops *ops, void *sysdata, struct list_head *resources); int pci_host_probe(struct pci_host_bridge *bridge); +void pci_probe_flush_workqueue(void); int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int busmax); int pci_bus_update_busn_res_end(struct pci_bus *b, int busmax); void pci_bus_release_busn_res(struct pci_bus *b); @@ -2079,6 +2080,8 @@ static inline int pci_has_flag(int flag) { return 0; } _PCI_NOP_ALL(read, *) _PCI_NOP_ALL(write,) =20 +static inline void pci_probe_flush_workqueue(void) { } + static inline struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device, struct pci_dev *from) diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index ec3f15164fd1..5239f556745d 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -8,6 +8,7 @@ * */ #include +#include #include "sched.h" =20 enum hk_flags { @@ -142,6 +143,7 @@ int housekeeping_update(struct cpumask *isol_mask) =20 synchronize_rcu(); =20 + pci_probe_flush_workqueue(); mem_cgroup_flush_workqueue(); vmstat_flush_workqueue(); =20 --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 AF3AA3002B9; Thu, 1 Jan 2026 22:16:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305801; cv=none; b=LnbtI125ufnaofCjZAP0s6l+drJC/9bAW0gDMsaCY6lb9BcN9JvYIOPcP3oyy+gR95HdqBCUE+f1nNFnFGKLd1BX67YyUUr6xl8puEjumVmCvSrcCFbHj+KQuwcTr35ehjTsiD/4bk94+cPbpcUqQtEL9wFzuqVYjN7SlIhUShA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305801; c=relaxed/simple; bh=tu0Lky1m6SezXDNrHXq/nqZLGO2PMXmZz7CmrPNyvdU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Uq/hF9Xn4OxXMt+7uAAbPLyOwgPuRKy+ybiGS31/ZVM+M5dm3omGs4rJVn0iSb+78n7toLhA9sBLUPCZLWqbda07l3bFY0L8Nu9Lcaks6heiGd+jSCNhYgm9Cu/h+nIxKTLQHOP+RPGTEy//WdpWURdLbR0RoFik1TGzpKy/wOc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RlhVF70R; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RlhVF70R" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF2E4C4CEF7; Thu, 1 Jan 2026 22:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305801; bh=tu0Lky1m6SezXDNrHXq/nqZLGO2PMXmZz7CmrPNyvdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RlhVF70R2AS65IRO8RII+UUUzNJvMlGQuAXpStDftU6+lQxMvG6CvCo0T4ebR1GHD KlemMADSBO0tvUv0JMxOQi7RwC2e5e9qOd+wDiuvFMg/edsouocn8bnuJoESu1XhRh QuXEEBx8UVESHmdRJLs0dX2OXFAV2XWAoFGqHwHDWsKOJg9aibmeBgVYXX0v6lMSvB +HPmgBG6Gck9OZ7A0k1ClGdpKiq0hYFF4Y8QBbkBJBvCp9I5cerain9DStAsMVmlPT rd7kxh18ZUP43Z72fmFx+NnjMAUkUDL3bNYP7U4ceR5rMhiU1AMUNbQkirgphi0P3e XtpkPNO/7faLQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 18/33] cpuset: Propagate cpuset isolation update to workqueue through housekeeping Date: Thu, 1 Jan 2026 23:13:43 +0100 Message-ID: <20260101221359.22298-19-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> 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="utf-8" Content-Transfer-Encoding: quoted-printable Until now, cpuset would propagate isolated partition changes to workqueues so that unbound workers get properly reaffined. Since housekeeping now centralizes, synchronize and propagates isolation cpumask changes, perform the work from that subsystem for consolidation and consistency purposes. For simplification purpose, the target function is adapted to take the new housekeeping mask instead of the isolated mask. Suggested-by: Tejun Heo Signed-off-by: Frederic Weisbecker Reviewed-by: Waiman Long Acked-by: Tejun Heo --- include/linux/workqueue.h | 2 +- init/Kconfig | 1 + kernel/cgroup/cpuset.c | 9 +++------ kernel/sched/isolation.c | 3 +++ kernel/workqueue.c | 17 ++++++++++------- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index dabc351cc127..a4749f56398f 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -588,7 +588,7 @@ struct workqueue_attrs *alloc_workqueue_attrs_noprof(vo= id); void free_workqueue_attrs(struct workqueue_attrs *attrs); int apply_workqueue_attrs(struct workqueue_struct *wq, const struct workqueue_attrs *attrs); -extern int workqueue_unbound_exclude_cpumask(cpumask_var_t cpumask); +extern int workqueue_unbound_housekeeping_update(const struct cpumask *hk); =20 extern bool queue_work_on(int cpu, struct workqueue_struct *wq, struct work_struct *work); diff --git a/init/Kconfig b/init/Kconfig index fa79feb8fe57..518830fb812f 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1254,6 +1254,7 @@ config CPUSETS bool "Cpuset controller" depends on SMP select UNION_FIND + select CPU_ISOLATION help This option will let you create and manage CPUSETs which allow dynamically partitioning a system into sets of CPUs and diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 1c0475e384dc..ea9925652d99 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1484,15 +1484,12 @@ static void update_isolation_cpumasks(void) =20 lockdep_assert_cpus_held(); =20 - ret =3D workqueue_unbound_exclude_cpumask(isolated_cpus); - WARN_ON_ONCE(ret < 0); - - ret =3D tmigr_isolated_exclude_cpumask(isolated_cpus); - WARN_ON_ONCE(ret < 0); - ret =3D housekeeping_update(isolated_cpus); WARN_ON_ONCE(ret < 0); =20 + ret =3D tmigr_isolated_exclude_cpumask(isolated_cpus); + WARN_ON_ONCE(ret < 0); + isolated_cpus_updating =3D false; } =20 diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index 5239f556745d..2f4f184cef2b 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -121,6 +121,7 @@ EXPORT_SYMBOL_GPL(housekeeping_test_cpu); int housekeeping_update(struct cpumask *isol_mask) { struct cpumask *trial, *old =3D NULL; + int err; =20 trial =3D kmalloc(cpumask_size(), GFP_KERNEL); if (!trial) @@ -146,6 +147,8 @@ int housekeeping_update(struct cpumask *isol_mask) pci_probe_flush_workqueue(); mem_cgroup_flush_workqueue(); vmstat_flush_workqueue(); + err =3D workqueue_unbound_housekeeping_update(housekeeping_cpumask(HK_TYP= E_DOMAIN)); + WARN_ON_ONCE(err < 0); =20 kfree(old); =20 diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 253311af47c6..eb5660013222 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -6959,13 +6959,16 @@ static int workqueue_apply_unbound_cpumask(const cp= umask_var_t unbound_cpumask) } =20 /** - * workqueue_unbound_exclude_cpumask - Exclude given CPUs from unbound cpu= mask - * @exclude_cpumask: the cpumask to be excluded from wq_unbound_cpumask + * workqueue_unbound_housekeeping_update - Propagate housekeeping cpumask = update + * @hk: the new housekeeping cpumask * - * This function can be called from cpuset code to provide a set of isolat= ed - * CPUs that should be excluded from wq_unbound_cpumask. + * Update the unbound workqueue cpumask on top of the new housekeeping cpu= mask such + * that the effective unbound affinity is the intersection of the new hous= ekeeping + * with the requested affinity set via nohz_full=3D/isolcpus=3D or sysfs. + * + * Return: 0 on success and -errno on failure. */ -int workqueue_unbound_exclude_cpumask(cpumask_var_t exclude_cpumask) +int workqueue_unbound_housekeeping_update(const struct cpumask *hk) { cpumask_var_t cpumask; int ret =3D 0; @@ -6981,14 +6984,14 @@ int workqueue_unbound_exclude_cpumask(cpumask_var_t= exclude_cpumask) * (HK_TYPE_WQ =E2=88=A9 HK_TYPE_DOMAIN) house keeping mask and rewritten * by any subsequent write to workqueue/cpumask sysfs file. */ - if (!cpumask_andnot(cpumask, wq_requested_unbound_cpumask, exclude_cpumas= k)) + if (!cpumask_and(cpumask, wq_requested_unbound_cpumask, hk)) cpumask_copy(cpumask, wq_requested_unbound_cpumask); if (!cpumask_equal(cpumask, wq_unbound_cpumask)) ret =3D workqueue_apply_unbound_cpumask(cpumask); =20 /* Save the current isolated cpumask & export it via sysfs */ if (!ret) - cpumask_copy(wq_isolated_cpumask, exclude_cpumask); + cpumask_andnot(wq_isolated_cpumask, cpu_possible_mask, hk); =20 mutex_unlock(&wq_pool_mutex); free_cpumask_var(cpumask); --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 23F0D301702; Thu, 1 Jan 2026 22:16:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305810; cv=none; b=nXm2RbfIfepbo+LMmTtRFTt5bn2m5wwZA7aV+7Pq74WLYPzHss0UYwyNvaP6iSyrs6etoCydecGNXcbzQabfaLRefa869OvqZJqAaSYbIVr8x9Q6tAwO0fvwtPN+RuDK1eCTNXdKMlZruT2cb8cEU0t5G+WVZnmXPCD0JyBoRO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305810; c=relaxed/simple; bh=gHNQqhw7VVZ8HDLj3PD4gbaFv3v5iPq7Y3Tkp7jU9lg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QvlhLjUcr5XB2O9yKEScoyxTwvjB1IYSm+bLor9I6bcab2dOa4RjF1pO6ykrqGnLfzFyvaIYZ4w7YVPPIl/DzQ3K7MNhNGVbG2Y9W80rRELiovdZ4v9Xc8fYGrmcjcOpelBqucs7RNpusrsQ4KZ9KbmjHMnkW+LfY9RgrNhI/Lk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q2Ouwrvp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q2Ouwrvp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07E77C4CEF7; Thu, 1 Jan 2026 22:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305810; bh=gHNQqhw7VVZ8HDLj3PD4gbaFv3v5iPq7Y3Tkp7jU9lg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q2Ouwrvp911JzA1XOUT9i1PXT2TImUcJ292gV1k9bzM8Z48Nu5G39zXRCd7XiMHvb aNik9aNs647YqthJkcEskFhllX1LhrZDWfe+1ctM3768mJsf7gQq5EN55ryfdkRAhP K4j/qAOHEidsOnpB982JjlxYPZF8/m+O2D2X17v4WKfESJLHnkJmRCUH1Ui6XE0WUe 0PI44xkxibtnf3j+PlSun3PxXSwrPwckMDuOvI/OzSnPUEFQjwd54MLgl8u38AtP22 VgL6pjrPdo2ZmLhJVr+5PxWUfWuG5ABgmW5ZG+AGxAIJ0drQDPLssux7e4m3Oo6Qyk oMI3wMcafwcfQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 19/33] cpuset: Propagate cpuset isolation update to timers through housekeeping Date: Thu, 1 Jan 2026 23:13:44 +0100 Message-ID: <20260101221359.22298-20-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Until now, cpuset would propagate isolated partition changes to timer migration so that unbound timers don't get migrated to isolated CPUs. Since housekeeping now centralizes, synchronize and propagates isolation cpumask changes, perform the work from that subsystem for consolidation and consistency purposes. Signed-off-by: Frederic Weisbecker --- kernel/cgroup/cpuset.c | 3 --- kernel/sched/isolation.c | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index ea9925652d99..12a47922b7ce 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1487,9 +1487,6 @@ static void update_isolation_cpumasks(void) ret =3D housekeeping_update(isolated_cpus); WARN_ON_ONCE(ret < 0); =20 - ret =3D tmigr_isolated_exclude_cpumask(isolated_cpus); - WARN_ON_ONCE(ret < 0); - isolated_cpus_updating =3D false; } =20 diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index 2f4f184cef2b..61580023cf9d 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -147,9 +147,13 @@ int housekeeping_update(struct cpumask *isol_mask) pci_probe_flush_workqueue(); mem_cgroup_flush_workqueue(); vmstat_flush_workqueue(); + err =3D workqueue_unbound_housekeeping_update(housekeeping_cpumask(HK_TYP= E_DOMAIN)); WARN_ON_ONCE(err < 0); =20 + err =3D tmigr_isolated_exclude_cpumask(isol_mask); + WARN_ON_ONCE(err < 0); + kfree(old); =20 return 0; --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 44E5C303A1A; Thu, 1 Jan 2026 22:16:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305818; cv=none; b=KWDJrMlzpkIPQSL+jLK1RhWJMoUUd4BKtNFdtnJ3Mxqp5UhZiYRx8wMHQj9or/rMfPV9PZu0wznpRX58XskjMzsBLS56SPMgsn3j19xFjTP6woOEfUULAzzWjpoLNEQj9i7fWudL9JM+uxCswmB7YaAN70eZ/7gkNE7wqOZVK4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305818; c=relaxed/simple; bh=xcMcLXp9lSxfZhVrsREHiMXj3hvNw6ylCQ2N03wRKM0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=el9GGVB2IitcmGPaR2qg/EkSI6Hwd9ZSSqNw9cRrEpxPil4CIJQo+O8CbStvu75nzsCiEwiiHVgIqEeEsvaM16Nksu6FexIeFFB17TnFxUi+oYwDK6y4EswW4VNwWHKyawf1jPyumBQbBVxtDgKsCtRh8XpLwT980hqxl3072lo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C2srymam; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C2srymam" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71B19C4CEF7; Thu, 1 Jan 2026 22:16:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305818; bh=xcMcLXp9lSxfZhVrsREHiMXj3hvNw6ylCQ2N03wRKM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C2srymamUA0MXxivD0ZeKbuJECZYnpJecM0twnYUVIw4QXxFyrb6VkzOgcYkmHia7 +DnWEgfnwas3kVZuLf9KnTKlIMAuWVsPt4pwS9udwPhgI+qL1DxK7Sod9D8m263NIa W7qFbUW/tCcxsOubXiycdmSVDZ9lABvy+cWUVjffImRmPd4OCVaeJltguOh1R2iLNZ JtcehsjD6GO3wNqGufbqTqFGlp6vOWIx4t10NRQc+URkLgOMwMUo+VgTIAgOoZRK6F RExsJ3KheHEyeLBvwtNieJ9/RZAvnTRNxtfaiadl5mYG2GYxsztP4x+qItJkx55huk 8+pERh53gsTmQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 20/33] timers/migration: Remove superfluous cpuset isolation test Date: Thu, 1 Jan 2026 23:13:45 +0100 Message-ID: <20260101221359.22298-21-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Cpuset isolated partitions are now included in HK_TYPE_DOMAIN. Testing if a CPU is part of an isolated partition alone is now useless. Remove the superflous test. Signed-off-by: Frederic Weisbecker Reviewed-by: Waiman Long --- kernel/time/timer_migration.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel/time/timer_migration.c b/kernel/time/timer_migration.c index 3879575a4975..6da9cd562b20 100644 --- a/kernel/time/timer_migration.c +++ b/kernel/time/timer_migration.c @@ -466,9 +466,8 @@ static inline bool tmigr_is_isolated(int cpu) { if (!static_branch_unlikely(&tmigr_exclude_isolated)) return false; - return (!housekeeping_cpu(cpu, HK_TYPE_DOMAIN) || - cpuset_cpu_is_isolated(cpu)) && - housekeeping_cpu(cpu, HK_TYPE_KERNEL_NOISE); + return (!housekeeping_cpu(cpu, HK_TYPE_DOMAIN) && + housekeeping_cpu(cpu, HK_TYPE_KERNEL_NOISE)); } =20 /* --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 77A9C305E10; Thu, 1 Jan 2026 22:17:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305829; cv=none; b=XJCO3tMts5CrYGZjU+RH7eaWCaE1eWuQSgcMtRst7krh3Jlx5/DRh6Nln9PdBDIVEVGw5y+3YhUE2cTLHsvttLR8tCLZg7KlQwG0V0ZnbJOIkeh4A1pdExE5o6Jaxj66i8ToFreY+L6XtDhhOa2G4Go3IIiDAPUWCWh4Gux38po= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305829; c=relaxed/simple; bh=MZh/70k9lOhqSg5WVM7HlPDgI+aR1XcYP1gqEcla7CM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fAWSpMy757u/J3U4jR308Uj4tVKL2QjpOU6630occ8hoxEVP1x3L8XDLUrXonrCUvkl+ZVbhzMxry+MZNo13cTXlXlrU6mv9/0aD/lK3aNvthpYjJP8o02DoKl8MR+TL3slxIa6s9vUr8rcQKCFH04J6LIA0a/GQPhv6kmZBWJo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZJLuCa3i; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZJLuCa3i" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9211BC4CEF7; Thu, 1 Jan 2026 22:16:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305826; bh=MZh/70k9lOhqSg5WVM7HlPDgI+aR1XcYP1gqEcla7CM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZJLuCa3iG6Sm7iktwt0+ApaoTltF7T5PkNGYT+0FP+cENPGotvk+AtxV9gYfGxoRh FYbq6OQBiHVnSQG5nNAU0YiaAfhwF5/3MnrpsYLCnxojpjheLBAiqwStH81QUYHdxU QpWa/jJVwJAJswYmswDQWTt2J83Doun9lTzIbCxG8voxdXKjRZqTSyWamEjR/gAGoX APgwNFXFMvnndf4ZCm/g3oTfWdIkJ1NSL9gGsqGDP0ElfG70njnTdR88WFR1+jKsPv 73vkg+OOaDpu4dw9cDanjVgYrwdaQjwrdcCXTitveYJo3cHiOsWXE4POuBaBb5mXgm rWMcFaLv1toEw== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 21/33] cpuset: Remove cpuset_cpu_is_isolated() Date: Thu, 1 Jan 2026 23:13:46 +0100 Message-ID: <20260101221359.22298-22-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The set of cpuset isolated CPUs is now included in HK_TYPE_DOMAIN housekeeping cpumask. There is no usecase left interested in just checking what is isolated by cpuset and not by the isolcpus=3D kernel boot parameter. Signed-off-by: Frederic Weisbecker Reviewed-by: Waiman Long --- include/linux/cpuset.h | 6 ------ include/linux/sched/isolation.h | 4 +--- kernel/cgroup/cpuset.c | 12 ------------ 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h index 1c49ffd2ca9b..a4aa2f1767d0 100644 --- a/include/linux/cpuset.h +++ b/include/linux/cpuset.h @@ -79,7 +79,6 @@ extern void cpuset_unlock(void); extern void cpuset_cpus_allowed_locked(struct task_struct *p, struct cpuma= sk *mask); extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mas= k); extern bool cpuset_cpus_allowed_fallback(struct task_struct *p); -extern bool cpuset_cpu_is_isolated(int cpu); extern nodemask_t cpuset_mems_allowed(struct task_struct *p); #define cpuset_current_mems_allowed (current->mems_allowed) void cpuset_init_current_mems_allowed(void); @@ -215,11 +214,6 @@ static inline bool cpuset_cpus_allowed_fallback(struct= task_struct *p) return false; } =20 -static inline bool cpuset_cpu_is_isolated(int cpu) -{ - return false; -} - static inline nodemask_t cpuset_mems_allowed(struct task_struct *p) { return node_possible_map; diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolatio= n.h index d8d9baf44516..d0fb0f647318 100644 --- a/include/linux/sched/isolation.h +++ b/include/linux/sched/isolation.h @@ -2,7 +2,6 @@ #define _LINUX_SCHED_ISOLATION_H =20 #include -#include #include #include =20 @@ -84,8 +83,7 @@ static inline bool housekeeping_cpu(int cpu, enum hk_type= type) static inline bool cpu_is_isolated(int cpu) { return !housekeeping_test_cpu(cpu, HK_TYPE_DOMAIN) || - !housekeeping_test_cpu(cpu, HK_TYPE_TICK) || - cpuset_cpu_is_isolated(cpu); + !housekeeping_test_cpu(cpu, HK_TYPE_TICK); } =20 #endif /* _LINUX_SCHED_ISOLATION_H */ diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 12a47922b7ce..de693acc9254 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -1490,17 +1489,6 @@ static void update_isolation_cpumasks(void) isolated_cpus_updating =3D false; } =20 -/** - * cpuset_cpu_is_isolated - Check if the given CPU is isolated - * @cpu: the CPU number to be checked - * Return: true if CPU is used in an isolated partition, false otherwise - */ -bool cpuset_cpu_is_isolated(int cpu) -{ - return cpumask_test_cpu(cpu, isolated_cpus); -} -EXPORT_SYMBOL_GPL(cpuset_cpu_is_isolated); - /** * rm_siblings_excl_cpus - Remove exclusive CPUs that are used by sibling = cpusets * @parent: Parent cpuset containing all siblings --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1EF663081BD; Thu, 1 Jan 2026 22:17:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305834; cv=none; b=Z2h66ndIJId1uAuR07C8DBbu2h2yIWSKtlP9l0a6cVwRvm10tFDL/2/pwhxcAV/PfCXImtd65YP29Fby4h2ZTztAuwZKzJuxkPv2O4c3005FfYQBnRFRbdDcz0u5c9yXXT2fKFihOWhEKp1pSs+8a4PP4hzeZIz6e4rQkM5TZqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305834; c=relaxed/simple; bh=STgH3vdgePx/NwxeTPu0LVfQh6HZMobxiXNItthO3G4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y6KDRUvmQsPtJZemDjHvO9dDiG2zRioJZYNr+905t8FTVjf3JuW9VuHlbxF28IuMa355J+ynOibPruW/HHLFasZ7QQxajO+GvpMOjNBfcMmLXaPGlsQpFEQyWL1+4s9l+qskRnjqRjmKEFV1B0c8t7/PxzfgSOgqzcnWgyPqXEk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jc7gn7TR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jc7gn7TR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C2F2C116D0; Thu, 1 Jan 2026 22:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305834; bh=STgH3vdgePx/NwxeTPu0LVfQh6HZMobxiXNItthO3G4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jc7gn7TR1w3hwydX3z0B7EcH9rCjv5djOTIhB0+TMcYJdJELjE0CyYpzKA654hMLq hfAROIBc8+V2iNgqs2DbNnrn+tlCRM8nif8NqFp4zKLJWaTGPWsaF+aSyArU8GuV/a oY9NxNLaiyBHWD/IcotLAwtCGDD7HJyMQy1vxXi6MblCVT9rRMhY357N6WUdgqZM40 2eqKe7IgayKiFXlcUJ3THlim3HDHOfKGkYUJFSIBeVHBRTZRZoP551DOU71dUpVa+E r3tV1aztmgSCFiWXB6B8iYBW+Bg6uXBPW2DXRuZRRfDY22u2frlTY3qc9SQEikfzmH 11SsFwxSg4qag== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 22/33] sched/isolation: Remove HK_TYPE_TICK test from cpu_is_isolated() Date: Thu, 1 Jan 2026 23:13:47 +0100 Message-ID: <20260101221359.22298-23-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It doesn't make sense to use nohz_full without also isolating the related CPUs from the domain topology, either through the use of isolcpus=3D or cpuset isolated partitions. And now HK_TYPE_DOMAIN includes all kinds of domain isolated CPUs. This means that HK_TYPE_KERNEL_NOISE (of which HK_TYPE_TICK is only an alias) should always be a subset of HK_TYPE_DOMAIN. Therefore if a CPU is not HK_TYPE_DOMAIN, it shouldn't be HK_TYPE_KERNEL_NOISE either. Testing the former is then enough. Simplify cpu_is_isolated() accordingly. Signed-off-by: Frederic Weisbecker Acked-by: Waiman Long --- include/linux/sched/isolation.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolatio= n.h index d0fb0f647318..dc3975ff1b2e 100644 --- a/include/linux/sched/isolation.h +++ b/include/linux/sched/isolation.h @@ -82,8 +82,7 @@ static inline bool housekeeping_cpu(int cpu, enum hk_type= type) =20 static inline bool cpu_is_isolated(int cpu) { - return !housekeeping_test_cpu(cpu, HK_TYPE_DOMAIN) || - !housekeeping_test_cpu(cpu, HK_TYPE_TICK); + return !housekeeping_test_cpu(cpu, HK_TYPE_DOMAIN); } =20 #endif /* _LINUX_SCHED_ISOLATION_H */ --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 61AD23093CA; Thu, 1 Jan 2026 22:17:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305843; cv=none; b=NOlt0BjSUq4l77FVsl/uk9kUffc8LFoWGzh4Jd5dc/C5y+D2yZaOZqRYkW1HrQsSPYV3rZbu+GfeS3ECY1RpcH+0hWIVSONgmWqxh+C6H8BX48tvFO3EbuTGiduOfCg/TAUU1PMY0MDAbl9veW5EpyFpSwxHEI0xSEFXROzo2Qg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305843; c=relaxed/simple; bh=BrnLJAuZFcClCQM0uX4BfjC7tqOUNhvTqWQot+DI0W8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TIEdU+7inpGBeAh0V7psegQn1ZwHJ81o2E6816cHEKP1eg3kmOIOqsfBEfOpIjCyGTBC8XsMYpbXeepdmG8YxicyOBIwqq8LiBZqJL3iqEJVoLvaXT/0OKfO9gF3U8DyR2Syjx9HWgNS6rUe4KNYl79wAsx0nNNxb3CeY33eLmM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nc0F+mQs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nc0F+mQs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 694CDC4CEF7; Thu, 1 Jan 2026 22:17:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305841; bh=BrnLJAuZFcClCQM0uX4BfjC7tqOUNhvTqWQot+DI0W8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nc0F+mQsr+cgVMYnh5k6lAsn2xDmg+rX1K4udSpWNHPUAsjLU+AN4EETfnsPESYPZ xXDcffmnrKhDT/yVw0aQVVpwsfwuQu4uB/6170eI8FK8Avs9N2xCcfrezsGC3yyBBj HhQrRG4tH0jPrOPbSHUJpaKzAWGJQ2q4iR0dPMKcNRn1vNMk0LhdlT0RZJOWbofHEi 8g4NUiG/Z/j9QuKQCwRydQseX7NAJNIiqExcLqQ+e0/cu0VxKZIee5SD//+2BZ6s6j qmOvrcIxbRavzymbWowbvrMis0Rew4MXv1vnJOmpW5s9b63Vsk7eW7lX50Eh5pmQIX 97TPVFj1WXptQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 23/33] PCI: Remove superfluous HK_TYPE_WQ check Date: Thu, 1 Jan 2026 23:13:48 +0100 Message-ID: <20260101221359.22298-24-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It doesn't make sense to use nohz_full without also isolating the related CPUs from the domain topology, either through the use of isolcpus=3D or cpuset isolated partitions. And now HK_TYPE_DOMAIN includes all kinds of domain isolated CPUs. This means that HK_TYPE_KERNEL_NOISE (of which HK_TYPE_WQ is only an alias) should always be a subset of HK_TYPE_DOMAIN. Therefore sane configurations verify: HK_TYPE_KERNEL_NOISE | HK_TYPE_DOMAIN =3D=3D HK_TYPE_DOMAIN Simplify the PCI probe target election accordingly. Signed-off-by: Frederic Weisbecker Acked-by: Bjorn Helgaas --- drivers/pci/pci-driver.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index b902d8adf9a5..a9590601835a 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -384,16 +384,9 @@ static int pci_call_probe(struct pci_driver *drv, stru= ct pci_dev *dev, pci_physfn_is_probed(dev)) { error =3D local_pci_probe(&ddi); } else { - cpumask_var_t wq_domain_mask; struct pci_probe_arg arg =3D { .ddi =3D &ddi }; =20 - if (!zalloc_cpumask_var(&wq_domain_mask, GFP_KERNEL)) { - error =3D -ENOMEM; - goto out; - } - INIT_WORK_ONSTACK(&arg.work, local_pci_probe_callback); - /* * The target election and the enqueue of the work must be within * the same RCU read side section so that when the workqueue pool @@ -402,12 +395,9 @@ static int pci_call_probe(struct pci_driver *drv, stru= ct pci_dev *dev, * targets. */ rcu_read_lock(); - cpumask_and(wq_domain_mask, - housekeeping_cpumask(HK_TYPE_WQ), - housekeeping_cpumask(HK_TYPE_DOMAIN)); - cpu =3D cpumask_any_and(cpumask_of_node(node), - wq_domain_mask); + housekeeping_cpumask(HK_TYPE_DOMAIN)); + if (cpu < nr_cpu_ids) { struct workqueue_struct *wq =3D pci_probe_wq; =20 @@ -422,10 +412,9 @@ static int pci_call_probe(struct pci_driver *drv, stru= ct pci_dev *dev, error =3D local_pci_probe(&ddi); } =20 - free_cpumask_var(wq_domain_mask); destroy_work_on_stack(&arg.work); } -out: + dev->is_probed =3D 0; cpu_hotplug_enable(); return error; --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C2ECC30ACEB; Thu, 1 Jan 2026 22:17:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305850; cv=none; b=C+lQFV9R1zYkcbtbik24ya0wsktyO6DNGpqAB1sZriPdUalMK2kBpi6TrLlzZUEgyWIdHvUibM0rIA5hMpBLGDy2K3e3XfA1rsYS0RqT5rcr62R3XZCwHHPHh9zPaX7Cm3qb0RjpYgkOBg4vKNEXkFM9cpb7gueddTjZDiuBDAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305850; c=relaxed/simple; bh=9wXcGCZqYAJGFwoghpjYmoH+2WL5WXQJ0azxL3BmHRY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dYwQD2/p3Ls3/F9FGJeaRK6HVYAb3YLrD5Yh0z/kXdBIwd5ZBzVzLu7wa+SNJsZm0iw+9QS8YGVPD7872/M+Z2xGf1jMmkvPQsVqiH261WgUzo4Vnvox3M9QbGEWWrngijJELC1fvQGa7jrAx4n2xlCJEFiMFzfJ63/ZiDacwN8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g9oq21WU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g9oq21WU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BC3FC116D0; Thu, 1 Jan 2026 22:17:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305850; bh=9wXcGCZqYAJGFwoghpjYmoH+2WL5WXQJ0azxL3BmHRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g9oq21WUCSC9/OwMtP02aP+LKfuyP4kYwo32TkRpa0R3GEVyItpW2xdt5TsQ8px7w KOYa0zIReJE24qH3uyrQI69LumAM1w2VW5Muq6an21EFetBZwX+ghiR8MGoLll8pZa Grf0QhLyYxz+6c5k0RlzzEvY1FgNVf13Dx8LwwDOAUsBeBeestfbDJ/bcBkfyyk46T B1qvUJ1xauqWykSaNT1jWVtE2ZlOOpKgPYpyqjW2SijootHw/wpYpnEeS0pAVzKwMj Qd/25qKpu/WlwmyRYUyxMwRydQAHhEqa7Oj+MF5/FNfpGrT+4s9srD9geS0nLM5iM1 8o6BlmW893OEQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 24/33] kthread: Refine naming of affinity related fields Date: Thu, 1 Jan 2026 23:13:49 +0100 Message-ID: <20260101221359.22298-25-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The kthreads preferred affinity related fields use "hotplug" as the base of their naming because the affinity management was initially deemed to deal with CPU hotplug. The scope of this role is going to broaden now and also deal with cpuset isolated partition updates. Switch the naming accordingly. Signed-off-by: Frederic Weisbecker Acked-by: Waiman Long --- kernel/kthread.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/kernel/kthread.c b/kernel/kthread.c index 99a3808d086f..f1e4f1f35cae 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -35,8 +35,8 @@ static DEFINE_SPINLOCK(kthread_create_lock); static LIST_HEAD(kthread_create_list); struct task_struct *kthreadd_task; =20 -static LIST_HEAD(kthreads_hotplug); -static DEFINE_MUTEX(kthreads_hotplug_lock); +static LIST_HEAD(kthread_affinity_list); +static DEFINE_MUTEX(kthread_affinity_lock); =20 struct kthread_create_info { @@ -69,7 +69,7 @@ struct kthread { /* To store the full name if task comm is truncated. */ char *full_name; struct task_struct *task; - struct list_head hotplug_node; + struct list_head affinity_node; struct cpumask *preferred_affinity; }; =20 @@ -128,7 +128,7 @@ bool set_kthread_struct(struct task_struct *p) =20 init_completion(&kthread->exited); init_completion(&kthread->parked); - INIT_LIST_HEAD(&kthread->hotplug_node); + INIT_LIST_HEAD(&kthread->affinity_node); p->vfork_done =3D &kthread->exited; =20 kthread->task =3D p; @@ -323,10 +323,10 @@ void __noreturn kthread_exit(long result) { struct kthread *kthread =3D to_kthread(current); kthread->result =3D result; - if (!list_empty(&kthread->hotplug_node)) { - mutex_lock(&kthreads_hotplug_lock); - list_del(&kthread->hotplug_node); - mutex_unlock(&kthreads_hotplug_lock); + if (!list_empty(&kthread->affinity_node)) { + mutex_lock(&kthread_affinity_lock); + list_del(&kthread->affinity_node); + mutex_unlock(&kthread_affinity_lock); =20 if (kthread->preferred_affinity) { kfree(kthread->preferred_affinity); @@ -390,9 +390,9 @@ static void kthread_affine_node(void) return; } =20 - mutex_lock(&kthreads_hotplug_lock); - WARN_ON_ONCE(!list_empty(&kthread->hotplug_node)); - list_add_tail(&kthread->hotplug_node, &kthreads_hotplug); + mutex_lock(&kthread_affinity_lock); + WARN_ON_ONCE(!list_empty(&kthread->affinity_node)); + list_add_tail(&kthread->affinity_node, &kthread_affinity_list); /* * The node cpumask is racy when read from kthread() but: * - a racing CPU going down will either fail on the subsequent @@ -402,7 +402,7 @@ static void kthread_affine_node(void) */ kthread_fetch_affinity(kthread, affinity); set_cpus_allowed_ptr(current, affinity); - mutex_unlock(&kthreads_hotplug_lock); + mutex_unlock(&kthread_affinity_lock); =20 free_cpumask_var(affinity); } @@ -873,16 +873,16 @@ int kthread_affine_preferred(struct task_struct *p, c= onst struct cpumask *mask) goto out; } =20 - mutex_lock(&kthreads_hotplug_lock); + mutex_lock(&kthread_affinity_lock); cpumask_copy(kthread->preferred_affinity, mask); - WARN_ON_ONCE(!list_empty(&kthread->hotplug_node)); - list_add_tail(&kthread->hotplug_node, &kthreads_hotplug); + WARN_ON_ONCE(!list_empty(&kthread->affinity_node)); + list_add_tail(&kthread->affinity_node, &kthread_affinity_list); kthread_fetch_affinity(kthread, affinity); =20 scoped_guard (raw_spinlock_irqsave, &p->pi_lock) set_cpus_allowed_force(p, affinity); =20 - mutex_unlock(&kthreads_hotplug_lock); + mutex_unlock(&kthread_affinity_lock); out: free_cpumask_var(affinity); =20 @@ -903,9 +903,9 @@ static int kthreads_online_cpu(unsigned int cpu) struct kthread *k; int ret; =20 - guard(mutex)(&kthreads_hotplug_lock); + guard(mutex)(&kthread_affinity_lock); =20 - if (list_empty(&kthreads_hotplug)) + if (list_empty(&kthread_affinity_list)) return 0; =20 if (!zalloc_cpumask_var(&affinity, GFP_KERNEL)) @@ -913,7 +913,7 @@ static int kthreads_online_cpu(unsigned int cpu) =20 ret =3D 0; =20 - list_for_each_entry(k, &kthreads_hotplug, hotplug_node) { + list_for_each_entry(k, &kthread_affinity_list, affinity_node) { if (WARN_ON_ONCE((k->task->flags & PF_NO_SETAFFINITY) || kthread_is_per_cpu(k->task))) { ret =3D -EINVAL; --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B240C30BB96; Thu, 1 Jan 2026 22:17:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305858; cv=none; b=pcZOxw5Uy4NZNRdlvBYrFw8FFTy01GPzg83udXXUoT1I2UL/1hXqvsSZa+X5JNEHudENtYDiyblyz8kSKm0hjMl5bMEm6yR0KSDgsYnljalxSw6DJrV9nH4aToePibN2DFVcp0pBRjj41kM7PZ+/U2dF6IdP0opUlAkcFXQib1s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305858; c=relaxed/simple; bh=FQiUYX134QuRdMK2UHqgCPVDFLi7Mj4zGAJtAEtu0Bs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ac5AQoFvV4SIifdPhWiFZSuknzlk1KKv8BuZB88nvuMRo2RbKP5hyBzW5qlsQfa6jdxIdNnRKlcZ4tI5jrndoOfCn9zWIU+U9XIdV110e/oApzSchjpesLh9gjhrr05H5iHswW9vRfoAjYkijFhOYxAhznEoojuTtCSjhccii6E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XUUyVasV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XUUyVasV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE941C4CEF7; Thu, 1 Jan 2026 22:17:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305858; bh=FQiUYX134QuRdMK2UHqgCPVDFLi7Mj4zGAJtAEtu0Bs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XUUyVasV1u3U2OAhlAsfAFSvZ4/84T9b+/Yagnb//7l06XW+pfb5SupHsl14EiZpO A7lsNvE8Gz+f+oav882CaJu+Xr395Aa7paTMq2wgWOtR+SCJ7KEkBgm/Nqga2j78Uv n0MCp/pybncPc+ax+ldjdWVCiUZtymea0X7ESH0dyW5NSBWCHbzy4fDnSkNN0RchSd 9li0iyITeAlfDOmRXA/n5dUyWiFv4oc1wW0hluBRrDSwHC9VV3yDZGdZ3gy3FS4xaB r1/38N02msJBlnvE+rPs8/2v5u9pgbKK9m+UOQpt8txpDDJyrkxcvJloMMe3jpoqJf D1of5SnkyyUJA== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 25/33] kthread: Include unbound kthreads in the managed affinity list Date: Thu, 1 Jan 2026 23:13:50 +0100 Message-ID: <20260101221359.22298-26-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The managed affinity list currently contains only unbound kthreads that have affinity preferences. Unbound kthreads globally affine by default are outside of the list because their affinity is automatically managed by the scheduler (through the fallback housekeeping mask) and by cpuset. However in order to preserve the preferred affinity of kthreads, cpuset will delegate the isolated partition update propagation to the housekeeping and kthread code. Prepare for that with including all unbound kthreads in the managed affinity list. Signed-off-by: Frederic Weisbecker Reviewed-by: Waiman Long --- kernel/kthread.c | 70 ++++++++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/kernel/kthread.c b/kernel/kthread.c index f1e4f1f35cae..51c0908d3d02 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -365,9 +365,10 @@ static void kthread_fetch_affinity(struct kthread *kth= read, struct cpumask *cpum if (kthread->preferred_affinity) { pref =3D kthread->preferred_affinity; } else { - if (WARN_ON_ONCE(kthread->node =3D=3D NUMA_NO_NODE)) - return; - pref =3D cpumask_of_node(kthread->node); + if (kthread->node =3D=3D NUMA_NO_NODE) + pref =3D housekeeping_cpumask(HK_TYPE_KTHREAD); + else + pref =3D cpumask_of_node(kthread->node); } =20 cpumask_and(cpumask, pref, housekeeping_cpumask(HK_TYPE_KTHREAD)); @@ -380,32 +381,29 @@ static void kthread_affine_node(void) struct kthread *kthread =3D to_kthread(current); cpumask_var_t affinity; =20 - WARN_ON_ONCE(kthread_is_per_cpu(current)); + if (WARN_ON_ONCE(kthread_is_per_cpu(current))) + return; =20 - if (kthread->node =3D=3D NUMA_NO_NODE) { - housekeeping_affine(current, HK_TYPE_KTHREAD); - } else { - if (!zalloc_cpumask_var(&affinity, GFP_KERNEL)) { - WARN_ON_ONCE(1); - return; - } - - mutex_lock(&kthread_affinity_lock); - WARN_ON_ONCE(!list_empty(&kthread->affinity_node)); - list_add_tail(&kthread->affinity_node, &kthread_affinity_list); - /* - * The node cpumask is racy when read from kthread() but: - * - a racing CPU going down will either fail on the subsequent - * call to set_cpus_allowed_ptr() or be migrated to housekeepers - * afterwards by the scheduler. - * - a racing CPU going up will be handled by kthreads_online_cpu() - */ - kthread_fetch_affinity(kthread, affinity); - set_cpus_allowed_ptr(current, affinity); - mutex_unlock(&kthread_affinity_lock); - - free_cpumask_var(affinity); + if (!zalloc_cpumask_var(&affinity, GFP_KERNEL)) { + WARN_ON_ONCE(1); + return; } + + mutex_lock(&kthread_affinity_lock); + WARN_ON_ONCE(!list_empty(&kthread->affinity_node)); + list_add_tail(&kthread->affinity_node, &kthread_affinity_list); + /* + * The node cpumask is racy when read from kthread() but: + * - a racing CPU going down will either fail on the subsequent + * call to set_cpus_allowed_ptr() or be migrated to housekeepers + * afterwards by the scheduler. + * - a racing CPU going up will be handled by kthreads_online_cpu() + */ + kthread_fetch_affinity(kthread, affinity); + set_cpus_allowed_ptr(current, affinity); + mutex_unlock(&kthread_affinity_lock); + + free_cpumask_var(affinity); } =20 static int kthread(void *_create) @@ -919,8 +917,22 @@ static int kthreads_online_cpu(unsigned int cpu) ret =3D -EINVAL; continue; } - kthread_fetch_affinity(k, affinity); - set_cpus_allowed_ptr(k->task, affinity); + + /* + * Unbound kthreads without preferred affinity are already affine + * to housekeeping, whether those CPUs are online or not. So no need + * to handle newly online CPUs for them. + * + * But kthreads with a preferred affinity or node are different: + * if none of their preferred CPUs are online and part of + * housekeeping at the same time, they must be affine to housekeeping. + * But as soon as one of their preferred CPU becomes online, they must + * be affine to them. + */ + if (k->preferred_affinity || k->node !=3D NUMA_NO_NODE) { + kthread_fetch_affinity(k, affinity); + set_cpus_allowed_ptr(k->task, affinity); + } } =20 free_cpumask_var(affinity); --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2023330C601; Thu, 1 Jan 2026 22:17:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305866; cv=none; b=JEtDjky5NwLk5DWwDpsRPPUD9SvjG4R4OmwdFZ3Fs2HLmYz9y9GPyUnK53MAME9gcz8SMIGHyBhSENCMwAS3XEOGFG+7oGcVcwZJVii/WdDtE17N5XYWhPW2POhj2oOKRkIkLvwGM5zcbEeVgTNyhUP1zm5xUgInixDmJrs4fYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305866; c=relaxed/simple; bh=FTfdEWcmOb6DfQTJTbI0bpXWltHwgECxQBbZ31X7mYQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=APmKywuOPDw4ooK6+xzYGO8v8U+8K2XdaCL1SEpYDr+9C4Y9TYebILp0USsTs5svXwwjolI5C4djLxaNJ/QGNqGS+XAFdVvaU0ThYq+Rb491PsaYlxa6JMOJ4uj8PXprqoYlSr6Q5HQwvyOeTtW1FjMx86WZVsK6mOu0ycrYCJU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Tkk9fQ0Y; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Tkk9fQ0Y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA8A2C116D0; Thu, 1 Jan 2026 22:17:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305866; bh=FTfdEWcmOb6DfQTJTbI0bpXWltHwgECxQBbZ31X7mYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tkk9fQ0YxqsER1NIYCYAosngscJ4AdypdNtqtaJFGu9GcutE6+K3Jp7bcDA3NQOcH Xytzse9mx5JPmfO5GyVTdWYK5YFWOq2SOa+0UwmyekzSxNnR7H7CdbRcJ4wn0VUcE2 BloJ1HDGpQYHr1o5ne77EZVEJFAMqZcvAJcxkkwqW+6RYgONx6ovugYS5UJbc3MsGQ 46al2/dLj9svm4BceMLmrQv7cEOqWMDC/MJ0Nt9QJs9G8/f/CXDGVdlkiTDzPCRHIu d7zSfba6m/XDB0RQczXhePFboKDtAaVIaMnukN1N41tEjfibT6WhpuV5u4rwIUmoUh uDHS7oRP2rgHA== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 26/33] kthread: Include kthreadd to the managed affinity list Date: Thu, 1 Jan 2026 23:13:51 +0100 Message-ID: <20260101221359.22298-27-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The unbound kthreads affinity management performed by cpuset is going to be imported to the kthread core code for consolidation purposes. Treat kthreadd just like any other kthread. Signed-off-by: Frederic Weisbecker Reviewed-by: Waiman Long --- kernel/kthread.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/kthread.c b/kernel/kthread.c index 51c0908d3d02..85ccf5bb17c9 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -818,12 +818,13 @@ int kthreadd(void *unused) /* Setup a clean context for our children to inherit. */ set_task_comm(tsk, comm); ignore_signals(tsk); - set_cpus_allowed_ptr(tsk, housekeeping_cpumask(HK_TYPE_KTHREAD)); set_mems_allowed(node_states[N_MEMORY]); =20 current->flags |=3D PF_NOFREEZE; cgroup_init_kthreadd(); =20 + kthread_affine_node(); + for (;;) { set_current_state(TASK_INTERRUPTIBLE); if (list_empty(&kthread_create_list)) --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C508A30DD14; Thu, 1 Jan 2026 22:17:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305874; cv=none; b=soj7oguk7xddQzcBd1ZhJsWV/RDQj4ziOzDSfOWAQsSwzHfXLWcNAsCMr8Xc6afridogRvTaYGp+kGk+AbhXoOiKe3o3nr6/fHWsb6d1/8KiTsPHAu6k/dp97HWbwivBV9AFeqT1uczrzfE5Bf9iYV1T+INiQl8oNTuaChFB7hc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305874; c=relaxed/simple; bh=OKxr66AuTYpmtINGeWatnOeeLWTfC6xUU/wfI1fZOeA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jrILqCXd9AEXg9kOO92KC9l9unsS0IemVVrnuSHNkP8bZStUIUBIFABCrWefERaS55hrAqS5G1CZKQc+wQ9V0ZtI8Ild7lZ1SyA2GhcHAqLk6yN3jas36h95gP84VmdDwE4VKcWxtAaRJuzkZ0I8SaqoG0MA3q9qeMbbosmnWXo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k3tzAh1q; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="k3tzAh1q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 696F1C4CEF7; Thu, 1 Jan 2026 22:17:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305874; bh=OKxr66AuTYpmtINGeWatnOeeLWTfC6xUU/wfI1fZOeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k3tzAh1qqBzEdJr7W13PBSjlKJJ2OZj+v1bk3WgK5Y/gMgiJhnOqkbzrE4d5fNn6r 3ihlWEqcfPQ/esrNTdCUpshwQlHu06VG7Fg8ddHxFPeJyiGDYP6VsaEe7AtkYGFNID 7bW3zS0Mk2L74PT+vdla6Mz6/0qfIdMkfBICDBxermqoh+GzMfbu/cvTlTD1Um7KNG qADGnv9N68YVfnTeHvZRAP+S2Gd2w3P6I51mCUa2XTbkMdiLCDF9BPwbcddsZ2ehdj ZdhkVDdGYr4dZ1sqs2Pe0ofLfYQE9v4eJ/Tk1J3wPU7EWgXsmp45dISB+MYVn2h/GZ vonDrbTOK4C9w== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 27/33] kthread: Rely on HK_TYPE_DOMAIN for preferred affinity management Date: Thu, 1 Jan 2026 23:13:52 +0100 Message-ID: <20260101221359.22298-28-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Unbound kthreads want to run neither on nohz_full CPUs nor on domain isolated CPUs. And since nohz_full implies domain isolation, checking the latter is enough to verify both. Therefore exclude kthreads from domain isolation. Signed-off-by: Frederic Weisbecker Reviewed-by: Waiman Long --- kernel/kthread.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/kthread.c b/kernel/kthread.c index 85ccf5bb17c9..968fa5868d21 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -362,18 +362,20 @@ static void kthread_fetch_affinity(struct kthread *kt= hread, struct cpumask *cpum { const struct cpumask *pref; =20 + guard(rcu)(); + if (kthread->preferred_affinity) { pref =3D kthread->preferred_affinity; } else { if (kthread->node =3D=3D NUMA_NO_NODE) - pref =3D housekeeping_cpumask(HK_TYPE_KTHREAD); + pref =3D housekeeping_cpumask(HK_TYPE_DOMAIN); else pref =3D cpumask_of_node(kthread->node); } =20 - cpumask_and(cpumask, pref, housekeeping_cpumask(HK_TYPE_KTHREAD)); + cpumask_and(cpumask, pref, housekeeping_cpumask(HK_TYPE_DOMAIN)); if (cpumask_empty(cpumask)) - cpumask_copy(cpumask, housekeeping_cpumask(HK_TYPE_KTHREAD)); + cpumask_copy(cpumask, housekeeping_cpumask(HK_TYPE_DOMAIN)); } =20 static void kthread_affine_node(void) --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 393B330E0DC; Thu, 1 Jan 2026 22:18:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305883; cv=none; b=uLsAiYxIPclkGObcfHobDukLl5afEt99loTNLH5rMn2FDCQxGSXYaHw+9D6YChHpUHM2V29uXhgpOTKBry/BM3HsTZoI6BBte4QqkxiUZ8lDQEWZn8RxjOjb/xqfklfeatybTomTDz+bEojxEsG1DA5xkYWq1rBdxtyRX7e9HL8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305883; c=relaxed/simple; bh=txAoH54KyHKbuey5FYwPXMe7a123Tyjq6wOFllqOg9U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aC+GYGohFNUB70ydfkvgsUeFvRPX4g/uQvDn0pWdqeD/kcTKSc9A1R+SJdkhCEkYjYOtL3eFONJhDJBnAtNJFfjJBXpVh7HfOhX3ARms1pAzIGQodEg/kmAvW0FtE1Fp66GwmO/59OrHwHha3gW1N+xicBHvbKpCtC8akvYMffA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nGRmEtfZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nGRmEtfZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCB81C116D0; Thu, 1 Jan 2026 22:17:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305883; bh=txAoH54KyHKbuey5FYwPXMe7a123Tyjq6wOFllqOg9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nGRmEtfZf/dlvXTRXeRug3jmfNXg5p3dx5FKXhG8VpPBiNBxtnzA4f4zq4cdvK7V0 Ajv2d1SdcQZ4WzUAu4ABDGC0IZLHAPLfc+WCdf/60Sme5hDBRAFCB6xCqi7jDHK8TF 4a2XPX9edzLhaEeEVfw90VYwjSLfjgww8JY6aPlYilZjglIbWHfdhP9hfdMKGiuMiN CVr1nXXYlRlsxaU9eYzmlqJotqeOlCna/rZcx+YxZrtTiAiWR6tsZLK7yNbTl2KOPM rXK4eWyFydu9GzHrar4isymMZ59ZNyAzDsj4JlDrWOfFfn/6xBWLEiO09OJ4w8+hTe V7cgvK/o6R8RA== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 28/33] sched: Switch the fallback task allowed cpumask to HK_TYPE_DOMAIN Date: Thu, 1 Jan 2026 23:13:53 +0100 Message-ID: <20260101221359.22298-29-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Tasks that have all their allowed CPUs offline don't want their affinity to fallback on either nohz_full CPUs or on domain isolated CPUs. And since nohz_full implies domain isolation, checking the latter is enough to verify both. Therefore exclude domain isolation from fallback task affinity. Signed-off-by: Frederic Weisbecker Acked-by: Waiman Long --- include/linux/mmu_context.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/mmu_context.h b/include/linux/mmu_context.h index ac01dc4eb2ce..ed3dd0f3fe19 100644 --- a/include/linux/mmu_context.h +++ b/include/linux/mmu_context.h @@ -24,7 +24,7 @@ static inline void leave_mm(void) { } #ifndef task_cpu_possible_mask # define task_cpu_possible_mask(p) cpu_possible_mask # define task_cpu_possible(cpu, p) true -# define task_cpu_fallback_mask(p) housekeeping_cpumask(HK_TYPE_TICK) +# define task_cpu_fallback_mask(p) housekeeping_cpumask(HK_TYPE_DOMAIN) #else # define task_cpu_possible(cpu, p) cpumask_test_cpu((cpu), task_cpu_possib= le_mask(p)) #endif --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E6C5430EF95; Thu, 1 Jan 2026 22:18:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305895; cv=none; b=Iv+eFnaBAEDK8XhmJaGhurgdFNpOhDfQRjnJe2Fgyu+oXqAXLzmVahmNC0okM7RFVIKy9rZH3VkfPyF3cIaV6ReXyUSQF2PGQN+yWyqdOYFt5rcbKjxX2rFUz+CE0tqmhFS3yNokB+otj8BOUcQJfqTYnE628fx8rfIAvoSd2Mk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305895; c=relaxed/simple; bh=suQBEGrwM0H79w5KYcULPea1fuwcki7sYob2HhlcJeE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j301qeqynLTHkFN1AE//t/CdIap7SVWwQa/eJ3wJs8hu9GvFPSzoSwTjJq4v28/369m8k/ZkkyOi/WeC5xdZqv5z/lIkciTqM3WfUrPX13V5UWQDfLGfGy9clSCWFHd1gzucN7dcqLIC+6wxFyFyGycpo8cFZ/C9K3LWo+ZHRR4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jFdsVBrD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jFdsVBrD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84B4FC4CEF7; Thu, 1 Jan 2026 22:18:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305891; bh=suQBEGrwM0H79w5KYcULPea1fuwcki7sYob2HhlcJeE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jFdsVBrD+gqPDbjB7hhYNrkRMOAcs9Ri6UytAJaZxIocRskZQJJHfHR1MuEbRLhXJ NKXRKYXcJ+V5O4Xcjcupc84aKMc88nXfS+5H+7WcyeX+GUyaA5eteoY9YGwkt2nY9W LBN6qDHveH8xYeclMA+Wt54gqUkaNeksJspA1oL0pb+E+BKUOfTUGTVF8lxrtd/ZRD oQlOw903CI+WdYfANptIRGygIyCMxBqOKsbWGhhizVRblqUwY+8n16pvoU/5tJIica OCKFL4VVgCvqqIbbJDcEkjRydRPCkbPMC9ZFsTbUvGdip07NmpIiHHvYF7Q+BkSqJb nVViGU/r/4gPg== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 29/33] sched/arm64: Move fallback task cpumask to HK_TYPE_DOMAIN Date: Thu, 1 Jan 2026 23:13:54 +0100 Message-ID: <20260101221359.22298-30-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When none of the allowed CPUs of a task are online, it gets migrated to the fallback cpumask which is all the non nohz_full CPUs. However just like nohz_full CPUs, domain isolated CPUs don't want to be disturbed by tasks that have lost their CPU affinities. And since nohz_full rely on domain isolation to work correctly, the housekeeping mask of domain isolated CPUs should always be a superset of the housekeeping mask of nohz_full CPUs (there can be CPUs that are domain isolated but not nohz_full, OTOH there shouldn't be nohz_full CPUs that are not domain isolated): HK_TYPE_DOMAIN | HK_TYPE_KERNEL_NOISE =3D=3D HK_TYPE_DOMAIN Therefore use HK_TYPE_DOMAIN as the appropriate fallback target for tasks and since this cpumask can be modified at runtime, make sure that 32 bits support CPUs on ARM64 mismatched systems are not isolated by cpusets. Signed-off-by: Frederic Weisbecker Reviewed-by: Waiman Long --- arch/arm64/kernel/cpufeature.c | 18 +++++++++++++++--- include/linux/cpu.h | 4 ++++ kernel/cgroup/cpuset.c | 17 ++++++++++++++--- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index c840a93b9ef9..70b0e45e299a 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1656,6 +1656,18 @@ has_cpuid_feature(const struct arm64_cpu_capabilitie= s *entry, int scope) return feature_matches(val, entry); } =20 +/* + * 32 bits support CPUs can't be isolated because tasks may be + * arbitrarily affine to them, defeating the purpose of isolation. + */ +bool arch_isolated_cpus_can_update(struct cpumask *new_cpus) +{ + if (static_branch_unlikely(&arm64_mismatched_32bit_el0)) + return !cpumask_intersects(cpu_32bit_el0_mask, new_cpus); + else + return true; +} + const struct cpumask *system_32bit_el0_cpumask(void) { if (!system_supports_32bit_el0()) @@ -1669,7 +1681,7 @@ const struct cpumask *system_32bit_el0_cpumask(void) =20 const struct cpumask *task_cpu_fallback_mask(struct task_struct *p) { - return __task_cpu_possible_mask(p, housekeeping_cpumask(HK_TYPE_TICK)); + return __task_cpu_possible_mask(p, housekeeping_cpumask(HK_TYPE_DOMAIN)); } =20 static int __init parse_32bit_el0_param(char *str) @@ -3987,8 +3999,8 @@ static int enable_mismatched_32bit_el0(unsigned int c= pu) bool cpu_32bit =3D false; =20 if (id_aa64pfr0_32bit_el0(info->reg_id_aa64pfr0)) { - if (!housekeeping_cpu(cpu, HK_TYPE_TICK)) - pr_info("Treating adaptive-ticks CPU %u as 64-bit only\n", cpu); + if (!housekeeping_cpu(cpu, HK_TYPE_DOMAIN)) + pr_info("Treating domain isolated CPU %u as 64-bit only\n", cpu); else cpu_32bit =3D true; } diff --git a/include/linux/cpu.h b/include/linux/cpu.h index 487b3bf2e1ea..0b48af25ab5c 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -229,4 +229,8 @@ static inline bool cpu_attack_vector_mitigated(enum cpu= _attack_vectors v) #define smt_mitigations SMT_MITIGATIONS_OFF #endif =20 +struct cpumask; + +bool arch_isolated_cpus_can_update(struct cpumask *new_cpus); + #endif /* _LINUX_CPU_H_ */ diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index de693acc9254..4c9aa3f80553 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1408,14 +1408,22 @@ static void partition_xcpus_del(int old_prs, struct= cpuset *parent, cpumask_or(parent->effective_cpus, parent->effective_cpus, xcpus); } =20 +bool __weak arch_isolated_cpus_can_update(struct cpumask *new_cpus) +{ + return true; +} + /* - * isolated_cpus_can_update - check for isolated & nohz_full conflicts + * isolated_cpus_can_update - check for conflicts against housekeeping and + * CPUs capabilities. * @add_cpus: cpu mask for cpus that are going to be isolated * @del_cpus: cpu mask for cpus that are no longer isolated, can be NULL * Return: false if there is conflict, true otherwise * - * If nohz_full is enabled and we have isolated CPUs, their combination mu= st - * still leave housekeeping CPUs. + * Check for conflicts: + * - If nohz_full is enabled and there are isolated CPUs, their combinatio= n must + * still leave housekeeping CPUs. + * - Architecture has CPU capabilities incompatible with being isolated * * TBD: Should consider merging this function into * prstate_housekeeping_conflict(). @@ -1426,6 +1434,9 @@ static bool isolated_cpus_can_update(struct cpumask *= add_cpus, cpumask_var_t full_hk_cpus; int res =3D true; =20 + if (!arch_isolated_cpus_can_update(add_cpus)) + return false; + if (!housekeeping_enabled(HK_TYPE_KERNEL_NOISE)) return true; =20 --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 11DDF30F93F; Thu, 1 Jan 2026 22:18:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305900; cv=none; b=rtdy6Yvb3c68PL8mCe2M05sOp/nJ4/RxqpFFb/QeXYXu/1/J3mEkZg4wuqF/2R6rvBArQjx6bBSzsNIguDdiO4R5u2Qvl3LCLwdTM2cCpkRvVl0vVe5ZmdVEK5IDzS7lIotT+LQAL6og5iGrrqtmr3BARwvfuDvFecyb8In3a6k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305900; c=relaxed/simple; bh=QnBszBWMBdPelj3/EhAAmslkOo78Vo1wD+/ritolIOQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LCbum8jhVGub4d84rCOayRu6xOnwdNqQlXj4j4bCsTRDf/H9WZJFs15TKI9X/+Hh78I/aj3oQZP5SK/pakiUlyIiJWSfA0EItDOZEi7DSfFu2t3Nn94Qd9VbYkcNSOzVQ7MIv+4i1MaMP1TWv+FhRECMVo6khK8jFkKtPPb5zYw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lLr6Du+0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lLr6Du+0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02B6BC19421; Thu, 1 Jan 2026 22:18:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305899; bh=QnBszBWMBdPelj3/EhAAmslkOo78Vo1wD+/ritolIOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lLr6Du+01wQ7rIsDvS1hnMGCTOQP6300d3yx50NlnX8+avtAXSlGCdkGmfu3LFiDl azt4pnazHojiE8FIkTc8eQiAtnQlzmCAZpzik2cI9zC74FVSrQKjSbRuK9sp0ycKbW m08MDz87hJAnUGp2fmbKZIT7kYaCL6sSWxwFGJrmTbJEblx45AD5uoLRtBz9DaOO6L GcEwDlnD0V8R9VRbFP3SwmZalMesMJ5z43tF5XfG0mzHUJtS6j90E7KYcvGkmSWTIP VGOmhH6ofE1DWvbSzc8WLhvLuUnsizMZWDW343vyFdt+/nvWsWuH6zDYMNCvyzksnC tO+3TXnOPkOqA== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 30/33] kthread: Honour kthreads preferred affinity after cpuset changes Date: Thu, 1 Jan 2026 23:13:55 +0100 Message-ID: <20260101221359.22298-31-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When cpuset isolated partitions get updated, unbound kthreads get indifferently affine to all non isolated CPUs, regardless of their individual affinity preferences. For example kswapd is a per-node kthread that prefers to be affine to the node it refers to. Whenever an isolated partition is created, updated or deleted, kswapd's node affinity is going to be broken if any CPU in the related node is not isolated because kswapd will be affine globally. Fix this with letting the consolidated kthread managed affinity code do the affinity update on behalf of cpuset. Signed-off-by: Frederic Weisbecker Reviewed-by: Waiman Long --- include/linux/kthread.h | 1 + kernel/cgroup/cpuset.c | 5 ++--- kernel/kthread.c | 41 ++++++++++++++++++++++++++++++---------- kernel/sched/isolation.c | 3 +++ 4 files changed, 37 insertions(+), 13 deletions(-) diff --git a/include/linux/kthread.h b/include/linux/kthread.h index 8d27403888ce..c92c1149ee6e 100644 --- a/include/linux/kthread.h +++ b/include/linux/kthread.h @@ -100,6 +100,7 @@ void kthread_unpark(struct task_struct *k); void kthread_parkme(void); void kthread_exit(long result) __noreturn; void kthread_complete_and_exit(struct completion *, long) __noreturn; +int kthreads_update_housekeeping(void); =20 int kthreadd(void *unused); extern struct task_struct *kthreadd_task; diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 4c9aa3f80553..3280f457232f 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1208,11 +1208,10 @@ void cpuset_update_tasks_cpumask(struct cpuset *cs,= struct cpumask *new_cpus) =20 if (top_cs) { /* + * PF_KTHREAD tasks are handled by housekeeping. * PF_NO_SETAFFINITY tasks are ignored. - * All per cpu kthreads should have PF_NO_SETAFFINITY - * flag set, see kthread_set_per_cpu(). */ - if (task->flags & PF_NO_SETAFFINITY) + if (task->flags & (PF_KTHREAD | PF_NO_SETAFFINITY)) continue; cpumask_andnot(new_cpus, possible_mask, subpartitions_cpus); } else { diff --git a/kernel/kthread.c b/kernel/kthread.c index 968fa5868d21..03008154249c 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -891,14 +891,7 @@ int kthread_affine_preferred(struct task_struct *p, co= nst struct cpumask *mask) } EXPORT_SYMBOL_GPL(kthread_affine_preferred); =20 -/* - * Re-affine kthreads according to their preferences - * and the newly online CPU. The CPU down part is handled - * by select_fallback_rq() which default re-affines to - * housekeepers from other nodes in case the preferred - * affinity doesn't apply anymore. - */ -static int kthreads_online_cpu(unsigned int cpu) +static int kthreads_update_affinity(bool force) { cpumask_var_t affinity; struct kthread *k; @@ -924,7 +917,8 @@ static int kthreads_online_cpu(unsigned int cpu) /* * Unbound kthreads without preferred affinity are already affine * to housekeeping, whether those CPUs are online or not. So no need - * to handle newly online CPUs for them. + * to handle newly online CPUs for them. However housekeeping changes + * have to be applied. * * But kthreads with a preferred affinity or node are different: * if none of their preferred CPUs are online and part of @@ -932,7 +926,7 @@ static int kthreads_online_cpu(unsigned int cpu) * But as soon as one of their preferred CPU becomes online, they must * be affine to them. */ - if (k->preferred_affinity || k->node !=3D NUMA_NO_NODE) { + if (force || k->preferred_affinity || k->node !=3D NUMA_NO_NODE) { kthread_fetch_affinity(k, affinity); set_cpus_allowed_ptr(k->task, affinity); } @@ -943,6 +937,33 @@ static int kthreads_online_cpu(unsigned int cpu) return ret; } =20 +/** + * kthreads_update_housekeeping - Update kthreads affinity on cpuset change + * + * When cpuset changes a partition type to/from "isolated" or updates rela= ted + * cpumasks, propagate the housekeeping cpumask change to preferred kthrea= ds + * affinity. + * + * Returns 0 if successful, -ENOMEM if temporary mask couldn't + * be allocated or -EINVAL in case of internal error. + */ +int kthreads_update_housekeeping(void) +{ + return kthreads_update_affinity(true); +} + +/* + * Re-affine kthreads according to their preferences + * and the newly online CPU. The CPU down part is handled + * by select_fallback_rq() which default re-affines to + * housekeepers from other nodes in case the preferred + * affinity doesn't apply anymore. + */ +static int kthreads_online_cpu(unsigned int cpu) +{ + return kthreads_update_affinity(false); +} + static int kthreads_init(void) { return cpuhp_setup_state(CPUHP_AP_KTHREADS_ONLINE, "kthreads:online", diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index 61580023cf9d..d8642eee8d77 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -154,6 +154,9 @@ int housekeeping_update(struct cpumask *isol_mask) err =3D tmigr_isolated_exclude_cpumask(isol_mask); WARN_ON_ONCE(err < 0); =20 + err =3D kthreads_update_housekeeping(); + WARN_ON_ONCE(err < 0); + kfree(old); =20 return 0; --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 82D573101A6; Thu, 1 Jan 2026 22:18:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305908; cv=none; b=DnZWVQs+kaCkOxNjbSprWd38m0RoauqUam4hYEacRIRf4cSK741H+1nnaY1jd2twEMH8Lw3qdVdOR3mJzExxxKiT2Bzge8U588tdfMWRz0Bjj/NullL95ZYTc2C6Jlfa4XbbZDIpUGJKg5tZ6pF8BzWpfxVvi231DNOB0gtRSWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305908; c=relaxed/simple; bh=cybpUb9IFSrtSEn6CVNh90w6y5FCshbAQhcAn4rc9bQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=onNKsVK7dJ9rogyfVcWEiIblEiEFQjYewGuzSSvxYz5eqBBmeyHdorn4eyQ3qwUiHpV3i3dbOf+Orl7b5yFa+Wg7iYik0vXIYhQgbQepUPkOfq0SxraiNiw4WmOGbfyKy1QxhAr2z5QA7XTekbN98vnp2nsOJAB0I2w82RlW53o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dKs4cuyy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dKs4cuyy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D778C116D0; Thu, 1 Jan 2026 22:18:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305908; bh=cybpUb9IFSrtSEn6CVNh90w6y5FCshbAQhcAn4rc9bQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dKs4cuyySogigb0CHjJKGicPzpmLF3keWilFbSY06Spy+118Ks90hsSQopL0I2Tta q1YIw8IVK6zIb/FMBQTyTlKkDfWyqj99/pfnp+rHWMmCIaHcamT5K8hKvVKo2tWaVm yuztN+96UASFPFnQGpTrLz3e9cskLBvUVKU2+txdPLfzlb8uQjnAxFbkcwFlhi4gqG LTn8i3HR2EvRis7KMpwBAV8hJH6PqsY1+Wgs7bzHTTjJj9ZLdM4p6Pna/QNZmQMZFA jF8uZmWY6brNA7sO54ERxDBPuY404ON4ub7VEwh7/HPb4ekacbIzK17ccHCt/eAV2a 1shCNQ4Ws5SvQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 31/33] kthread: Comment on the purpose and placement of kthread_affine_node() call Date: Thu, 1 Jan 2026 23:13:56 +0100 Message-ID: <20260101221359.22298-32-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It may not appear obvious why kthread_affine_node() is not called before the kthread creation completion instead of after the first wake-up. The reason is that kthread_affine_node() applies a default affinity behaviour that only takes place if no affinity preference have already been passed by the kthread creation call site. Add a comment to clarify that. Reported-by: Peter Zijlstra Signed-off-by: Frederic Weisbecker --- kernel/kthread.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/kthread.c b/kernel/kthread.c index 03008154249c..51f419139dea 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -453,6 +453,10 @@ static int kthread(void *_create) =20 self->started =3D 1; =20 + /* + * Apply default node affinity if no call to kthread_bind[_mask]() nor + * kthread_affine_preferred() was issued before the first wake-up. + */ if (!(current->flags & PF_NO_SETAFFINITY) && !self->preferred_affinity) kthread_affine_node(); =20 --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 07CB8311940; Thu, 1 Jan 2026 22:18:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305917; cv=none; b=kkvnOcWHlp3/BTUlFHt5bItWnyvVJvLHr2QBeSNNMuinaVbu6fituN0yRNH8B/aGOMTFaJbuBeU4nAYW3xlSHce4n74SVH2L5Sh3tOYROcWxneYpBB5HNestj4sxjXVXgaq0pv1Jd8sCoAKjc5reXgpxzqIrlqUC8Bk9ALTMmVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305917; c=relaxed/simple; bh=kluxsGzh3yUyBuEdMQW2ChyzrN9Wa4B73tu4Iho0QMM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CS+v4mGmaW9EEcxXpngiz46e6NBz1fnx4L5dXfqXcIGAznvIYCIxvG2guhbX1wW+SplMJ8yy6fxzjAzpcYMul5KBF4HTFwQNPKVkHg7MsgsRhWNptMkaM5VkG8us/hj6p3NCnwi1ojgq8hb5Jgbs+NQYsHaz50usMDX9qYJY8kQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sCUxHlmB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sCUxHlmB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD9BBC4CEF7; Thu, 1 Jan 2026 22:18:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305916; bh=kluxsGzh3yUyBuEdMQW2ChyzrN9Wa4B73tu4Iho0QMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sCUxHlmBfKU8mEXn9Gb6CiqvN470rNDukwLhsH8IJ25cs2s+T2WMY+Xx+K/FU+2r6 PWsWM16rGucx0Nc742fDtSvNWY1bkV0VUXsF5pfaMbTJnzC0FB4VXwwfk3OsCfrrVs Aes5McW6JYJvBoWjkGtGQNrKdKBRINtBXSrrCueLNNFZzd6m1GyhdBfhN8pvt1oVLz dWFggAnFJp+V6MOO6xFIu638EERhe2JFPZVw8ufLBF2V/0fMA7B289koJ3yAHePmjy LNdt9BUzdzGeognpYEt6DWKuX1Q1Af8Yn0+HYm26nah83C++ezo5x4vFhlYHpufrs9 Ycf6r9GynPcvQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 32/33] kthread: Document kthread_affine_preferred() Date: Thu, 1 Jan 2026 23:13:57 +0100 Message-ID: <20260101221359.22298-33-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The documentation of this new API has been overlooked during its introduction. Fill the gap. Signed-off-by: Frederic Weisbecker --- kernel/kthread.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel/kthread.c b/kernel/kthread.c index 51f419139dea..c50f4c0eabfe 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -856,6 +856,18 @@ int kthreadd(void *unused) return 0; } =20 +/** + * kthread_affine_preferred - Define a kthread's preferred affinity + * @p: thread created by kthread_create(). + * @mask: preferred mask of CPUs (might not be online, must be possible) f= or @p + * to run on. + * + * Similar to kthread_bind_mask() except that the affinity is not a requir= ement + * but rather a preference that can be constrained by CPU isolation or CPU= hotplug. + * Must be called before the first wakeup of the kthread. + * + * Returns 0 if the affinity has been applied. + */ int kthread_affine_preferred(struct task_struct *p, const struct cpumask *= mask) { struct kthread *kthread =3D to_kthread(p); --=20 2.51.1 From nobody Mon Feb 9 07:19:41 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 760CF31280A; Thu, 1 Jan 2026 22:18:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305925; cv=none; b=QxuyXYOy/gla1m4YyMAUAIk4tsbVHJGqDZNEiwZIGEtI3nq2qrj1f93GaUkxPTehgjF9bL+hbylisEp54pecNwU76MAidljkpWcrTNJHTVL1Hk9NjmlQ9/QC40K1z6e4Gqi8k8b1jljEMHX9WXxNTxwVERhXdz3JhFC8oEw6kSc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767305925; c=relaxed/simple; bh=soOg+pSguRYShDvlBT6z+CExBTh9mpEwKqBDpU+MvVA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jdIwy3WUeopMsD5LEbW70gXRqmh6xo1keBGanz3De/bwQg0RdWuaTYFLPwCdWuvq5cMFix8Au4pcFK9Vh/2+y2vvpPD5VkWMtDZQoN5NhVo+Ba/emGWF+qJB7p+T5MDS1U6lKF4MRcuoHdICmXqbHYtS9s4ubg1WYr76BlrtEs4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ch0+O6T9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ch0+O6T9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5258EC4CEF7; Thu, 1 Jan 2026 22:18:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767305925; bh=soOg+pSguRYShDvlBT6z+CExBTh9mpEwKqBDpU+MvVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ch0+O6T98cz7FFkRIvS/lrnNxuwEZVtNVKFC3b2uDV4OOAyrOCUNOhusqCS6JNycr JUpM4y18xsCFl5PanmWQQ56Xf4q84aK9WKNz43EhMZ1cwGEt+l7YTfU8aIyG79LZFm umUER4Ke8sqCA4evjdGE7hKCxtUMzlRqiHgbST3rqhEnSWxUWB0Ay/pY7a418yRReV VyWeUpgJ1b01hgn0Knsfb6k0nIunjAL6AWFL2SPFbQ9xuquSJrz5ncySl9dYIZ6+Q+ kw65NtkT6BzpNxo/bs+0zFugLdB4vJmfSkrCoHMfujB2EbbJKcG3Fx7qcV66bUr8Dx F9u1AJrAhWhAQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Andrew Morton , Bjorn Helgaas , Catalin Marinas , Chen Ridong , Danilo Krummrich , "David S . Miller" , Eric Dumazet , Gabriele Monaco , Greg Kroah-Hartman , Ingo Molnar , Jakub Kicinski , Jens Axboe , Johannes Weiner , Lai Jiangshan , Marco Crivellari , Michal Hocko , Muchun Song , Paolo Abeni , Peter Zijlstra , Phil Auld , "Rafael J . Wysocki" , Roman Gushchin , Shakeel Butt , Simon Horman , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long , Will Deacon , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 33/33] doc: Add housekeeping documentation Date: Thu, 1 Jan 2026 23:13:58 +0100 Message-ID: <20260101221359.22298-34-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260101221359.22298-1-frederic@kernel.org> References: <20260101221359.22298-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Frederic Weisbecker Acked-by: Waiman Long --- Documentation/core-api/housekeeping.rst | 111 ++++++++++++++++++++++++ Documentation/core-api/index.rst | 1 + 2 files changed, 112 insertions(+) create mode 100644 Documentation/core-api/housekeeping.rst diff --git a/Documentation/core-api/housekeeping.rst b/Documentation/core-a= pi/housekeeping.rst new file mode 100644 index 000000000000..e5417302774c --- /dev/null +++ b/Documentation/core-api/housekeeping.rst @@ -0,0 +1,111 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Housekeeping +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + + +CPU Isolation moves away kernel work that may otherwise run on any CPU. +The purpose of its related features is to reduce the OS jitter that some +extreme workloads can't stand, such as in some DPDK usecases. + +The kernel work moved away by CPU isolation is commonly described as +"housekeeping" because it includes ground work that performs cleanups, +statistics maintainance and actions relying on them, memory release, +various deferrals etc... + +Sometimes housekeeping is just some unbound work (unbound workqueues, +unbound timers, ...) that gets easily assigned to non-isolated CPUs. +But sometimes housekeeping is tied to a specific CPU and requires +elaborated tricks to be offloaded to non-isolated CPUs (RCU_NOCB, remote +scheduler tick, etc...). + +Thus, a housekeeping CPU can be considered as the reverse of an isolated +CPU. It is simply a CPU that can execute housekeeping work. There must +always be at least one online housekeeping CPU at any time. The CPUs that +are not isolated are automatically assigned as housekeeping. + +Housekeeping is currently divided in four features described +by the ``enum hk_type type``: + +1. HK_TYPE_DOMAIN matches the work moved away by scheduler domain + isolation performed through ``isolcpus=3Ddomain`` boot parameter or + isolated cpuset partitions in cgroup v2. This includes scheduler + load balancing, unbound workqueues and timers. + +2. HK_TYPE_KERNEL_NOISE matches the work moved away by tick isolation + performed through ``nohz_full=3D`` or ``isolcpus=3Dnohz`` boot + parameters. This includes remote scheduler tick, vmstat and lockup + watchdog. + +3. HK_TYPE_MANAGED_IRQ matches the IRQ handlers moved away by managed + IRQ isolation performed through ``isolcpus=3Dmanaged_irq``. + +4. HK_TYPE_DOMAIN_BOOT matches the work moved away by scheduler domain + isolation performed through ``isolcpus=3Ddomain`` only. It is similar + to HK_TYPE_DOMAIN except it ignores the isolation performed by + cpusets. + + +Housekeeping cpumasks +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D + +Housekeeping cpumasks include the CPUs that can execute the work moved +away by the matching isolation feature. These cpumasks are returned by +the following function:: + + const struct cpumask *housekeeping_cpumask(enum hk_type type) + +By default, if neither ``nohz_full=3D``, nor ``isolcpus``, nor cpuset's +isolated partitions are used, which covers most usecases, this function +returns the cpu_possible_mask. + +Otherwise the function returns the cpumask complement of the isolation +feature. For example: + +With isolcpus=3Ddomain,7 the following will return a mask with all possible +CPUs except 7:: + + housekeeping_cpumask(HK_TYPE_DOMAIN) + +Similarly with nohz_full=3D5,6 the following will return a mask with all +possible CPUs except 5,6:: + + housekeeping_cpumask(HK_TYPE_KERNEL_NOISE) + + +Synchronization against cpusets +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D + +Cpuset can modify the HK_TYPE_DOMAIN housekeeping cpumask while creating, +modifying or deleting an isolated partition. + +The users of HK_TYPE_DOMAIN cpumask must then make sure to synchronize +properly against cpuset in order to make sure that: + +1. The cpumask snapshot stays coherent. + +2. No housekeeping work is queued on a newly made isolated CPU. + +3. Pending housekeeping work that was queued to a non isolated + CPU which just turned isolated through cpuset must be flushed + before the related created/modified isolated partition is made + available to userspace. + +This synchronization is maintained by an RCU based scheme. The cpuset upda= te +side waits for an RCU grace period after updating the HK_TYPE_DOMAIN +cpumask and before flushing pending works. On the read side, care must be +taken to gather the housekeeping target election and the work enqueue with= in +the same RCU read side critical section. + +A typical layout example would look like this on the update side +(``housekeeping_update()``):: + + rcu_assign_pointer(housekeeping_cpumasks[type], trial); + synchronize_rcu(); + flush_workqueue(example_workqueue); + +And then on the read side:: + + rcu_read_lock(); + cpu =3D housekeeping_any_cpu(HK_TYPE_DOMAIN); + queue_work_on(cpu, example_workqueue, work); + rcu_read_unlock(); diff --git a/Documentation/core-api/index.rst b/Documentation/core-api/inde= x.rst index 5eb0fbbbc323..79fe7735692e 100644 --- a/Documentation/core-api/index.rst +++ b/Documentation/core-api/index.rst @@ -25,6 +25,7 @@ it. symbol-namespaces asm-annotations real-time/index + housekeeping.rst =20 Data structures and low-level utilities =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --=20 2.51.1