lkml.org 
[lkml]   [2021]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 3/4] workqueue: Tag bound workers with KTHREAD_IS_PER_CPU
Date
On 13/01/21 21:28, Lai Jiangshan wrote:
> On Tue, Jan 12, 2021 at 10:51 PM Peter Zijlstra <peterz@infradead.org> wrote:
>> @@ -4972,9 +4977,11 @@ static void rebind_workers(struct worker
>> * of all workers first and then clear UNBOUND. As we're called
>> * from CPU_ONLINE, the following shouldn't fail.
>> */
>> - for_each_pool_worker(worker, pool)
>> + for_each_pool_worker(worker, pool) {
>> WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task,
>> pool->attrs->cpumask) < 0);
>> + kthread_set_per_cpu(worker->task, true);
>
> Will the schedule break affinity in the middle of these two lines due to
> patch4 allowing it and result in Paul's reported splat.
>

You might be right; at this point we would still have BALANCE_PUSH set,
so something like the below could happen

rebind_workers()
set_cpus_allowed_ptr()
affine_move_task()
task_running() => stop_one_cpu()

... // Stopper migrates the kworker here in the meantime

switch_to(<pcpu kworker>) // Both cpuhp thread and kworker should be enqueued
// here, so one or the other could be picked
balance_switch()
balance_push()
^-- no KTHREAD_IS_PER_CPU !

This should however trigger the WARN_ON_ONCE() in kthread_set_per_cpu()
*before* the one in process_one_work(), which I haven't seen in Paul's
mails.

>> + }
>>
>> raw_spin_lock_irq(&pool->lock);
>>
>>
>>

\
 
 \ /
  Last update: 2021-01-13 15:19    [W:0.160 / U:0.436 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site