Skip to contentSkip to conversation

workqueue: Calling destroy_work_on_stack() to pair with INIT_WORK_ONSTACK()

PATCH Applied Chuansheng Liu 5 participants 8 messages Jan 7, 2014 – Jan 12, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 workqueue: Calling destroy_work_on_stack() to pair with INIT_WORK_ONSTACK()

In case CONFIG_DEBUG_OBJECTS_WORK is defined, it is needed to call destroy_work_on_stack() which frees the debug object to pair with INIT_WORK_ONSTACK().

---
 kernel/workqueue.c |    2 ++
 1 file changed, 2 insertions(+)
kernel/workqueue.c +2 -0
index b010eac..82ef9f3 100644
@@ -4789,6 +4789,7 @@ static int workqueue_cpu_down_callback(struct notifier_block *nfb,
 
 		/* wait for per-cpu unbinding to finish */
 		flush_work(&unbind_work);
+		destroy_work_on_stack(&unbind_work);
 		break;
 	}
 	return NOTIFY_OK;
@@ -4828,6 +4829,7 @@ long work_on_cpu(int cpu, long (*fn)(void *), void *arg)
 	INIT_WORK_ONSTACK(&wfc.work, work_for_cpu_fn);
 	schedule_work_on(cpu, &wfc.work);
 	flush_work(&wfc.work);
+	destroy_work_on_stack(&wfc.work);
 	return wfc.ret;
 }
 EXPORT_SYMBOL_GPL(work_on_cpu);
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 2/3 xfs: Calling destroy_work_on_stack() to pair with INIT_WORK_ONSTACK()

In case CONFIG_DEBUG_OBJECTS_WORK is defined, it is needed to call destroy_work_on_stack() which frees the debug object to pair with INIT_WORK_ONSTACK().

---
 fs/xfs/xfs_bmap_util.c |    1 +
 1 file changed, 1 insertion(+)
fs/xfs/xfs_bmap_util.c +1 -0
index 1394106..82e0dab 100644
@@ -287,6 +287,7 @@ xfs_bmapi_allocate(
 	INIT_WORK_ONSTACK(&args->work, xfs_bmapi_allocate_worker);
 	queue_work(xfs_alloc_wq, &args->work);
 	wait_for_completion(&done);
+	destroy_work_on_stack(&args->work);
 	return args->result;
 }
 
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH 2/3] xfs: Calling destroy_work_on_stack() to pair with INIT_WORK_ONSTACK()

Hi Chuansheng,

Quoted 15 lines · Chuansheng Liu

In case CONFIG_DEBUG_OBJECTS_WORK is defined, it is needed to call destroy_work_on_stack() which frees the debug object to pair with INIT_WORK_ONSTACK().

---
 fs/xfs/xfs_bmap_util.c |    1 +
 1 file changed, 1 insertion(+)
fs/xfs/xfs_bmap_util.c +0 -0
index 1394106..82e0dab 100644

fs/xfs/xfs_bmap_util.c xfs_bmapi_allocate( · line 292

Quoted 6 lines
fs/xfs/xfs_bmap_util.c +1 -0
@@ -287,6 +287,7 @@ xfs_bmapi_allocate(
 	INIT_WORK_ONSTACK(&args->work, xfs_bmapi_allocate_worker);
 	queue_work(xfs_alloc_wq, &args->work);
 	wait_for_completion(&done);
+	destroy_work_on_stack(&args->work);
 	return args->result;
 }

Thanks for your patch and it work fine for my testing. I missed this in an old commit: [ 3b876c8f2a xfs: fix debug_object WARN at xfs_alloc_vextent() ]

Just out of curious, do you notice memory leaks or other hints which help you finding out this problem?

Thanks,
-Jeff

Reviewed-by
#3 lore raw

Re: [PATCH 2/3] xfs: Calling destroy_work_on_stack() to pair with INIT_WORK_ONSTACK()

Quoted 13 lines · Jeff Liu

Hi Chuansheng,

Quoted 10 lines · Chuansheng Liu

In case CONFIG_DEBUG_OBJECTS_WORK is defined, it is needed to call destroy_work_on_stack() which frees the debug object to pair with INIT_WORK_ONSTACK().

---
 fs/xfs/xfs_bmap_util.c |    1 +
 1 file changed, 1 insertion(+)
Quoted 14 lines

fs/xfs/xfs_bmap_util.c xfs_bmapi_allocate( · line 292

Quoted 11 lines
fs/xfs/xfs_bmap_util.c +1 -0
index 1394106..82e0dab 100644
@@ -287,6 +287,7 @@ xfs_bmapi_allocate(
 	INIT_WORK_ONSTACK(&args->work, xfs_bmapi_allocate_worker);
 	queue_work(xfs_alloc_wq, &args->work);
 	wait_for_completion(&done);
+	destroy_work_on_stack(&args->work);
 	return args->result;
 }

Thanks for your patch and it work fine for my testing. I missed this in an old commit: [ 3b876c8f2a xfs: fix debug_object WARN at xfs_alloc_vextent() ]

Looks good to me too.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#4 lore raw

RE: [PATCH 2/3] xfs: Calling destroy_work_on_stack() to pair with INIT_WORK_ONSTACK()

In reply to Jeff Liu

Hello Jeff,

Quoted 12 lines

-----Original Message-----
From: Jeff Liu [mailto:[email protected]]
Sent: Tuesday, January 07, 2014 7:21 PM
To: Liu, Chuansheng; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH 2/3] xfs: Calling destroy_work_on_stack() to pair with INIT_WORK_ONSTACK()

Hi Chuansheng,

Quoted 1 line · Chuansheng Liu
Quoted 8 lines
Quoted 6 lines

In case CONFIG_DEBUG_OBJECTS_WORK is defined, it is needed to call destroy_work_on_stack() which frees the debug object to pair with INIT_WORK_ONSTACK().

---

Thanks for your patch and it work fine for my testing. I missed this in an old commit: [ 3b876c8f2a xfs: fix debug_object WARN at xfs_alloc_vextent() ]

Thanks your testing.

Quoted 3 lines

Just out of curious, do you notice memory leaks or other hints which help you finding out this problem?

I am trying to use the INIT_WORK_ONSTACK() in my code, then I found in some places Calling destroy_work_on_stack() is missed.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#5 lore raw

PATCH 3/3 dm snapshot: Calling destroy_work_on_stack() to pair with INIT_WORK_ONSTACK()

In reply to Chuansheng Liu

In case CONFIG_DEBUG_OBJECTS_WORK is defined, it is needed to call destroy_work_on_stack() which frees the debug object to pair with INIT_WORK_ONSTACK().

---
 drivers/md/dm-snap-persistent.c |    1 +
 1 file changed, 1 insertion(+)
drivers/md/dm-snap-persistent.c +1 -0
index 2d2b1b7..2f5a9f8 100644
@@ -257,6 +257,7 @@ static int chunk_io(struct pstore *ps, void *area, chunk_t chunk, int rw,
 	INIT_WORK_ONSTACK(&req.work, do_metadata);
 	queue_work(ps->metadata_wq, &req.work);
 	flush_workqueue(ps->metadata_wq);
+	destroy_work_on_stack(&req.work);
 
 	return req.result;
 }
Signature · 1 line
1.7.9.5
Applied
#6 lore raw

Re: [PATCH 3/3] dm snapshot: Calling destroy_work_on_stack() to pair with INIT_WORK_ONSTACK()

Quoted 6 lines · Chuansheng Liu

In case CONFIG_DEBUG_OBJECTS_WORK is defined, it is needed to call destroy_work_on_stack() which frees the debug object to pair with INIT_WORK_ONSTACK().

Applied to linux-dm.git's 'for-next' branch.

Thanks,
Mike