lkml.org 
[lkml]   [2020]   [Oct]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] kthread_worker: re-set CPU affinities if CPU come online
On Mon, Oct 26, 2020 at 02:52:13PM +0800, qiang.zhang@windriver.com wrote:
> @@ -737,8 +741,11 @@ __kthread_create_worker(int cpu, unsigned int flags,
> if (IS_ERR(task))
> goto fail_task;
>
> - if (cpu >= 0)
> + if (cpu >= 0) {
> kthread_bind(task, cpu);
> + worker->bind_cpu = cpu;
> + cpuhp_state_add_instance_nocalls(kworker_online, &worker->cpuhp_node);
> + }
>
> worker->flags = flags;
> worker->task = task;
...
> +static int kworker_cpu_online(unsigned int cpu, struct hlist_node *node)
> +{
> + struct kthread_worker *worker = hlist_entry(node, struct kthread_worker, cpuhp_node);
> + struct task_struct *task = worker->task;
> +
> + if (cpu == worker->bind_cpu)
> + WARN_ON_ONCE(set_cpus_allowed_ptr(task, cpumask_of(cpu)) < 0);
> + return 0;
> +}

I don't think this works. The kthread may have changed its binding while
running using set_cpus_allowed_ptr() as you're doing above. Besides, when a
cpu goes offline, the bound kthread can fall back to other cpus but its cpu
mask isn't cleared, is it?

Thanks.

--
tejun

\
 
 \ /
  Last update: 2020-10-26 14:50    [W:0.064 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site