From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 70628219FC for ; Fri, 26 Dec 2025 21:37:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766785061; cv=none; b=jFCABpeTzmuWjqJudJoA66qB4CdyhV3UY+ms+ZSJwu9GLpYJm3ZgTz4ZQOu4wnIHX9F2aJvSJW4Oraj1bm9JzLjia7UjQ0hnM4X6uX+IsNheneF0qGFLIp4uTAxEaxqL3NOGpx/W1Q6TmIpz25ibGFdoUrXxEK+TUjGH3mP3v8I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766785061; c=relaxed/simple; bh=X+mEgsNRkXIT4lMXTBvZoqKWijU0MQoRTGT0mUCNFi4=; h=From:Message-ID:Date:MIME-Version:Subject:To:Cc:References: In-Reply-To:Content-Type; b=WiLrM1CA894BVwhWvuzfjaOEXq4pWy0m5YxsTZFwouMXru2QOvalQgTrXqqFpNeBDEQoPup0DRHRQj9z7vIVqJC5SvpyTFZ5QL0illuwzf5s88jkrz2oDmOKbfByX0wSj8mdWy4+ZpzHvB/T2NpHfyuFG2qurBxHMVTsWjoXA9c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=My1Mx4Xt; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=bAkWmCra; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="My1Mx4Xt"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="bAkWmCra" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766785058; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=asBMqPMMlBYgauRrbMzCES/5E7Ini+6B8CJ6RNaEzp0=; b=My1Mx4Xtk+XD1ZIYtOKdpgUl82RTW3LP7ChK3Cq973arZcbQw5zJKP3lT7dbZYIINAXhgl N3AHiu8PGVIkn9hp0F/mDE2qcz/csh5B7pmdWdCqo4/7xxzsBp0ABHSZBcroj2BI3TfdDS h/fwHu5Eo3WxcR8bnKZkMnlO7xg4Ke4= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-331-s8WGayTdP1CzZZ6RjKHlqw-1; Fri, 26 Dec 2025 16:37:37 -0500 X-MC-Unique: s8WGayTdP1CzZZ6RjKHlqw-1 X-Mimecast-MFC-AGG-ID: s8WGayTdP1CzZZ6RjKHlqw_1766785057 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-8888a6cb328so192079006d6.0 for ; Fri, 26 Dec 2025 13:37:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1766785057; x=1767389857; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:from:to :cc:subject:date:message-id:reply-to; bh=asBMqPMMlBYgauRrbMzCES/5E7Ini+6B8CJ6RNaEzp0=; b=bAkWmCraMlcyr8+zppyAcC7lcIsamdF3Y8M2E1CqbMwz0EQsJUweGErLixi7chn3EO sUMlrqI1F4/e0/7pMYrF8yBEm1HMBkFrirSUT7oxVhBwWzzESXxhylJCgVccpFNyFyGx jTK747AAFFvLTtP5drSmSSts2a/DCZbJNKcBkpHSxKKiix8ya/VWE/HWJRMLx+1Ff3Nt 2YCa/ckbNbiZndFaoAzHHiDcdnV5Ng+Z4Xi/t+YSzPStA8vfMD1aCOTsI7n02XEHmmdJ mPO3uxVCPxrKGpHqO+/wWr+0MAQHWAhHxVW8x5AcQBD4A7a26OgdZiFLsYe3PpFAi2ts NLsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766785057; x=1767389857; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=asBMqPMMlBYgauRrbMzCES/5E7Ini+6B8CJ6RNaEzp0=; b=llcIIYWSexgTXXxg9kZDR7gUpeJRD8tj1JPHaKka+rpc8vDbCJERP6F2TAZi8tVl+h gbe8ca2oId6TbsL2K7b8IxdFwE9++opFK1SNVICHhnVFO7YraOgDJ6JHBjCjnToK88Us kwukA59NlPz4vJn4N4FRxWxdulhmWF62WLbouJSIBDTZgmZyKbcE66ImrYrHSuR7tKQi H3d78dhdUnTsfZNgpfs8hk6dlYoRj4Udf6SWqXaxX9QbxRTNofWeMtVh8mp1UPprhuV4 YMbmCsYD+tUO6GHBBQJPIdvSkmuq0Q+7UqijYGxcM1EE1qMk9dFBHuYESUmWdGHjYQjt B2ZQ== X-Forwarded-Encrypted: i=1; AJvYcCW1pKaoYxs9BtpVuGmWc1KtAUkxjVhQvIyoFid2/VHPn+d3IHpd7kAQo+1GZ/ojsjB18Hv+qR4j@vger.kernel.org X-Gm-Message-State: AOJu0YwG95zeeL6K7RZhFam0yq3T68gQLoA0PWdOOpHJFLmGe7Bd84f9 PWynHPq9UQ1ivTTLrRr6MW6mjVRfnO21XEOEABaTL2/qdefaEfguH4/ginPYcQ4wBy5INnW7Ohd vUCuAu99hsV41MbDBuHTa8y5vGdhEe/jbYxHBf+qWwTmMXtCcPDE/zHXKZ8Q= X-Gm-Gg: AY/fxX5tuOaRV45ZUkzWuWvz/zzET7QCplTFmp8AauDp5iVbRjOIfXYjsLVmfvWc2ri l0hBRTTUjow5wWbd6a0YuW9PL4nbwrvqUwVjsBR8RI/lYfJWtL9Y4Y2EUZ5V8pPfVOncQcj1Vq2 LPVHTCh/S/IonaDp6/OlYDH0rvpqIuEGX/B+um9T3vRWA6uH2wvE6fZouKLz83mGw0ADooZ4Paz 5mnDFsOkmmyBmls011TZbQEoAiEgs7VUFl77q14TTQ6GGARbWi5sJUoRFReyH6vkwtsyr8KgRL2 RrKUW35923YwSmvah8jsXwpMiqgH0D6DQsck4z59hbpy4hKjZLjOqoxlW0iev8QFiKg+OJBpHTt o+vs1YjHLknmfbMBL6Xp/0BPexbNosgU/4I1rgdsjthzZN0DG11jy2iRd X-Received: by 2002:a05:6214:1ccf:b0:786:8f81:42f with SMTP id 6a1803df08f44-88d8369eac6mr381481926d6.39.1766785056788; Fri, 26 Dec 2025 13:37:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/UszSTKNZq6JUtpfA708/ibPfYyEh5wUQDx/+llWKoJlmPrhzPZqD/XUz+CjETOu+z3XbwQ== X-Received: by 2002:a05:6214:1ccf:b0:786:8f81:42f with SMTP id 6a1803df08f44-88d8369eac6mr381481746d6.39.1766785056354; Fri, 26 Dec 2025 13:37:36 -0800 (PST) Received: from ?IPV6:2601:600:947f:f020:85dc:d2b2:c5ee:e3c4? ([2601:600:947f:f020:85dc:d2b2:c5ee:e3c4]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-88d9680c323sm170712766d6.13.2025.12.26.13.37.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Dec 2025 13:37:35 -0800 (PST) From: Waiman Long X-Google-Original-From: Waiman Long Message-ID: Date: Fri, 26 Dec 2025 16:37:31 -0500 Precedence: bulk X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 24/33] kthread: Refine naming of affinity related fields To: Frederic Weisbecker , LKML Cc: =?UTF-8?Q?Michal_Koutn=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 , 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 References: <20251224134520.33231-1-frederic@kernel.org> <20251224134520.33231-25-frederic@kernel.org> Content-Language: en-US In-Reply-To: <20251224134520.33231-25-frederic@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/24/25 8:45 AM, Frederic Weisbecker wrote: > 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 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; > > -static LIST_HEAD(kthreads_hotplug); > -static DEFINE_MUTEX(kthreads_hotplug_lock); > +static LIST_HEAD(kthread_affinity_list); > +static DEFINE_MUTEX(kthread_affinity_lock); > > 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; > }; > > @@ -128,7 +128,7 @@ bool set_kthread_struct(struct task_struct *p) > > init_completion(&kthread->exited); > init_completion(&kthread->parked); > - INIT_LIST_HEAD(&kthread->hotplug_node); > + INIT_LIST_HEAD(&kthread->affinity_node); > p->vfork_done = &kthread->exited; > > kthread->task = p; > @@ -323,10 +323,10 @@ void __noreturn kthread_exit(long result) > { > struct kthread *kthread = to_kthread(current); > kthread->result = 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); > > if (kthread->preferred_affinity) { > kfree(kthread->preferred_affinity); > @@ -390,9 +390,9 @@ static void kthread_affine_node(void) > return; > } > > - 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); > > free_cpumask_var(affinity); > } > @@ -873,16 +873,16 @@ int kthread_affine_preferred(struct task_struct *p, const struct cpumask *mask) > goto out; > } > > - 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); > > scoped_guard (raw_spinlock_irqsave, &p->pi_lock) > set_cpus_allowed_force(p, affinity); > > - mutex_unlock(&kthreads_hotplug_lock); > + mutex_unlock(&kthread_affinity_lock); > out: > free_cpumask_var(affinity); > > @@ -903,9 +903,9 @@ static int kthreads_online_cpu(unsigned int cpu) > struct kthread *k; > int ret; > > - guard(mutex)(&kthreads_hotplug_lock); > + guard(mutex)(&kthread_affinity_lock); > > - if (list_empty(&kthreads_hotplug)) > + if (list_empty(&kthread_affinity_list)) > return 0; > > if (!zalloc_cpumask_var(&affinity, GFP_KERNEL)) > @@ -913,7 +913,7 @@ static int kthreads_online_cpu(unsigned int cpu) > > ret = 0; > > - 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 = -EINVAL; Acked-by: Waiman Long