Skip to contentSkip to conversation

workqueue - process context

DISCUSSION Vicente Feito 1 participant 1 message Feb 19, 2005

lore
Share & tools
lore
#0 lore raw
Quoted 16 lines · you

Vicente> I've been playing with workqueues, and I've found that Vicente> once I unload the module, if I don't call Vicente> destroy_workqueue(); then the workqueue I've created Vicente> stays in the process list, [my_wq], I don't know if Vicente> that's meant to be, or is it a bug, cause I believe there Vicente> can be two options in here:

Vicente> 1) It's meant to be so you can unload your module and let Vicente> the works run some time after you're already gone, that Vicente> allows you to probe other modules or do whatever necesary Vicente> without the need to wait for the workqueue to be emtpy.

Vicente> 2) It's a bug, cause the module allows to be unloaded, Vicente> destroying the structs but not removing the workqueue Vicente> from the process context.

Quoted 5 lines

Not destroying its workqueue is a bug in the module just like any other resource leak. It's analogous to a module allocating some memory with kmalloc() and not calling kfree() when it's unloaded. If a module creates a workqueue, then it should call destroy_workqueue() when it's unloaded.

What if I need the module to be unloaded cause It's mutually exclusive with another module to be loaded, and I still need to run the works in a workqueue time before that happens? That's completely out of the picture?cause that might be useful.

Quoted 4 lines

By the way, the module (or any code calling destroy_workqueue()) must make sure that it has race conditions that might result in work being submitted to the queue while it is being destroyed.

yes, I think flushing is enough, is it?

Quoted 2 lines

-R .

Vicente.