From nobody Sat Feb 7 11:51:59 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 4479D823DD; Sun, 25 Jan 2026 22:46: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=1769381161; cv=none; b=R0Gm5F7v3bwtoTN/3n9aFY/MgJ25dHJ21oj6IztVG4RCOI9NwNn4o8l3q+LJq0ST4tEQknWorcFTuqIVd3F0GQ8vw5vIzglI6vmM7jX8Fga9soL58C83Ryq6M8cQd5AD4WQ9EJ0tbUKRz7tfwr0ZXsxXoGxImtc2lcctF39ZDNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381161; c=relaxed/simple; bh=vPL8EzXKWq9iiIp5kuYoia41/85wMoYaNYnO6c8sEhk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZSR0FZ2HvSzc9rGrffIhXN5VEYmt7YnxrhFzTPXahb2rqqb82aceA7z9AnCVDxu88IIpXBP9Q4h9/awGF/waGCz3UUvQVNfoxq73szCUJ/5MyA07RvABpEUtMt1I4HZt3NPzr2FnAjlEdG5o4RUexulqxP+SmYbEjnuk7PZdk90= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FIWgU7+p; 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="FIWgU7+p" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A88EC16AAE; Sun, 25 Jan 2026 22:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381160; bh=vPL8EzXKWq9iiIp5kuYoia41/85wMoYaNYnO6c8sEhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FIWgU7+pr7+ckwb83DyKxDiWT8xbe7CLrxGuGRjBUui3ebqjTplaAEWc1SnTKrjOG tUx+pdCeJFih0IMyujpdXJcHTYc5m6E+TsbZUkcYq0FjizUFEUOr5uKfn1ANgV8x3c iVZKrZlS1Txl44jkj+YbP5PDaSiE866VyLyaP3azWSwzmGZ8ZkjD5zVumV8c6k8I2E br5lPpen+XXuYE5ErnUP87vKq0rH5MzUQOK/Wzr6hGKGNE5Rz+Nyoss94n5SFzlEft rkDsNXhbh/uSNRerB1QWLMq7i4T11QBlyJZ2emnty4QgtX4wjKvHxpfQ7H7fWu5r3J +QCJLEqLO6GZw== 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: Sun, 25 Jan 2026 23:45:08 +0100 Message-ID: <20260125224541.50226-2-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 993B130DEA9; Sun, 25 Jan 2026 22:46: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=1769381169; cv=none; b=gSgCs6nJv/cWv3zdEQxKKM6hbwp5R96tcqgHBrN3ZiF2TR1hc7YLPUuL0OWJ2fx6qiZ2ujM3pzrxk90xkgHwaVrE01NpCSonZzDbQKLauT7qU7BEPyazW3t1IFesKoKQuo0vHJ3NRFSYLqdut7+t4nkNzgjmRiN8BQvm5ksFgIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381169; c=relaxed/simple; bh=11kVg/bDOXpa/yvnQMWYkjqm5C/SPwrAAGSvfZEuxSQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L1TD5KqPZ1znaOtAd8EnS5Wql4c94VDQIcknMhVhIPBVlAJ21IrEsrFtGX8/ZUGdwXra59zHCHcbU7p3amBhJ9jVXv1rzs7Qb5zPotOhScdYvnfXJKfyT/XOsyvzA48y2YgpeJtUi8SK+GQ/xjtMAZNayYolXcsLiBQbawtQesY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hJRAwobl; 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="hJRAwobl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49895C4CEF1; Sun, 25 Jan 2026 22:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381169; bh=11kVg/bDOXpa/yvnQMWYkjqm5C/SPwrAAGSvfZEuxSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hJRAwoblsccMiodobRnpFQtGpl7gdxJB6n0JNacQjkT3UO8ssdSlLJfivDoMQVuXT wCi8OStM8FmLsLva1RcHux2JzK4oEe1rcGtTC1CLlg5MJP2qceYP0hMKyY/acCEiYE 3XRxxxD/co2sos47qIivFwk3U2q8xCW3LoQ7QmT/Emn4nLa69E7qOgq4BXVQluLogP td5NDbweSjT7mCDWSEgJ4Cp1IY7VhKyObYeNMJOhIPoENPXIX1ZEV04RF1G+8hC8Qy cnZVjB3llXMwhAv+AzXVrxjs3FZ08WV6sZe3qFJOe68oPw2I3yp6MU1lf8URxD2gKE a2mPuA1WIz3xw== 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: Sun, 25 Jan 2026 23:45:09 +0100 Message-ID: <20260125224541.50226-3-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 A0F4E1F9F7A; Sun, 25 Jan 2026 22:46: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=1769381177; cv=none; b=nYvKCxdP9uMF5eG57OM7zCOoH/rpQryQJJyB4xsBkKwvlt4gCelq7C+8RNlTMZ+A6MhLz8FPfcVcXmPrg/AF5FdSw3PCRtnbvSxBl1PaIdqEMrYS82/FjWBht/h9hVhDmP1jwvuNLm0ZlZl1gqSN5We1FS7ZH3JBKQd8g9IVJBg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381177; c=relaxed/simple; bh=xkhk7ZGxynk2RcaH6iYDB0TKNwEPyWR7khi8Efbu4u0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OEWVr6owVRyAV0nY1hDIjQSFWNePyqkt/DAhI9IWPWpbDqcr0zgYMGSD+mKYiJCa8wsMCZrTa86vQD3fEnpFefLReVwE/diTacSP+Ix3DLLOkWfCWwf9amhj0Ly7JBGNT7hR1JE9fA35OrE3/v4YsBpOr6FbnHymI/o9JbRtvck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bd15xw5x; 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="bd15xw5x" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D6ACC16AAE; Sun, 25 Jan 2026 22:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381177; bh=xkhk7ZGxynk2RcaH6iYDB0TKNwEPyWR7khi8Efbu4u0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bd15xw5xwORVoabUcDJ1q5vVXlUYP45MmfLpf1Wj7eumbe1G1offqX/LsP2i05p8/ HJs/Ycv5vPdLg/ki6rSHV563InBaJlvvNpL0K92O622nmbd042+g9S/1wd4T6PYK2D 9aiGuiOJSIPrOirt4z5JnC4GNDrneBm2dNyp/TSMPtL+M/AkK0EU8o6AL54sojyU6/ 6MOAnKTImcHfao+B+LDXo/+Z63S6rC0oSeuJTmLh4N6F1x8dDaL2uM2Wa/ReCCKUzp mY/kmoEtTP6ML9TH1hzaspFsZoenAkurH84HQ+FPm7nCHw49b+ruwIfNkN/xPSnIhb Q51QFBv+lYVgQ== 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: Sun, 25 Jan 2026 23:45:10 +0100 Message-ID: <20260125224541.50226-4-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Acked-by: Michal Hocko --- 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 Sat Feb 7 11:51:59 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 A33132F3622; Sun, 25 Jan 2026 22:46: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=1769381185; cv=none; b=hW7TlBQPldRwT9KofIY7wN7QkNvbmNDlM80WkeskGac1C3UXWuG4l/1yFpEJsyqJ16Wal10U96UQ1baZZ6FNxZUYQDoQbpM11xawWcL+cTfU9WjUXaLKsSF9vPQV5CCPCPvYG62aJAVsr2tmcwzxtDSKiUObdsRRQZsnEEBkABM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381185; c=relaxed/simple; bh=gBHkj0y4jQxeMV2qzbEciSScfrXq1yZennkNx/2Itiw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pCaS/Gye8K3RXPjbKxvOJdPXbiNFYGqUYQeFuYto285COa4+HRjrnKbqqKXi8sG5fMktcpoh5LqPFzuSLK3VRyjIwvT0u4htQ0cLSj8ZIaHPgq+x4JnSXKTx39olHBXKEIJ1Zzx3uOc6sW/GKOUi0/CEXbvADwuqOG1yZ+ha9xo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Vya0JZRe; 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="Vya0JZRe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB51CC2BC9E; Sun, 25 Jan 2026 22:46:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381185; bh=gBHkj0y4jQxeMV2qzbEciSScfrXq1yZennkNx/2Itiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vya0JZRerX6XRdRcf+3ZmdU/VAEs0kDelL44rPDaZbuk+MvP/g/c9RDBz3cwK8BoY RJpqDdp3lBNV9gvBtq9dlULnElIRSCM8Z+CopO4Ea9g6llbuGy+G63Wj0iiJxtbkIJ V/QGhA02i88H47QMfQ8qzNvuiNvyd0ROzYl5Vnjc/2bAW5o2ZkH+2zGUY4dk7766yu L9cRZiPRF+c/XXRBcW3h7By3oYGAZjVTS4iymb87J/ESjS71Q6dPiSD2CcWX4s05ii H6etrU7Qh8TJQVkTFdSCJCTwcVkl1DsOcbVuDcGZwbYaQiS0nykmw2se/R0Q65O1Rk RkKVvaqqzrzUw== 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: Sun, 25 Jan 2026 23:45:11 +0100 Message-ID: <20260125224541.50226-5-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Acked-by: Michal Hocko --- 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 Sat Feb 7 11:51:59 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 0A1DD2FFF8C; Sun, 25 Jan 2026 22:46:32 +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=1769381193; cv=none; b=BuZpvRnBx/6HAk7SlI/559QXlO1xn4cO9ShznINQmUAc6MNQVRGPXN/GA8c020+nAad5zjVRwYumd7GyGzCVOsL3EDPCp7j3cfx1bv2g/BUXjxV1JxDnr3wHplxRkIK004u2cYrSzxJMzY/ULNylkzEwUdBEoIt0WPzzPuyFMdM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381193; c=relaxed/simple; bh=JkXt23imzQZBGJmS8wrmieQIzrgOcUkUTqGUwsGlyvE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=snhmTkIcJDY6/AG4gMzuaHpYMQnje0uVPXGuUeXIhmNmuKwQxFh7NIc+fI25qGw67HEJ9hf1uyHo1fgbvrcgcNq7wpx79my5E9A6YIaMte7Fc7dLAPaztyv2A5SDcTvpTPeEQlkpnEkdluB7AKoFsUh9e3Ju+Dc7j1b0coawDvM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NCo6OzUj; 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="NCo6OzUj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF0DFC4CEF1; Sun, 25 Jan 2026 22:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381192; bh=JkXt23imzQZBGJmS8wrmieQIzrgOcUkUTqGUwsGlyvE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NCo6OzUj+5z3fShzlerTKOSi2VNbYcycL73l2Toam+tXKL7QepiGm0M5uE/Xi1HOh w2+ws74ssU/HLOIjxZzVMs/CmT6qgAn9fIh96Bx+sDrWJI4jFGVdKg+lZv/O93VtnH TDxUomhuOznH6kr8UuKgl6kN+9fdrwQuWAzEytGAQypm0VJUb07laV/4EqjL7tO7Ao YllT0BwcdqB9VtbIAtFxxVD3VrldCqAofRvgCKc8w8Lj76cpGgjpsEpOAcAb/M/QoC riI4/A8lGc+aQKBYnirPNe+usCyzAlKT4TFQLdhiP7FTQnsDCL4g1rcUJlBZBV16sl H9KSW5ZtAXQ2Q== 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: Sun, 25 Jan 2026 23:45:12 +0100 Message-ID: <20260125224541.50226-6-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 6D13130DEA9; Sun, 25 Jan 2026 22:46:40 +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=1769381200; cv=none; b=Gw5nAgHcKGUBJrZQlKY4IEuP53QRyerkrUvLcDXQnQuWWBcx87nwaW1qJnwIRGbOVizc0B48ANKStUv/obbunT8ML6CWaWGPsfk3FfJDTuZokqKm1DZ8eCsANBVpQzc3le6iZx5hK5+DyUXpoz/JVW5Yn/qvv6ixLmRlw8QmDZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381200; c=relaxed/simple; bh=pTB9cNPcvPakmWV9jutt30tCCHfCDIAA9k4V/apVATM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nMELAxgmWqgPQETXDkGmE+g9OxJKfN7z51TGQmezVIlBywYTKqRL6t3lizYkrMI5VtlqTfqgA5cnpaJpL52WQutxJTNMMiZoanwfSSUFy+JgROOkVo9zk3fe5+PAd3FFK33AMfHA0Trhtc03clv1FXH1+z84PltvldFRb9Ux6ow= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aGGZML+w; 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="aGGZML+w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15BBBC16AAE; Sun, 25 Jan 2026 22:46:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381200; bh=pTB9cNPcvPakmWV9jutt30tCCHfCDIAA9k4V/apVATM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aGGZML+whxH4c/xSgMhk4FEyW2E/CWTmGwSjAzdR7qsacQp3b8hfFVgE447fO9/dX IQEJn/vgUpEZUS6tbTqkaYXfkNrSvsbqHhzEPX7xBth/mnWW+3tJvuHvfKvQAC/vVG vEGDolxnjONqPuiKrBNoysiyVqrAVXx0eEqiEVlIdaL6NLKgEAffKrWTi9riHYAikG /hwF51Wz5CFt4Ib6YpUG2jmb6nKt1OcFQptXMkoStma9Z1bi3gqYhu3s/Tvf0YtVar uzE+IeGNule8/0UK3WlNJWV0oZ+AhujXHcgsfp5fecQfYHKx32nJT/uyqQWy0UYujU CYmtYFJauzfgA== 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: Sun, 25 Jan 2026 23:45:13 +0100 Message-ID: <20260125224541.50226-7-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 EA7D430DEA9; Sun, 25 Jan 2026 22:46:48 +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=1769381209; cv=none; b=ohYb1L8uQ5znDYpb3a4FgmQgB1kFvcQy/6yhLiKMP+mgp8wHEtFHG7AnHITDWOT+T5hQY+sLdQeNznS7KrbDC9G5A3pvkVOQ6lErTqS6NXelW+G0TEn/Lx8hYfV/oRq9DgmnYUgb3zVEl3KSglnXJFjmfROYrmrnlP4DJpjHzuE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381209; c=relaxed/simple; bh=N56RJwx7Vb0djbwM5UfAAN+LOP0Kn2KqSnmCrDj/jJE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f9mbm/0yWyGPGPnDuIm4/AV8FliGFzhkhSHFJg8IlslmQ5hBuKlUZubxZUUlRar1pFJT+nl0REKJeB6vqj/oDd48hrabOJWONBmxdLDrDbv8PlPqlH8CNU07CeFP3+F9SEXoDMhsA2ztS+gy14jxDgEX8XI4RgOA3CKUsWG2SM0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UyHyvsIu; 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="UyHyvsIu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5B7AC4CEF1; Sun, 25 Jan 2026 22:46:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381208; bh=N56RJwx7Vb0djbwM5UfAAN+LOP0Kn2KqSnmCrDj/jJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UyHyvsIu3okQ7Dlrf1ZCbraTIEmvPj3HTE7McqBEPQFbSMXqbR7JC1o8FMfOZ5Nus Q0VStLXxJa8HFC8tU9CxjBr+GJAO0LSOS68Rky95s/N/EpY3B5xpjhtYJYUnX4DqlF ugG/ANCw3sRSMZvTBSK2hobdEYUt4T9D/rHhR+ohNj687AyBkaVf1S/Ds/MAyJa6ue ntDh/UYinNi61GJeloa/JJXblaHR6n9fE0MGE8ZRm26svM4ZXhwoEZYsHjx6klL++o gid4fhZqJNRtQyW/mAw1DvMlbvBzIy1VeVFBCDXa+U33RbENMF2WCVNMGDNzansp9s u9p6/bEs4ZVWg== 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: Sun, 25 Jan 2026 23:45:14 +0100 Message-ID: <20260125224541.50226-8-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 D3F2130DEA9; Sun, 25 Jan 2026 22:46:56 +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=1769381216; cv=none; b=Z48FII7qhNXAPyHl1V5sYtwoR6ov8qY6KXm2DlRe9r39zGs9qU67t7TSBGQpsNqjVIRrWEzb1qwgS9htcZu6O1DpHek9zUtYnTeltRuRlbCtYOcMY/7J2jYcaaWqKpwY+Pv5Rc0NPX2zU+7u5pSODjhwlVAehhYxwpAdT4lHykI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381216; c=relaxed/simple; bh=gHL1k3Ce/0Yqnu3RKEhMFCTtXjaAjQ9JVob0E5Uoa3s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IEb+dhcsFEJ55f3RefIz4pc21GdNhdt4CmxQx1JqLBPS+gXz8OJiK+CA8pHgcxqvAHEtTqjXVLDo/pgVRH0vq2O3LwxlajNYPmLfiEMrObobUM6lM0L/NcbMlqGA+06PBEYKEEYgzcl0TzVLvQcWZK3ZaiI8bXKUqdUYM7gwxY4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NeWRcvHf; 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="NeWRcvHf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16F61C4CEF1; Sun, 25 Jan 2026 22:46:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381216; bh=gHL1k3Ce/0Yqnu3RKEhMFCTtXjaAjQ9JVob0E5Uoa3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NeWRcvHfyNkP41Y23+BOqfICl2kcKZg/8wKK47gGHMusAHbGA2Wo7fFtJRW7vJrCX yzl5Q2dYHHh5Nj+MLKzPGz5ditBgiu1Kh6txj3s/1tsBYFB5jUDpfDzgKJQ78xA9i+ vzkzY62pMpw+HbiFUi5N7D8TXWBRLwsIO0Tqs7qfREjVLgSIKCbdetc5JvC/vbLtFM sGym7Mn6+sf/Pr7KMZUdgSqsox+/Y5NuRSqcvqjRsqx4KegjDVKO/x50YepFOOMc8H RLpX2Ta4FLD8OVTkqUJ7OsFBHGf137O0zSliVHv7zlt4cT0w7Y8qThUAZgqeYQBe+k qk4tadz39hsKw== 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: Sun, 25 Jan 2026 23:45:15 +0100 Message-ID: <20260125224541.50226-9-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 EAE3E30C626; Sun, 25 Jan 2026 22:47:04 +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=1769381225; cv=none; b=KWv1whrs5N7zGhG8/lDlb1xT7dTkzJnQeb0+amby0WEelhlnhI/DG1w7XoomX1dP040JgRvuflRer8FY3+TDpQm23G7+MvLJu/z6zh9HP/8bNWnqBD5FWtP/6sp5Q5ocO/hDIBpSRzYmrJ2YzQXqYX/NDnPYup6WSvpIZo7lwSw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381225; c=relaxed/simple; bh=CSBqMHaVS4LYUH4nZYK0n1Q3mrGckGoVFLRQaFReEXw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MWwMIOom0BcOfG0zLH2CgUKxXXOXe5L+VeY4iPuSSTjuiEzXLu4vcx7mB/43X+j75E4hUOz/T4BGwqX2E4X2LQvFAj9/wk0OXM8udVEz1ELqUY0mRB71e3k6XyGRytUdI2uPmMzVpTfkluKdTj5RXQxz3vntmaDAZWr360XG43Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=temhnd07; 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="temhnd07" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2BFEC16AAE; Sun, 25 Jan 2026 22:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381224; bh=CSBqMHaVS4LYUH4nZYK0n1Q3mrGckGoVFLRQaFReEXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=temhnd07RHCs6lNSYUz4dbj0AdS6VgNvDbHHoQlwXOwUJoMRDGW6YISibUt7MpdLw jnI8yaWSPfggyIWb9RllrE4gvUIzfbvX7Wkkex438uhX1Q6DMwMifEXgCIYovYdPi2 Nz4roDXgmETt+bVRRIuD7SU6+baquysP7zPZFV0nRG/4zl4hxV7Rb9tZdivbsT5sd6 jRm8usW5uMG/cXmbECMxPFLPyK7QOV71u+IsduLIES03OtEaV2UMKcf37Gn97vcjpL vmQQtoDswbo1ah3b/RS/Or1mUjKopIJ+G4wDoUQgpGQ9VxlcCsO/MsQZlJ6NkPPfEK elrCpb0Jw4Vxw== 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: Sun, 25 Jan 2026 23:45:16 +0100 Message-ID: <20260125224541.50226-10-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 D93A9126BF7; Sun, 25 Jan 2026 22:47:12 +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=1769381232; cv=none; b=VNoWvpZFyCwA24P7qQMFZbMW4HwY008esehyGpCPIni30CrdmJRzw6mprPoRfEGAcBQa8qe4jB9Fz5h8nBRS0CSuaQM9o3FF1hhVXfDBVrHMRFuyIgiL6YZc3/RLRbGVJrfZ5EGbKc4S6Z+NJ3QsZwD6SoAktnVCv6AUh2w69Bw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381232; c=relaxed/simple; bh=cfBsUi49kwBpo1bGsw5oqJU14C2/JcinY0oHFYzJ/us=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u8iGf4xIyVeZZp1eJ9IqFVlbIBSPEKiPNjs3QPYXpkDdhhJAIndJUtlpEW6C8iGTyJd783HuRW8mhApr70dxFO5TZMy/VBN+9J56eOXst70xyE7cy0/ymQUUtMDY9d+23Fu6BNgoeWzuTKQdr2aUD14YtY1tizi/gMn45x9nsuY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EECGCyaW; 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="EECGCyaW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2CFFC4CEF1; Sun, 25 Jan 2026 22:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381232; bh=cfBsUi49kwBpo1bGsw5oqJU14C2/JcinY0oHFYzJ/us=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EECGCyaWvrVDR26r8FMcmAew6wPA696Yx4BFQy1/SqYAn+y03+OxAk9+r9OlqSwfx dnJZcbibQmmtLq12EfALx9aJO9zD3zSyo9QEAZH+qmwiK7VWDFNOCMZAyrxdK/n6PL TZsk+H5oEoc+p89p4HQbJsBDVgpGJ61Iyw1usvP+o1i4z2UQG4ptq8w8S9uW380t9c cRYDPhWZFKZpG4XX6IRQTcpmxhTc8LIrKExVxVLU/3BFtxZoBYV/aDlNyu0PrMeGrF wgtzwFzUlAwd4Ey9GEdOxxpf3yeaEeHIbYESHjtUcwxBHuYC6yOy+Z5Z2Rpwn5icM7 kxq7nEKhH18Yg== 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: Sun, 25 Jan 2026 23:45:17 +0100 Message-ID: <20260125224541.50226-11-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 299D530C626; Sun, 25 Jan 2026 22:47:21 +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=1769381241; cv=none; b=rTeU3W+o3tI7wvpemFHNxBm1n2JQNpnqF8YZxosRYNh//E9XsLuoCXO7yoBgN8z3z8OdUH9/J8vbv+N6/bvXYdTs7Mvq2icj5s4YfcFKAqGKZxnuiAueB6rLpLX2KANwIazUBcTrQP/4uN/dbm9aodol3AuUsizgWWMyOdylLX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381241; c=relaxed/simple; bh=JzP68aQ+gy8MFfasMpMI/FZxkM6LDJNtU1916wSaM4Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fGZBaYRrQPAebrMG3YZGgqe61Yxlocx5j+w+nF6tCKQh6gc9mh+9f4yRX/rSbc0Q1TNlTRNABEDPoCmFuknQW+6naMnos+9mH9ee1AteUb49F6LGyYQPnaM5GexzJC/9RoiNc8zchxgFCJHMcQcSPMv35IKjyIJ3xRBLIBh5VgM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pZH8jb1A; 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="pZH8jb1A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40989C2BC86; Sun, 25 Jan 2026 22:47:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381241; bh=JzP68aQ+gy8MFfasMpMI/FZxkM6LDJNtU1916wSaM4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pZH8jb1AUqc5N69sLqgEmq+QKBIiu6wiiXwzJEi5ZGmmLVjLEJyxuwz+pct9+lnSw w9njNCBXNzXQqNSoNUDSdh6XRsKeddfyc6cH30vOjz2hIdn934RKFCg1seb7tRkHI6 hB/wTPpPo+dQbJku/sCGbRXfKLCXqKbPzh6s15mJoaEYChWfkMQyimU7s3WAJfcKiz Nh+yKWa/cQ/p2I7FbwCGFvu++IydAkJCkefhTyDIJIyWM41dVxKka1ZZUJhKbzFEko EbnSL7iQ5ftw2Vdjyb68aMtE652HxefnDQ2pPkEceU8iHyxr98bucDWchvPQ1msLFi 7kaC1al7RQRuw== 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: Sun, 25 Jan 2026 23:45:18 +0100 Message-ID: <20260125224541.50226-12-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 8AF7230F551; Sun, 25 Jan 2026 22:47:29 +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=1769381249; cv=none; b=Lrv92Ejqig4b2a6+NfCmMTV8j3CapSJmxbGb6b+zgPVrYPqsE8Rdky0WMI4PtdxTb8qLCMFEHfffgmgfT9UpUNzmA3hQwGNLg6BDSwfTbZxTy570i05A7WXf3NPyPssghw6YhIzEYV1+7ooMxd+a/TUnGbAGUBoRvu9iAzgg6wo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381249; c=relaxed/simple; bh=v9YrBjmYoXXJcaUrCVcNEergJy1rpdNBj6w7mIgdodQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dNr/7qyv2sUSdy0QEKsM4keab5Ew7UEaW1+PHRfURBpk/wyq1BCXmZMJq+9swAX+adYbz8V2RvrBhp4M73iH63X1OBQc/Pu2eOqgqjinm6//qRPgLKedenLBhmwWg3Hz6rS50sAtiD4bUckNSmQh/lliA9p0M+Cr3xWxSu+vHVw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XO3eKJpi; 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="XO3eKJpi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AEF2C19425; Sun, 25 Jan 2026 22:47:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381249; bh=v9YrBjmYoXXJcaUrCVcNEergJy1rpdNBj6w7mIgdodQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XO3eKJpipVP4C45Ce6EDtUhF4Kpy//JomtboPzMqwpCX/glAEuwTyQX2bUD3y/T/h ocneaY8G1ia5hEL0QFOEuDorsU2gPA0eJWNU4wL+oz7Ayk8pN29ZU4VvHVPUYS/U1F KdTS6T2KpyzJkoOg7eGpu59CTvWxjsPzI8vF9p+DtfMHYftoPrfWlR2xxH3RHg1RGk sE65qjjQVL3HbQIBqFZU0HP6K1PRny2miLAOqs5tWpoUnIHYQzcNV80SWv/8kCRaDo mKVmBnCxGTjB3HTkZSqTKg1jX98GM78mHvBVwfsf/XpfP0HLCk/MazpRhN5FugcIp/ Zyq/n175MmaYA== 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: Sun, 25 Jan 2026 23:45:19 +0100 Message-ID: <20260125224541.50226-13-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 935B730F53E; Sun, 25 Jan 2026 22:47: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=1769381257; cv=none; b=Ou6+gd5CMZWWC5DfaWKoJA7fkFWInpm8+lgtPD4HR89HSuowlMXkX5wbg0lUs/Bm4vzX711sB1VmwMtGKQz+HCn/KaU4QLmHZLONKMyzUwant599ULCR3MVjcJQ2R/8pmBK45znSOoMZ7SiLdMCi4bTvMMzfe5AYCHF6zQNGWeg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381257; c=relaxed/simple; bh=wMXJKwwq0CUGfNI5Ih4i6lhiz7gOrxOgiKsZySY9z0I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qD++KwQPFyXuW1Iv3cUQ6tWL0YsjsP/cvVWZ59aV0JuL1cyjcG8kZbOp3YelzMWsSRqUFDSZPCVWIgtyxq913VgR5hUt+pexCwg3SAfDLgV//U/5PELg6Os30GHjmckFygDAmiBpYNQ1P+YlM5zxqk3ycwZIPr1iIqjEMcDJIuQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p61JT54g; 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="p61JT54g" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AA36C4CEF1; Sun, 25 Jan 2026 22:47:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381257; bh=wMXJKwwq0CUGfNI5Ih4i6lhiz7gOrxOgiKsZySY9z0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p61JT54g4toxPnCarvpaFbBjsBbe7y1z48sMSn4GtBKRchfD+DJ6Ktg76jyXqw1QB rOKCvVHN/cqoTXvZZNshucufY4VXA3FM2YoP7ajXUrLgGIEsRmQ8ilZpXbOJVt//Kh NHd7eHilOaEKEtxmiz5uPC9PGvIKQcatLEuwA3+kF8nHRUjAJggboXdirVq/Wz122y rVLgihCncKuJChsc7b2WZT87+bDFo+VCqhKkZUIYeBoDqrIrWZKlWqVn01mGIpDcCI 5cnFi+ABhROKFCwKxe2jKb0e2Yz56ybW7n6Q8jOpO2+5RsvgD2a81S3GiOt0HY23nc s1yjuVMQYNeJw== 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: Sun, 25 Jan 2026 23:45:20 +0100 Message-ID: <20260125224541.50226-14-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 | 60 +++++++++++++++++++++++++--------------- kernel/sched/sched.h | 1 + 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index 11a623fa6320..6f77289c14c3 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; } @@ -183,7 +197,7 @@ static int __init housekeeping_setup(char *str, unsigne= d long flags) iter_flags =3D flags & (HK_FLAG_KERNEL_NOISE | HK_FLAG_DOMAIN); first_cpu =3D (type =3D=3D HK_TYPE_MAX || !iter_flags) ? 0 : cpumask_first_and_and(cpu_present_mask, - housekeeping_staging, housekeeping.cpumasks[type]); + housekeeping_staging, housekeeping_cpumask(type)); if (first_cpu >=3D min(nr_cpu_ids, setup_max_cpus)) { pr_warn("Housekeeping: must include one present CPU " "neither in nohz_full=3D nor in isolcpus=3Ddomain, " 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 Sat Feb 7 11:51:59 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 7E88C30F806; Sun, 25 Jan 2026 22:47: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=1769381266; cv=none; b=GlbvfUrDLtpOLdUMtQe/xTvQqVnv2BvP0SJdS7ZcVL0IgGYG0S52z/2O+rI6F6Fpg7BW0OFwH6DmJRauKslWQjYUpHkB8EF1z0zz+b/YPnJrTHl+amjqQ4XV2mxq9cCrjCpmoopCE6zNrXTAsCi7k4BeS22uwnHwXzWKx4V6VTo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381266; c=relaxed/simple; bh=Qqaq4aoHo6a9PFuRdP+ZSEkR7bC/Dwwr9j36rrRCXWA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XN5sROl08CkNGtuI9Jctp76/n+JaptuPVlhEUZMoyRvCCEVz58Nnsh0PpEFX5CUQgz2WvDPfiivumvd5uP/BocvdFH2v/jAcO77oB+MxMCclpt+Vc9Dqi/yo+SMY/PFJBQHUrca+xx9xtUprpcBr5+xkPsVpH4bUMA1wXbLvjIo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VFdZRXOu; 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="VFdZRXOu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEEFFC4CEF1; Sun, 25 Jan 2026 22:47:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381266; bh=Qqaq4aoHo6a9PFuRdP+ZSEkR7bC/Dwwr9j36rrRCXWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VFdZRXOuNskCqzkyJTn9woxy8lPuAJFb1axhe5T+7oO0PrH9tmfL11t1II0sm4SiO w5kUjkol7puwqNVbEmhXa26wvAAIi5Wvm4VYVF4ABPSjoCdfU6hGPkETjQQABXdKnk 7xkvXnpEFm0t/VtWXyVrWNtEIE29ZAWNjDNhh4zBpDIIe22sNVyjbFTTBJtjbYKBZk aXt+8mBfwP/0eTEeFGuyIhW3aSIK0wepa7mPCpWka8aDMUZEkFU+csINUz3q0/URFN N6KnuMomNJJbveTeQQADosEjw+jau46beFuYAV/XBbzpvDrwxhLUcP+zjVJq85SxXr Is+LWJ4pH0Hpw== 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: Sun, 25 Jan 2026 23:45:21 +0100 Message-ID: <20260125224541.50226-15-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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. [Chen Ridong: Fix cpu_hotplug_lock deadlock and use correct static branch API] Signed-off-by: Frederic Weisbecker Reviewed-by: Waiman Long Reviewed-by: Chen Ridong Signed-off-by: Chen Ridong --- include/linux/sched/isolation.h | 7 +++ kernel/cgroup/cpuset.c | 5 ++- kernel/sched/isolation.c | 75 ++++++++++++++++++++++++++++++--- kernel/sched/sched.h | 1 + 4 files changed, 80 insertions(+), 8 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..e146e1f34bf9 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1482,14 +1482,15 @@ static void update_isolation_cpumasks(void) if (!isolated_cpus_updating) return; =20 - lockdep_assert_cpus_held(); - ret =3D workqueue_unbound_exclude_cpumask(isolated_cpus); WARN_ON_ONCE(ret < 0); =20 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 6f77289c14c3..674a02891b38 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,45 @@ 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; + + lockdep_assert_cpus_held(); + + 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_cpuslocked(&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 Sat Feb 7 11:51:59 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 B43902FFF8C; Sun, 25 Jan 2026 22:47: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=1769381274; cv=none; b=g+iyzl+OpPCUgIlabn4yaqeNVzPS7AlfbSOqXETWcT2b7teyXViurXdpytRW9rwj7vMZydetgB4Cpl+AXAzlFeKK3GNFYJr34/pbFlqbPwZmAfEG1LpbtzS5MhKhdMx9y9hWtqrarfY1cOAclLrajfbU15yLa5LZaSkYmOUu8rQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381274; c=relaxed/simple; bh=BfOLTh+rKXrQuPYF24CMRF3A211Wdv94FBZKVfSgI04=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L3NsMRw3Pua+x7n1CsJyEBO2E1ugNQnvyYcjE/xJbXJtU3aTOrn6EbhJYfeoXCYHaASLGQpg49GjgBhfqNb3004utPCE0Hiyc4cDTlfINAcBntNEffv8VtwakmYfl6Qvj/HJ1Du2zdJAiDikwGCN69Ldx3vXyxC29+NNltrbALg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gRN4U1TJ; 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="gRN4U1TJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C940CC4CEF1; Sun, 25 Jan 2026 22:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381274; bh=BfOLTh+rKXrQuPYF24CMRF3A211Wdv94FBZKVfSgI04=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gRN4U1TJC+1Gt6KUeIhNA+ZdF2HuReeK73gmUtGQc06MU3q51s4bsNS9KXkD8LbYP Iub1vFYe7KQKYLrPX/PbDUuV9uVJ6E8FPwiKNbS6zmsHrUtTYR0pifVLO6Ifc3VXmA 2N8ELJtuBIE5w+GAJkjpX9Py1jf38L2KEJZ/rwJCNuFnZKlI9csfamnVL8RW92nShk KxolpK5j1ZE1J2rnfGlmTgG6AJggLNljRxhYLbJlqEZaqrP0vq8cY6d6636NBHo663 QgLt6LqoBvhpiUCZ+bd/rReCW7dwsGkVHQJ7JsRNsdOYDTwMT0BuQ7KgtSW2m/JqYX 5vmEhUetC7Mqw== 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: Sun, 25 Jan 2026 23:45:22 +0100 Message-ID: <20260125224541.50226-16-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 674a02891b38..f4053ebf4027 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -144,6 +144,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 Sat Feb 7 11:51:59 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 BD98930F52D; Sun, 25 Jan 2026 22:48: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=1769381282; cv=none; b=fwNlt6rN7u5ZKxwdvEuwcbqLfvuoDk9etUJvqjUnni8LtGeoUfk8qeiuzfksTw/5sziU2A9PT0IaTGD/kRguwDC2UCo54qgfljMRb7/5ZWTgDnDKWrQhYD1DAOJ215XW0Q+SAk3pIQS5S5GhLbNVShPwfQiOXx95hWSZ+aYf26c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381282; c=relaxed/simple; bh=FCpWtWiXviPK0JfRDl7l6gUIkKLhd7cslD/kQrH3RoY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uA+YzZJgRk7q9/3cceQkKN/Jauqxq2IprJAvLfghyuXWIazT+CmjkNZu0Fs+y3elZhzje/2GHcEFBd7QjNgxX7Q2SHKZPud/j/ld6/0Y1Va8wU5RQQQVQxFHvn2JlzE4GNASOzu6GgeIz1D/ADMcyhDdpDIGcAA+MW6RiNGLpy4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AvvAZEyE; 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="AvvAZEyE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB0DEC16AAE; Sun, 25 Jan 2026 22:47:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381282; bh=FCpWtWiXviPK0JfRDl7l6gUIkKLhd7cslD/kQrH3RoY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AvvAZEyEtKaCfqe5rzGN+Pe7C6GMyaY0JllgN4JVMYWGnLlNJNMdrE82nXGnwhGuM ig2aZgk1vOhsGKD2pYrRPiiWKmtUfAKadlZRhaB1yrmh3eS7VR2seQ+xqGKuFuHfSR Xe3L01V3/QzIUf8hJqhxfK9DybKbaI+P+ICudgL1O9w944OVckhr3wBFBAGPdKXFW+ 53ZA6GDuvwES6ssJ+Rq8iWRon/KwIXxTepltZWSJLs9qqxHWwXCSZ8iJQdkGLBwt87 tcu6mPw9TRNqDDyUxf0NxLM88mYLKgvwTbBktZFTFcjcJU3VVNLG8MOcbxDic9KV7e JLkSJiy8P+F6A== 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: Sun, 25 Jan 2026 23:45:23 +0100 Message-ID: <20260125224541.50226-17-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 f4053ebf4027..160b3fcab209 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -145,6 +145,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 Sat Feb 7 11:51:59 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 147F230EF96; Sun, 25 Jan 2026 22:48: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=1769381291; cv=none; b=ulhXqnjtQUypdd/5H9bDNYFNhwoHB5OGkR3RzdeqIO4Ak5BJvQtyXGGF0fkWH1TbeLfk4mOKSoc+PMCpZWYMc/JKbrce0fchWCuMZ0JvqdBo3AZzySzJAxQTm9yNi31md5mOnutUXRmCJmwjLMvOBagqeV2EU+eX3lfE/DM9AJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381291; c=relaxed/simple; bh=P/TRTFNVIMdojDSgDr/B6FcyiyDRu4/UxmoQr5eq/JI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EzUIz4EDR/ep/nVpdSwTtznHIP3OM6GSTbfkmUUIzeaus1Hb5itdZHvQlGw9cdBbrZGhCy5ShID5mnjn19FFZNOKXNBjCNqKEqzuY0wnt5su4yE8O7wssbky1eTLXMHlN+Ig2f7EJ327uPagkdSn3ayOygKj5OfxY0jB0Eh43No= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=G2APndNk; 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="G2APndNk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC19DC2BC86; Sun, 25 Jan 2026 22:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381290; bh=P/TRTFNVIMdojDSgDr/B6FcyiyDRu4/UxmoQr5eq/JI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G2APndNkhF+7Cbi4hNCaRKrcZZnpnnKRyD+P6Kd1xncgafa1Vqtq1e621bxRTvlpy 7bWpJQ+0lRQVUTNcoc0xHeEC3i62H1u/Di6tzvOcBknSeqM2AUsAAQIEVNSPIUEFab DT7XQsOc06AMIVnv3IJsKfv7SFCoLvg2Ov2noxSGG0/xrnkynkPNWMNuCyUbjwUUl7 dsJQu3nzVC4G+jSW/IUYlhc+5kC/2nws8QnslUTGCXh1cT6qzIt4aNDRT4rDSyaJrz A7xP+s6ITlSLNgSc+vz9lpYZUrJHjBfJb+MBkCwjaQcRHrSm6rf4mFTCvDDjSXUw+l izK1+zL33Of4A== 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: Sun, 25 Jan 2026 23:45:24 +0100 Message-ID: <20260125224541.50226-18-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 160b3fcab209..1e4c3154b0a4 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -8,6 +8,7 @@ * */ #include +#include #include "sched.h" =20 enum hk_flags { @@ -144,6 +145,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 Sat Feb 7 11:51:59 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 A9C7830F53F; Sun, 25 Jan 2026 22:48:18 +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=1769381298; cv=none; b=mO/k4uwU3aqcZyaZgWCMgqOcYM3mnWLqOllNk0fwDSEQDVvCXcT6/RZfygf17Vyqy9/zB9jVjmxQInzXUT6oOFGZH1lUnWC7OeHwr3hY9mPwUnv1kSRx7QcilmvwFaFElKK7Givo2DgQV9F042hQgVY2nGFpUzAOlYcyBAiJ76g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381298; c=relaxed/simple; bh=PDoIYHuuiQUu4y1J8hgAkjDfFBft4fHDXLhrlxOrw90=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hIIJPN6ZzztEuZ9eQdIwdO5VHFwvorEhTEiQeLmmCxE5PEMYC2CE6GQrgZ5DqCbqpGekJIgqBwj8pJMPSJ30ZsV2vSFAsLVs4d2cLwzsK2bAtOWi622gywZqjf9x7NclyNSY4bv4Z7f2YgM0Vkf5FKVxIwideHs/wJIWbn8x+Uo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FXVJDGvG; 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="FXVJDGvG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E931C16AAE; Sun, 25 Jan 2026 22:48:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381298; bh=PDoIYHuuiQUu4y1J8hgAkjDfFBft4fHDXLhrlxOrw90=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FXVJDGvGd90ljUIRHA3Gq+xSNAPYbf5Of7csvzmr6nei4zcJ7mhopJ1z1alkU6Dfp l0WYTDe1bqdAbAwqxkXWftB2h/QrmGaK47ERIpLMpl/XGWMaVeG01EE3V1cO3TJGhS ycvJwK2yTD/h3Z7SN6aPzoayLR27DlQfuE/tsJutjBLeXZcEUkuJsyXWSUknHlc7ng /RWRUd8FUCncSiL1IgasD696UCodzN9XukraV+QyWa2mKQaYlHjfSGb22+eWrZBBZs piSO+onX1DUhkVV3zHKe6dKz2I61vJKBFw27FSgvAUZM0cDrmVaXHWYmGpF86sls9f xf7nNq6/T22aQ== 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: Sun, 25 Jan 2026 23:45:25 +0100 Message-ID: <20260125224541.50226-19-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 e146e1f34bf9..6309ec5d7b2a 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1482,15 +1482,12 @@ static void update_isolation_cpumasks(void) if (!isolated_cpus_updating) return; =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 1e4c3154b0a4..5bcb6d760f20 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 lockdep_assert_cpus_held(); =20 @@ -148,6 +149,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 Sat Feb 7 11:51:59 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 BB3402F3622; Sun, 25 Jan 2026 22:48:26 +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=1769381306; cv=none; b=FU8utDYklHTrN9gY+8k19xm05yyJyISxSorJ3gLFiPIfMqyz3Gqhp6g/wRpNCp820FtFuX8l3sAV8nqXWJsy98KE3ct4J7SFzvSiO/4aQwbLv26b2kxft1WozCeHA+IlJLDuXtUQ2GfEaWLuzLhvtVUVnxKEpZAKP3bJxAJFWvg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381306; c=relaxed/simple; bh=1KNWx87QTGRb7i2dGJVg+gYyletvaK/k+GQ/bIy3PfI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nO6rQf4+nocuTWF2sZ3FmXyAAtkc0Gp+jVZyzytjC5v2hcq0Zs3f65nKOfPr74lq4FqCvaSooAyDcoK8m5iI6gCypWB8ZNEImF2Y/nFuNplIqeNK1177ulJKCSe2d9g5MfVZ3QCEDXycApzPdhJeKdpKqdR+K6/yED+2WmKa8OA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WiokbWY+; 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="WiokbWY+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8D7DC19425; Sun, 25 Jan 2026 22:48:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381306; bh=1KNWx87QTGRb7i2dGJVg+gYyletvaK/k+GQ/bIy3PfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WiokbWY+u72D6ZGtYKo/OejDhCbcUqCRW/Ivk54y8e59YMvltE6LmCSSlZrvA8P3I 6533dVvqWDSARpKKhgZXSIH72E2CbBiqihh/IqGhW6IPa4I/961XuV77GnI9QSY3Tf wNow3A9qvtm2p7ZVWY4n8JyrVrgbRLGQklV+793Dg1WHR6Pc8W6pddLNM4lAOAeZ9m fLORz+IDKeCldynaM9+BMlVges/4tcKZn7jJxWhO501pASCEFErJHshoUU6sjNsv4i S2abbTLmRK73kWuAb2arxixwfUPO4O7J2fCOjEHn+OAleh3vPMqvugS5gwfJIcyM7y RP4+wnYr93doA== 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: Sun, 25 Jan 2026 23:45:26 +0100 Message-ID: <20260125224541.50226-20-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 6309ec5d7b2a..080fa2fb10c7 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1485,9 +1485,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 5bcb6d760f20..a30d19b641f7 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -149,9 +149,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 Sat Feb 7 11:51:59 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 CF7C92F362A; Sun, 25 Jan 2026 22:48:34 +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=1769381314; cv=none; b=d69r0w0zynyMz1LJCF9stQkqyoqb74P3mAsWglOXsaX6Jqml19Wcte7ZcsjVJ5Rrp7B53jpx1yko7KB46ZyvFUC4HoU1IGymyvG5uQKnHOrUXr14gUD6qndlH1hUxxoY7VIxQ1EiWBqRY6iZe0PFZl82PgPlKQXCDs2m8Nw6HAI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381314; c=relaxed/simple; bh=xcMcLXp9lSxfZhVrsREHiMXj3hvNw6ylCQ2N03wRKM0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rI+Y8KlxuHvYwQJU80SwKeXyGIKkmeqcteTAOmiedpUnzVdgGIBJAeWFuLrDRy0QrAeWyxGcPp6UvtpvMx3zpkB7tSpLknWWgKxDAHlJf8K5T+HyRkn3p6l1HYwScrb1Zu0RTYP7hak4dHhEn62urynnqycuRNMEPLP8/TjGiQY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QmeExAOs; 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="QmeExAOs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC069C2BC87; Sun, 25 Jan 2026 22:48:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381314; bh=xcMcLXp9lSxfZhVrsREHiMXj3hvNw6ylCQ2N03wRKM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QmeExAOsPNVoad+FjY6nF+vUq/CT43QF/yEuMh6eHWpIhuE6ZhsTyd5DgYVaFdhRA KSrOxbUrqW5spLkd02FS+St8WkGKBIm+v3PMxvJLp1CI21bHFT5B83sW9aoEvZd7EZ wLGM69jCyrsM0H58qDzzf0R8iRbdcsrDdiowQ99KVna6CUb5V2fJVSJxg5AUF6Qw9u FAWcSRhFRJXdqspv5nZhIU/oCRP5Wf0+b2FMOnlohs0YeAWa9QzyeMxmiuo5sfIrrr 3ETdzmebs0OLqjVcHCp0rHJFMPuaSujPyR7DCLDzl/Lv+WMKVs8eZVXX99M8M05ujn feLcLjAzWadHg== 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: Sun, 25 Jan 2026 23:45:27 +0100 Message-ID: <20260125224541.50226-21-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 4D393126BF7; Sun, 25 Jan 2026 22:48:43 +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=1769381323; cv=none; b=qEnNQDU9WyCP2vdD9NRAel1DQ0tZ+MT2SP2YbuwShHzY6Y0LkqHMB9iL80FvaGKAhbmQECiIXeJ+m7bQ7fH/Bg1XS/3xOdTI4vQtySU9JFnIFWQNpNR9skUTCO8bUTxwxKV05euZbC33f922JqcULhtpt1c//norHGwJ/YOeras= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381323; c=relaxed/simple; bh=WKTkyJ8jkqGGb+tOllqXp0QcpTGdBE5V0vkm6c4cf8Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=H+YYyGucIXWz76k7SzqLtknaFngFqvIxELZUi1d7ORwPJGcowNBHkSXwDEDQT5zyGpaw6yz5m/SaYXzy2B4aIWdmHN1ydjPnXIzR6mrKvJ7PJP5jI74wOCwuk2upfO0gSlI/DoM1tmIEabXKtCJ8+3IGIOwOHsviou6v0HKWgPI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TzUio1oM; 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="TzUio1oM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDB11C4CEF1; Sun, 25 Jan 2026 22:48:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381322; bh=WKTkyJ8jkqGGb+tOllqXp0QcpTGdBE5V0vkm6c4cf8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TzUio1oMCuWVOr/hvPqMiqsDEXur3veTOeSjzKH5SJhpSu5gLojrq6uxIO5tlclaO SiCD96gaiU92TkqXwpFUv3RRAkq4eBlkKX5uKBjCFDVi1cm1unbUjGTZ+9kU2Wfjtd KDrYmqsLx8C7XLXXkauZj37AwwS31nm+n/bRg9u/Nk4m76hFcKf37mLb6dmzjk7Ppl pmylxpjeNlfbUB5EOPOp5lXuGjklgvtZV0OO6PQX3kuNdvbY6qOY79Hk4O3YYJgzuJ mgm+qdkybu70yYD4RucYWWjlWCGeSlwRbZp4yhSr/eMyxELihqv92ku8xePYJ2JTss lNqziVulJBoxw== 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: Sun, 25 Jan 2026 23:45:28 +0100 Message-ID: <20260125224541.50226-22-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 080fa2fb10c7..801694de82a3 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -1488,17 +1487,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 Sat Feb 7 11:51:59 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 2280C30F53E; Sun, 25 Jan 2026 22:48:51 +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=1769381331; cv=none; b=E6J45m3C+6crnE8kU+GNT2RxecELB5mAeF5Nk3q2jSZ414a9I3Qbxwh+UTtT0Q+vun3Zvezt7pZdbBh/IXcAdR6LinVvP+O5Q38j5iufz/OOJ2QQymm3NFZDWoaIi3e3AWY/+kduk4ypEOck7o2IeZ6ySlPje5UY/HPLguHVwk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381331; c=relaxed/simple; bh=97q8vd09m+nJzodwGZsfdaDvcrqWHJSN7XyvoB2eWkE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VUATO/j/FXIZS6TUPsdFsHCCi3M471euwGQARcsB1lxyoUPbH5P6wiwk+pddvdSwCKPp8N6pCjyqZslyqGCXFT9Eqno6Ik001glgKe0S56akImLZcmOT+8nh+MMWZzlLmJcZz2Zql6GzwuEJdpoRVikL8OVrWNqQpX50NpGrmHs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iWzxMvwP; 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="iWzxMvwP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53A44C2BC87; Sun, 25 Jan 2026 22:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381331; bh=97q8vd09m+nJzodwGZsfdaDvcrqWHJSN7XyvoB2eWkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iWzxMvwPS1SK8km3fkUM3KgJIRikD7FClNxi0QRWA5JrZfgoAG74mwdpsj77nQw7W pS+cblqrXwGcEsssKQkPukfkT8uGiTsqgSu+22HsHe4DVh85FGH00kq2D7pa1DxYEH 3KYGi+/nHiOvpcakIiLZcJpmeXLgnPPfK6QTjgIuYcRznlaAEkzvcG1T9xHmLiE6gW VhoV0F6r3pRrttIteAXMq8adrmOLmzsmN152Dd46Ig++lgee4RGIOmvFVu6kyCJL7j sthW3q5UKNvsici9viFfBwMpf++h32gi9Utw5uqLE3nA9hfyEqCrVZLa3kB3gzWwBh u3g2L4UmLlXyg== 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: Sun, 25 Jan 2026 23:45:29 +0100 Message-ID: <20260125224541.50226-23-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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_DOMAIN should always be a subset of HK_TYPE_KERNEL_NOISE (of which HK_TYPE_TICK is only an alias). 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 Sat Feb 7 11:51:59 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 51F8B30FC23; Sun, 25 Jan 2026 22:48:59 +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=1769381339; cv=none; b=V0omqVqqxgY+cMCfq0+SHuyBnL5oIm6kFGIA49plugegGyMqwCgp0IS4SdFtlBmRfntkfKZZ5XTN8ktP/gFtbQCG0awKdV8ZcQSYs6mmAw47AFBI5jKk8LNUDYVfbY4hVqQcY7gkHjhlHi+6kmxC3R1I2XDPwodPBnz12GnaM7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381339; c=relaxed/simple; bh=WfH/BEHCO4tRBNYS6k1Vgh28uP7HnVhy+PmfS91LOJM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uMjGF1zWOARSy/PP3explZ3Y++DCMsgC7TabZQtd47wUZmPPQVJ3MJvCzR8omtPUyK3nqlc7wysFSemBMrMYwvOhW2rFfSk/ipaflJJC+5vVg2dDOCJMpzBmZwPLkxfWQ5ZJH2t2CXRYvO+peyaM2+891UZIe1GZSLyKCsCZGdY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dy+BYVqw; 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="dy+BYVqw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CCC0C2BC87; Sun, 25 Jan 2026 22:48:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381339; bh=WfH/BEHCO4tRBNYS6k1Vgh28uP7HnVhy+PmfS91LOJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dy+BYVqw0O1s3QzEYM4MR0fWTzp73RlR0LyB9A3qFhaAGl2AjZYyLqdayLPZ6+ZpB +OCmoXmLP8MVpzqAZut5Agy8D+dQV7n3FDSaTLgi41yvwbAuihWDqvu9bRdBTYPodi wiPuYBJa/anYV7B+xDhqeA4MNx8kYCoLeeHbIc2DwSDEXKhk9Z+7h9K6Fx3iviWf9r cD0SQWzB0cMMDrQkjo/GFn6+VWjy6wDJzQDrdIqBOKGXoeLHTcGqCIl6B1Jyir8IKN XfwCqNrf2mTF7oMnVsNUtcv1OIFle98VrKLDs6/Jv+T4vuauRvPtbeqHamJTLYtmZG 7dk23P8wx9dWQ== 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: Sun, 25 Jan 2026 23:45:30 +0100 Message-ID: <20260125224541.50226-24-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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_DOMAIN should always be a subset of HK_TYPE_KERNEL_NOISE (of which HK_TYPE_WQ is only an alias). 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 Sat Feb 7 11:51:59 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 00B4A23E32B; Sun, 25 Jan 2026 22:49:07 +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=1769381348; cv=none; b=uOFThIv4WcRF7JAej9u7DIgBoZoAy/o/Da4Qonz6HYo1/s0K1IXknkBDdxBRoBcwxQurT2RH/TmtgAoYvvFQM1NmNjmuXSz+rx1rE8+ncQt2QV6toOQ+uZSed4s5gpABC3INwuFwxafWAlyIWQO+AxB4FjoWye2Cq1+fSTt6za4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381348; c=relaxed/simple; bh=9wXcGCZqYAJGFwoghpjYmoH+2WL5WXQJ0azxL3BmHRY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PgPZ3I1wJGeqyKT1AeqNi+YSedTFhs7sPuvpPBFCPnEwPHB4fw/5KS3g0M0wjs2pgHG8B5so6QFoWbHGk0t4jrw8fGsG6it27/jV9Eb8BlZj9a205vl0fEnnnQS6ehbtKHyJilWLd8ztEs9CGQK6oOLsIDQ2fP+Lq+fkDyzZtzw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cQouXDHb; 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="cQouXDHb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9561C2BC86; Sun, 25 Jan 2026 22:48:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381347; bh=9wXcGCZqYAJGFwoghpjYmoH+2WL5WXQJ0azxL3BmHRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cQouXDHboX2piB9wKNa/rwB+1F8SE/r3ji8PH2PfYH+Ao9MzAGQkY75UpLFHDMnzX LU3p6BhhfDe5PRwyQs0ilEtyiExo1MxmhHXrWDm1yM1a+rBpQGGWW8IDZ/5WG+ppbJ GUGs13jkP/5BZozejUS8/83/9Q7ctbohhB0rZcTDdkfDQSDBgUwCERxUPpOoySLZmv dQZzqTBKEAiaC9Aoew9VslxlGUKZpc/Ikdw/1bVZZ8Yym0cbtFhFh1fm++2z3FKcPy HMGXY6hMpoxGfgGHnh61TDuP3lkTJ84dHJmT6QzFjgotcCPgCnYhnlfh26DqeebYYC aeD0u+uricWXw== 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: Sun, 25 Jan 2026 23:45:31 +0100 Message-ID: <20260125224541.50226-25-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 176C92F3622; Sun, 25 Jan 2026 22:49:15 +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=1769381356; cv=none; b=OMBx8omxEIfVH3q6wUzs65Bc3vnV2HETm0biXqpqFxSp//KSML9EiLOYMW5EQ+ZIdVFOqZMlfEQHZJhTLFuzMhyJo6wkRpHT+f49LH2rYZg2B+BwDBLR5yUKBCWfYh6QYdAWSOdzm6Ki/zzwnQEgA0RZSn9aDXVmr8GXUixxowQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381356; c=relaxed/simple; bh=FQiUYX134QuRdMK2UHqgCPVDFLi7Mj4zGAJtAEtu0Bs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VLID/FnuEhWbexYSvAKYtEpUayh9fwrjZuk1IHBcig0iPNvOOIJ0/QIq3PdPcICQTvTQRQZPEa9OrXlLRQ7zyq2539p84TXpZ9iQRLbFNo6Ni3M0YuIStXESvQ5MJH0sbKGSrN6WIMULI6ZNWHNPNXFIMUD7m13R+mQ3BZCTdZ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UgViSQhG; 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="UgViSQhG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1ECDC2BC87; Sun, 25 Jan 2026 22:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381355; bh=FQiUYX134QuRdMK2UHqgCPVDFLi7Mj4zGAJtAEtu0Bs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UgViSQhGT3Wuke/Yit+vSr4vsPQsGUB9TksMilPkbw8ucPH88dnfcU8EQRgMLb06e lN2gyJnxemaInoGQz3B75xDql7Evl1TQQ4zZmMsXAnbD1Urr7NwOnt6wOnaYCOQeeQ sgfXCryqqyMrpzQwx8K3coFYao2XKspATR/APoqQUbITIoNDoEi47ehdm2MK1mENnZ ywxEht8+8pss3W8QMkb/rQLYybf1dBhLQUt9LxeRxUkMJZvTICvHfAVqI24kffYkw6 adk3FM+FdCMT9PgkO4j8TJQKImvmwOStO+j50JTiTr4NKwPRgOc7x/stxI36amWxYC ikhAsOpNxxM2A== 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: Sun, 25 Jan 2026 23:45:32 +0100 Message-ID: <20260125224541.50226-26-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 D9AAA3101B6; Sun, 25 Jan 2026 22:49:23 +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=1769381363; cv=none; b=HBtTn94TAqjwcj8mP64g7lHpaJ1b9OQPrYQQ0AHAjqO0I8WYResvMl+QjwE7XUS+QB5B9hBCrzgz1gnEfIh43ZraGwnv69iGUn6Wtscyrq2+v2qhhpZeJXgumAj6uZnokGhp0zwNTM9MqCtPJyBwHxABvrxE794swY5THFhKit8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381363; c=relaxed/simple; bh=FTfdEWcmOb6DfQTJTbI0bpXWltHwgECxQBbZ31X7mYQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f+0+CRCN5tMPboRP1M1Da8B6LZEZOoNb44Cq0td6GNcK4+JGMvwDi0Sr7XDS9oioL1kxzB93tIcQ2LVsDKRMNQ+urFaBKXeuNC8pEipWj2ihCxtFqv6nOyG14J4cwR8jE4SXronuPnqlRA1t9lbPOsQ5Hwonb783a3GFfKkyDOo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XMcxUM+y; 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="XMcxUM+y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3246DC4CEF1; Sun, 25 Jan 2026 22:49:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381363; bh=FTfdEWcmOb6DfQTJTbI0bpXWltHwgECxQBbZ31X7mYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XMcxUM+y8zwl/B5ZM6qLijBt8PpVzUJS0ExIUBKq3Pr+17yI5eqE/DCk5K6IogDpS Ab5JmBSmKO/xfwevciVu/DgjXNBby/p8gmQt/uKmdvW8Ancmg5iqtWzVB3zrIfw5pE YFZKtfsQXGdGrjJwts8JwDPOPuFQayB7+WXHoA7HGXODt67y9xqFHadzm2HhPXJfXs uVGbVjNmEJhJLkM5BHC96duZkXOf3U67tMM4mhZmATXQzZtn5gV899YzmyEo+5j9vC ZagSay65D2aX5KHjsbzu6IqSMfxRclXF+CE/uLzvxe/xC2rRaTuY06nyCNG9DDAkTY UBg8IBX+vc7VQ== 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: Sun, 25 Jan 2026 23:45:33 +0100 Message-ID: <20260125224541.50226-27-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 252FD30DD1A; Sun, 25 Jan 2026 22:49:31 +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=1769381372; cv=none; b=m5HK+TqyerT9nLShjRG75GShpvqQrzIIQ2g4V7v/SaXZkGp+UAMhCx0Xo6Hl1bxcj7qF76FfIe3+mZ1VeEYZFsdruUn8P7HEgQPFZbXDyh+k5A3lje3TWXL9+pJaKR5BvdhFEiA7UrQNPFlbO/xdvVMxhjX1JrtBDskRF/2bZAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381372; c=relaxed/simple; bh=OKxr66AuTYpmtINGeWatnOeeLWTfC6xUU/wfI1fZOeA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hSe8p2pVYN+Sn/mzuuMn7YrrhNSMSMqZ641Dju7XnsH+58W0kR23lg6dUsYXBkLD7xsNHqzjJnMFbCYPA/Qpn7tnCgEtYSP3ai0ncWhq3Jd2KH6XlMOCzchmSK+2lMg1xZ4LOtARLSE89KzW0Q5hZhx/rUQRbMd7YdaL90Xt/As= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=d70jxwgb; 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="d70jxwgb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 305D3C4AF09; Sun, 25 Jan 2026 22:49:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381371; bh=OKxr66AuTYpmtINGeWatnOeeLWTfC6xUU/wfI1fZOeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d70jxwgbF/CNKBtHpaDvSsHZFYSPWkBvVnaAo4Av7c4PHeWTyYMkUFCWk1jjxGKNg ixqOpT8qvOYKSjtsZSCMAxfq7drEFvjvij9M7sOtf0wWj+Pkq1eQNV9zAPnH2LLJ46 U6kk8bKaPMuJWDxKBXAF79yPSO65UoKLNwQx9uXrJSiRc7H0bx78/0545kNWuHswIp S4GznnYh2O52k0q8L/eji+euYnCkrI0H2+gU/UbY7iY7yHVhxStXJ4Nf3l8V8yA0hF ZIkhMGFhYHD8fmUu1Q2R3M0YoaEAcVq1tLFbqt3BP9IobTzV3xnL9TVhgs2t81yeWW nwPYM711OQw3w== 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: Sun, 25 Jan 2026 23:45:34 +0100 Message-ID: <20260125224541.50226-28-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 99AC330DD1A; Sun, 25 Jan 2026 22:49:40 +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=1769381380; cv=none; b=qnSzJoSxET4RX2mFm2ndxwI+d0lDKEQj5Q98wJ+pVAaKuIowG0BmBU2VQZiKCfk1u2unAQnHl5O8NztfXaIcD/z0WHKkehVzqYC8g9+dr7kFaLjp/TZFJ6Q35k1SyEVJQm61pmyIpDKvcOtPxsNrEqDSJtNWYICewrSHMNPSoLg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381380; c=relaxed/simple; bh=txAoH54KyHKbuey5FYwPXMe7a123Tyjq6wOFllqOg9U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p8Na8v2E3BpOjSyNJLC9Y+X6xhGntINCKR6+c9ZHSZHz9IWhuNDRyh0NESfAk4zGXfn5Pce/ZoEqHBpwmB/t5AhFF1yz2Ax8H+2c8MFM69EOHSYatIjSDwLeLrZweRFVXjuOJIPFeof3ZiGTSKkAzVR/3mGXlu8Gbo7RQ5P0ARE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ct+/Hpif; 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="ct+/Hpif" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3229EC4CEF1; Sun, 25 Jan 2026 22:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381380; bh=txAoH54KyHKbuey5FYwPXMe7a123Tyjq6wOFllqOg9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ct+/Hpif4Fc82u2iven2KRFCFhW56c3/+0FaStQzwSlTMN2Gippl3VCDYfCTDGlsH grRUbkAjXxFz8QNUB32ATVc6ffl7ouZv2PQIqbvN0EmXZclBnjEpbADbXDw8OYIS6i RYSxBDD9lok+I+KvwO2sO129c1HXWc4DfBbJmfGbA7lLTnLjszzo8qkICZAnGRGmF7 SmjCO4HNh4E+cJw7qaQN1zg4efuWoM6ocDBuEXWoktF2g9cEtNKKAozJwfn+fhoVY0 zUgi+HoSWTvagYHbpkikZfHRj1znB0oDpDKy9Bc2PDCxrGkPfYZQsaq7Fpj4bCfnKa ds8venZCqWWkQ== 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: Sun, 25 Jan 2026 23:45:35 +0100 Message-ID: <20260125224541.50226-29-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 1EC1F30FF1C; Sun, 25 Jan 2026 22:49:48 +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=1769381389; cv=none; b=qeCf9MpnqpTUBDzWMDWkJBkrFePVwyFdwPbWQ75aRPKNtipNMCwBYxa/Sxyd7EDyRDAsi886Xf/Sln/MQDgYqq6gpCohawPWq9k5xVzBBWGU6oFiwlb01j2INqmLwTBFCZJRxcs6yVNhzU7B8Fp6RIRiAphn8tCJ1VyjphYorZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381389; c=relaxed/simple; bh=8YH3jJJ1l+zWkUBN7W5HQtnoatv1adfZkeKPi8o8s7E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MRRnVGD8/s8oE4Z7PkRsV1wEXq72CWVMFD9NPsQthJCotl1EqWPsn73ZNkC5HSZF2hELUK7vnQAk5QVHYBd9cLjjr3QpQW66uJQLPR0ep5N7swnkJWxFBqnJ7wLLvrNGlb3y1f8mbDfyaUpakjF1WTiDt4kniqyYkr8YYAnSXFs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Xh9qasXM; 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="Xh9qasXM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F034C19425; Sun, 25 Jan 2026 22:49:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381388; bh=8YH3jJJ1l+zWkUBN7W5HQtnoatv1adfZkeKPi8o8s7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xh9qasXMZUMlZAvDOzubOT1QTX8nu9zdOSq/aG5SytkYO8dDUbUHJYFhPOhMIbOoc shv9P8Bht3wB1y2r2jVGvZJv0HRG80ck2wtcmqKvSpyaFC/xFWa1YeBCz4KK/9ivCR hYkK+Dyczy4RyH0t8DqAhfix9gdqot+5+jz0nhKl5oWWR6gbyqD0RRWpWeslUSffQg 5ffYgiOyzrLcj7I2oZeUcUBGC28h6CqUynsHVapP6lqi9yhKrLlwD6ZJaiFeb/Dw6q li4SD3zXYvOkkw7bhKz4ZGmz1nuunbm6XlRzlwkUldb6lKhtWEGk/kgzKSmleS680L XVtpddRKIJWYQ== 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: Sun, 25 Jan 2026 23:45:36 +0100 Message-ID: <20260125224541.50226-30-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 subset 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. Note that cpuset isolated partitions are not supported on those systems and may result in undefined behaviour. Signed-off-by: Frederic Weisbecker Reviewed-by: Waiman Long Acked-by: Will Deacon Tested-by: Will Deacon --- Documentation/arch/arm64/asymmetric-32bit.rst | 12 ++++++++---- arch/arm64/kernel/cpufeature.c | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Documentation/arch/arm64/asymmetric-32bit.rst b/Documentation/= arch/arm64/asymmetric-32bit.rst index 57b8d7476f71..fc0c350c5e00 100644 --- a/Documentation/arch/arm64/asymmetric-32bit.rst +++ b/Documentation/arch/arm64/asymmetric-32bit.rst @@ -154,10 +154,14 @@ mode will return to host userspace with an ``exit_rea= son`` of ``KVM_EXIT_FAIL_ENTRY`` and will remain non-runnable until successfully re-initialised by a subsequent ``KVM_ARM_VCPU_INIT`` operation. =20 -NOHZ FULL ---------- +SCHEDULER DOMAIN ISOLATION +-------------------------- =20 -To avoid perturbing an adaptive-ticks CPU (specified using -``nohz_full=3D``) when a 32-bit task is forcefully migrated, these CPUs +To avoid perturbing a boot-defined domain isolated CPU (specified using +``isolcpus=3D[domain]``) when a 32-bit task is forcefully migrated, these = CPUs are treated as 64-bit-only when support for asymmetric 32-bit systems is enabled. + +However as opposed to boot-defined domain isolation, runtime-defined domain +isolation using cpuset isolated partition is not advised on asymmetric +32-bit systems and will result in undefined behaviour. diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index c840a93b9ef9..f0e66cb27d17 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1669,7 +1669,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 +3987,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; } --=20 2.51.1 From nobody Sat Feb 7 11:51:59 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 1D17E30F53E; Sun, 25 Jan 2026 22:49:57 +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=1769381397; cv=none; b=CdLXb9S9/YU4ZiFAT2ekeHiSzbSl4nhirezg+y+Ertsj3qmXYJRbjXzlBBeG5HZnDw44TPumtAEpd5os/V3oYWrKZQd3HKlmm6BGm5X648AaUzhRH1uOO1b0yx0d/U+k0xGOJqktYA641Uwcu1sXWT10MpbyyxcyV/pow2vfK6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381397; c=relaxed/simple; bh=h4+1N6+onxTB3qHJHE3W5TiIbyuzvrEMpQNEnSESUL8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IVulAAE2W1uDJbrTDxtItWzOYgBBq/Ve+a/f2WeCIKD4iLk1OXbA3RPPsx3N66ffvi1UiQ5zOHERSjZiRyGblOfMqH+vCrL5pYQK4Vxi0uc4NIZ0mKKKBodkwTfiIyYBJv6VZ7Zkn8u37do1mZO/FtshqAheg50C8zlK9eOW7J4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kvQ5Lnyz; 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="kvQ5Lnyz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 128EFC4CEF1; Sun, 25 Jan 2026 22:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381397; bh=h4+1N6+onxTB3qHJHE3W5TiIbyuzvrEMpQNEnSESUL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kvQ5LnyzA+O6y4LUBWv/7wEJYWp46+ofYDM2EyONjVw1AIkqi6EB56+Oel9II/NLK HHdKlb4PyDtYcmib4xuM5xdF8Af8P0DlSMiEcAtKW0KelHaT8vmw0qLVWbA9m+qoC7 tG+aNiq5gxL88NVCMk2hmDNjRsFYl9HKjZpsEdD9TsnHiXRrNFZD8zxXUssjMNHmqj 7i0PUx4Oyef4qEgji6Ns+v0gCbdZvVdcOaAqMJiNUHJpSKToUf0pDY3aXKvlxVkClJ 9/HGLvRC+cBbT8Fbyi27zOmB3eoGNswFV7aOlH4M+1RfBOxBANuYTERwWSSzl1GjLP jt/8h7dy5BLBw== 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: Sun, 25 Jan 2026 23:45:37 +0100 Message-ID: <20260125224541.50226-31-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 801694de82a3..9a8292b7c7f1 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 a30d19b641f7..3b725d39c06e 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -156,6 +156,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 Sat Feb 7 11:51:59 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 073DB30E0F9; Sun, 25 Jan 2026 22:50:04 +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=1769381405; cv=none; b=V3AsQEiDprMfGA5R+/ele561K6WO76229n098C5ajrqDoyFDP4mnnkw+JfKF28mlUMooprUrW5YHnzGdZTATnjQXeu4MnIuNVKwwnzl4Ha5vuKPtCmkz/gMbc9rBm4oOcLM2ymrRNZcGjOWSueaJ7/PHZJeU9fwij05V9haxIz4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381405; c=relaxed/simple; bh=cybpUb9IFSrtSEn6CVNh90w6y5FCshbAQhcAn4rc9bQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XwQdKl/jIxMS42kc6VmbIYRMN0xOt9CfmJaeC3CX2fyKi1x8qGjwGFywTmCTV+6qcOpqpQcy1qi6WjNM5xrPhcvH2jxKKhjCv4f3h3SIR49BHntjUUGYf0KJzToKT1tO3tyrxSFgfLvP5/neO/tGNRNsKNANARa0wQyo1adYc8E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=szmnbFCF; 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="szmnbFCF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6663EC4CEF1; Sun, 25 Jan 2026 22:49:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381404; bh=cybpUb9IFSrtSEn6CVNh90w6y5FCshbAQhcAn4rc9bQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=szmnbFCF+vyRguPs+qTjhgn0jgwAxnTgIPrBfdW/GdN/D7mcBxVuZHNNiCj3DokE+ 8u2aqDutKHZoWAe9XmC3IYWWqKSGUc/71rTf+st24SadAtLG/5tVE/jHMtduy4FUkz SUAJb8ld4SDph1t42LM8gIYOi58uwgPrAnn5YD3a1P8uxg9qB72/8ZQGGOIi74olWd CFCrf6sohYmd90ny+Aju0E7DCjeBioTCp58AJPJYv8B1r5e24LmqFQ57VDbkaj4U1B ROdap0VewRCNie09oE4Flv5Uo1LqjdEi7bFQzZQH0fJGsTjtkrDTq829RCaRtYO8AD d3bzLzh17qang== 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: Sun, 25 Jan 2026 23:45:38 +0100 Message-ID: <20260125224541.50226-32-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 2FB2031AAAF; Sun, 25 Jan 2026 22:50:13 +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=1769381413; cv=none; b=f7jvC0njbL55NMulb0JwPqVsxs9jCu/N9kuZqVipa6TwajtLGYFqXBhd21TcRhy38BIMkQWXEZlOPhM92U/PGDtHoTCKd+IMr4N/g+Z2zy1u3yPGh8ufRUithdrnIzvDtcDwQQdPgRm3DoE/W+XM9S8WweSjX9oktBG3jlSRpDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381413; c=relaxed/simple; bh=kluxsGzh3yUyBuEdMQW2ChyzrN9Wa4B73tu4Iho0QMM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZyeSOy4UENBWOOuzBVMyG6CkP/i9d0hjN+0cPzfsMeAaHvbM7/DQ5IAbICvFTsE0TnSBtSv66MXnDBNqdg2vJeX9eVg3/83CqjqMNvMIyNECxuvR4OK61gI3UinmHQ5P+F5uMdzQtIxcvRSY1qFxJza08PCOoYbkgSzo/4RSc4E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PwIC4g98; 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="PwIC4g98" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 120E4C19425; Sun, 25 Jan 2026 22:50:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381413; bh=kluxsGzh3yUyBuEdMQW2ChyzrN9Wa4B73tu4Iho0QMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PwIC4g988r+B+FQPa2FGhJt4tSrnNd2nr3Tz4JrNby9d+xw96kD0fCjntTLY1+H1n uXxDNbXKSPe2PPZHG2MkM8KfxPUVZcHV22WrAGuzzmO872gdpB+rEYMVaPF9zDiHeA 4DAVOo0ZX1apu66trrhs8xQp/0u1Hpi6J1VWvFy9lMGJMwfhvoSf3REVbWUSMv1fy3 w9NNX6yNDqcaFM+CfcvB1OrCkCSjmfni8NhXoeV3iRN0cEMtFRoxEHfQHvq7WzyJd8 2Ta3I7sXvWD+IW/l3nN7TVys5aR+iJcCHXKGctB2PGpo2OIwb6AJNGfhBRwGPUwOXV m2Z/opj23gBYw== 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: Sun, 25 Jan 2026 23:45:39 +0100 Message-ID: <20260125224541.50226-33-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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 Sat Feb 7 11:51:59 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 461AE31195C; Sun, 25 Jan 2026 22:50:21 +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=1769381421; cv=none; b=P6LzzLpJaxISPc8th48b61ZaV61CNJ0ZBexvVIyfWEFX4vaz1How2Q8BG+LOpddzrixnewXk6WSEGah4HX6CmWxCc1XrU+zdSOmhDZhp1wj4t/hvHFsi3w0cXZKMlWKh+a4GIUkg3agG1gx5DP1+XG7wqhSx+xboXRqU8iuvql8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769381421; c=relaxed/simple; bh=soOg+pSguRYShDvlBT6z+CExBTh9mpEwKqBDpU+MvVA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r211aD/MjNFJP/I/vC720IJbw7NyF9nmniDbdW+3xKNC7OzssMzM5lqxhiOv4ge/1rfVjO641tmfgMWwFBRj7I4QdGVaIFfup2+c7DLC4Yqj2eUBMjMkQwjPlGdw9OHPoBTdV7ojuqwpfvr/3xlkpvPcrvuzzLas5IZBCIm8duM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O9eNU6FB; 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="O9eNU6FB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63F9BC16AAE; Sun, 25 Jan 2026 22:50:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769381420; bh=soOg+pSguRYShDvlBT6z+CExBTh9mpEwKqBDpU+MvVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O9eNU6FBgsG9hyVi/+uWzwzBcb3jcShb7uOmQsjIIjUrQdwd6h2E2hlOYXFcXB/ql qdKPPIOMoMFnsXK4JR327RdmvVp12tzAKc3mdCuECy36dJ+ULwoOd7XxIR96MFfnRS Tf/BhWFSthB4dknZzQT+VDMKWaiGk1piYc4/1SvoEyWQPVWOMbGzCOX50wyM0HhBgo zQY6jjB6xI7BeQI9xaby26nk/VdbQlcrksM8alFh3VGgf4VPNgHrdrPRTG1yHtNs6B LJOghmDwx1hiHEaoiXnunqOam5DBew91Q1zeucjxGqoQn4ndm/rwNY/R4fMGcCaLal ZHqk/ey3wxMIw== 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: Sun, 25 Jan 2026 23:45:40 +0100 Message-ID: <20260125224541.50226-34-frederic@kernel.org> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20260125224541.50226-1-frederic@kernel.org> References: <20260125224541.50226-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