lkml.org 
[lkml]   [2008]   [Jul]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch, minor] workqueue: consistently use 'err' in __create_workqueue_key()
On 07/28, Dmitry Adamushko wrote:
>
> I guess error handling is a bit illogical in __create_workqueue_key()

Please see below,

> for_each_possible_cpu(cpu) {
> cwq = init_cpu_workqueue(wq, cpu);
> - if (err || !cpu_online(cpu))
> + if (!cpu_online(cpu))
> continue;
> err = create_workqueue_thread(cwq, cpu);
> + if (err)
> + break;

This was done on purpose. The code above does init_cpu_workqueue(cpu)
for each possible cpu, even if we fail to create cwq->thread for some
cpu. This way destroy_workqueue() (called below) shouldn't worry about
the partially initialized workqueues.

The patch above should work, but it assumes that destroy_workqueue()
must do nothing with cwq if cwq->thread == NULL, this is not very
robust.


And, more importantly. Let's suppose __create_workqueue_key() does
"break" and drops cpu_add_remove_lock. Then we race with cpu-hotplug
which can hit the uninitialized cwq. This is fixable, but needs other
complication.

Oleg.



\
 
 \ /
  Last update: 2008-07-29 13:01    [W:0.312 / U:0.468 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site