[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZqQjxnWWKYBIpueP@pavilion.home>
Date: Sat, 27 Jul 2024 00:31:34 +0200
From: Frederic Weisbecker <frederic@...nel.org>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>, Kees Cook <kees@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Michal Hocko <mhocko@...nel.org>, Vlastimil Babka <vbabka@...e.cz>,
linux-mm@...ck.org, "Paul E. McKenney" <paulmck@...nel.org>,
Neeraj Upadhyay <neeraj.upadhyay@...nel.org>,
Joel Fernandes <joel@...lfernandes.org>,
Boqun Feng <boqun.feng@...il.com>,
Zqiang <qiang.zhang1211@...il.com>, rcu@...r.kernel.org
Subject: Re: [RFC PATCH 12/20] kthread: Implement preferred affinity
Le Fri, Jul 26, 2024 at 11:56:48PM +0200, Frederic Weisbecker a écrit :
> +int kthread_affine_preferred(struct task_struct *p, const struct cpumask *mask)
> +{
> + struct kthread *kthread = to_kthread(p);
> + cpumask_var_t affinity;
> + unsigned long flags;
> + int ret;
> +
> + if (!wait_task_inactive(p, TASK_UNINTERRUPTIBLE) || kthread->started) {
> + WARN_ON(1);
> + return -EINVAL;
> + }
> +
> + if (!zalloc_cpumask_var(&affinity, GFP_KERNEL))
> + return -ENOMEM;
> +
> + kthread->preferred_affinity = kzalloc(sizeof(struct cpumask), GFP_KERNEL);
> + if (!kthread->preferred_affinity) {
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> + mutex_lock(&kthreads_hotplug_lock);
> + cpumask_copy(kthread->preferred_affinity, mask);
> + list_add_tail(&kthread->hotplug_node, &kthreads_hotplug);
> + kthread_fetch_affinity(kthread, affinity);
> +
> + /* It's safe because the task is inactive. */
> + raw_spin_lock_irqsave(&p->pi_lock, flags);
> + do_set_cpus_allowed(p, mask);
s/mask/affinity
Powered by blists - more mailing lists