Re: [Patch] workqueue: move lockdep annotations up to destroy_workqueue()

From: Cong Wang
Date: Thu Apr 01 2010 - 02:02:31 EST

Cong Wang wrote:
Tejun Heo wrote:

On 04/01/2010 01:28 PM, Cong Wang wrote:
Hmmm... can you please try to see whether this circular locking
warning involving wq->lockdep_map is reproducible w/ the bonding
locking fixed? I still can't see where wq -> cpu_add_remove_lock
dependency is created.

I thought this is obvious.

Here it is:

void destroy_workqueue(struct workqueue_struct *wq)
const struct cpumask *cpu_map = wq_cpu_map(wq);
int cpu;

cpu_maps_update_begin(); <----------------- Hold
cpu_add_remove_lock here

for_each_cpu(cpu, cpu_map)
cleanup_workqueue_thread(per_cpu_ptr(wq->cpu_wq, cpu)); <------ See below
cpu_maps_update_done(); <----------------- Release
cpu_add_remove_lock here

static void cleanup_workqueue_thread(struct cpu_workqueue_struct *cwq)
* Our caller is either destroy_workqueue() or CPU_POST_DEAD,
* cpu_add_remove_lock protects cwq->thread.
if (cwq->thread == NULL)

lock_map_acquire(&cwq->wq->lockdep_map); <-------------- Lockdep
complains here.

Yeap, the above is cpu_add_remove_lock -> wq->lockdep_map dependency.
I can see that but I'm failing to see where the dependency the other
direction is created.

Hmm, it looks like I misunderstand lock_map_acquire()? From the changelog,
I thought it was added to complain its caller is holding a lock when invoking
it, thus cpu_add_remove_lock is not an exception.

Oh, I see, wq->lockdep_map is acquired again in run_workqueue(), so I was wrong. :)
I think you and Oleg are right, the lockdep warning is not irrelevant.

Sorry for the noise, ignore this patch please.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at