From nobody Fri Oct 3 15:37:02 2025 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 D9D9732C31A for ; Fri, 29 Aug 2025 15:49:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756482560; cv=none; b=CAhUcU/yUtBCjwn7uf7QLFdA3cAdfkTMZD85rcBqkSCpaOlERqYwgSANjQUuiOCTi7vyg4jxa8wD5tUZAbatCzAuUPXSVU9JV7u+tcyL/ov7w2a/5U/0fQSsWU57Fh6Frg1858Fa1euCWPT20GIumz6f+FnOahD96r+6ZK3CCPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756482560; c=relaxed/simple; bh=msWuzDTcgxqxV1VfqrsWjNwgWbBhxXt72Fo9MOZeVHU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i9hY419EVytQ5ajSnB4nLG4+PLuKDGhd0ItV7cQW/1+rA0oLCer1R2ukA2iDYOdioXRkoW+AaGsBRR+KLCF8gddEe3VyEP4x/29VMg3ReE8hVEoCDZ3fi4Gqzmtw2Fj82zvi6DmgHaFvIKJh0bWd3aJaJxw8TAPJeiFztZT5Jm4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hHSzD4Dn; 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="hHSzD4Dn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A529FC4CEF0; Fri, 29 Aug 2025 15:49:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756482560; bh=msWuzDTcgxqxV1VfqrsWjNwgWbBhxXt72Fo9MOZeVHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hHSzD4Dn4qZ4WYPHCYqnZqAtyCr8q+4g24/jaS6Vl3q0CE/FcoT3rB+yYcK3dzCac rr30Mt0hR137cIcYylb8/M8hTBOOMBlo4wNlnap4RdTZEZSH+rr+03DklbnyjMu7PJ moa31JgA2121K1Fv8Q5rFS9uphda4zpOOpSlWNmrcns211gtwu201PnL8A7x28kHZ7 k2uxj+D9oqUR96HiNS7E3nHzPUlJDvWQJJE4AdY/dtcz6avDksIHxl7wM+DdfMqphO DlcHy2XEGSqYWHiiqIo06P4F7117/Kl5cWHlPm7MqdlT5LHMNzz3e3/Wuoy+s+RuGu UK59VYvQjTfHA== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Marco Crivellari , Michal Hocko , Peter Zijlstra , Tejun Heo , Thomas Gleixner , Vlastimil Babka , Waiman Long Subject: [PATCH 21/33] kthread: Refine naming of affinity related fields Date: Fri, 29 Aug 2025 17:48:02 +0200 Message-ID: <20250829154814.47015-22-frederic@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250829154814.47015-1-frederic@kernel.org> References: <20250829154814.47015-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 --- kernel/kthread.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/kernel/kthread.c b/kernel/kthread.c index 31b072e8d427..c4dd967e9e9c 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); } @@ -876,10 +876,10 @@ 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 /* It's safe because the task is inactive. */ @@ -887,7 +887,7 @@ int kthread_affine_preferred(struct task_struct *p, con= st struct cpumask *mask) do_set_cpus_allowed(p, affinity); raw_spin_unlock_irqrestore(&p->pi_lock, flags); =20 - mutex_unlock(&kthreads_hotplug_lock); + mutex_unlock(&kthread_affinity_lock); out: free_cpumask_var(affinity); =20 @@ -908,9 +908,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)) @@ -918,7 +918,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.0