Skip to contentSkip to conversation

workqueue: cancel_delayed_work() should return %NULL if work item is idle

PATCH New Dan Magenheimer 2 participants 3 messages Oct 19, 2012 – Oct 23, 2012 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 workqueue: cancel_delayed_work() should return %NULL if work item is idle

FYI, it is likely that ocfs2 will not work on 3.7-rcN until the following one-line patch is merged, as the code in ramster that provoked it is directly leveraged from ocfs2 o2net.

Quoted 44 lines

From: Tejun Heo [mailto:tj at kernel.org]
Sent: Thursday, October 18, 2012 5:39 PM
To: Dan Magenheimer
Cc: linux-kernel at vger.kernel.org; Konrad Wilk
Subject: [PATCH] workqueue: cancel_delayed_work() should return %NULL if work item is idle

From e65120fcfc1cb9697655d29ecd7982451c05d3c2 Mon Sep 17 00:00:00 2001
From: Dan Magenheimer <[email protected]>
Date: Thu, 18 Oct 2012 16:31:37 -0700

57b30ae77b ("workqueue: reimplement cancel_delayed_work() using try_to_grab_pending()") made cancel_delayed_work() always return %true unless someone else is also trying to cancel the work item, which is broken - if the target work item is idle, the return value should be %false.

try_to_grab_pending() indicates that the target work item was idle by zero return value. Use it for return. Note that this brings cancel_delayed_work() in line with __cancel_work_timer() in return value handling.

LKML-Reference: <444a6439-b1a4-4740-9e7e-bc37267cfe73@default>

---
 kernel/workqueue.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/workqueue.c +1 -2
index d951daa..042d221 100644
@@ -2982,7 +2982,7 @@ bool cancel_delayed_work(struct delayed_work *dwork)
 
 	set_work_cpu_and_clear_pending(&dwork->work, work_cpu(&dwork->work));
 	local_irq_restore(flags);
-	return true;
+	return ret;
 }
 EXPORT_SYMBOL(cancel_delayed_work);
 
--

1.7.7.3

maintainer
#1 lore raw

PATCH 1/1 workqueue: cancel_delayed_work() should return %NULL if work item is idle

Help me understand the issue. Who broke this? Do I need to push this patch, or is someone else?

Thanks,
Joel

Quoted 53 lines · Dan Magenheimer

FYI, it is likely that ocfs2 will not work on 3.7-rcN until the following one-line patch is merged, as the code in ramster that provoked it is directly leveraged from ocfs2 o2net.

Quoted 42 lines

From: Tejun Heo [mailto:tj at kernel.org]
Sent: Thursday, October 18, 2012 5:39 PM
To: Dan Magenheimer
Cc: linux-kernel at vger.kernel.org; Konrad Wilk
Subject: [PATCH] workqueue: cancel_delayed_work() should return %NULL if work item is idle

From e65120fcfc1cb9697655d29ecd7982451c05d3c2 Mon Sep 17 00:00:00 2001
From: Dan Magenheimer <[email protected]>
Date: Thu, 18 Oct 2012 16:31:37 -0700

57b30ae77b ("workqueue: reimplement cancel_delayed_work() using try_to_grab_pending()") made cancel_delayed_work() always return %true unless someone else is also trying to cancel the work item, which is broken - if the target work item is idle, the return value should be %false.

try_to_grab_pending() indicates that the target work item was idle by zero return value. Use it for return. Note that this brings cancel_delayed_work() in line with __cancel_work_timer() in return value handling.

LKML-Reference: <444a6439-b1a4-4740-9e7e-bc37267cfe73@default>

---
 kernel/workqueue.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/workqueue.c +1 -2
index d951daa..042d221 100644
@@ -2982,7 +2982,7 @@ bool cancel_delayed_work(struct delayed_work *dwork)
 
 	set_work_cpu_and_clear_pending(&dwork->work, work_cpu(&dwork->work));
 	local_irq_restore(flags);
-	return true;
+	return ret;
 }
 EXPORT_SYMBOL(cancel_delayed_work);
 
--
Quoted 2 lines

1.7.7.3

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

Signature · 6 lines
Life's Little Instruction Book #139

	"Never deprive someone of hope; it might be all they have."

			http://www.jlbec.org/
			jlbec at evilplan.org
#2 lore raw

PATCH 1/1 workqueue: cancel_delayed_work() should return %NULL if work item is idle

Quoted 9 lines

From: Joel Becker [mailto:jlbec at evilplan.org]
Sent: Tuesday, October 23, 2012 2:51 AM
To: Dan Magenheimer
Cc: ocfs2-devel at oss.oracle.com
Subject: Re: [Ocfs2-devel] FW: [PATCH] workqueue: cancel_delayed_work() should return %NULL if work item is idle

Help me understand the issue. Who broke this? Do I need to push this patch, or is someone else?

Tejun's new workqueue implementation which was just merged in 3.7 had a bug in it. See this thread:

https://lkml.org/lkml/2012/10/18/592

It appears the patch didn't get into 3.7-rc2. Cc'ing Tejun. Hopefully it will be merged for -rc3 since
ramster is completely broken without the patch because a reference counter on a socket gets miscounted. I expect the same to be true of ocfs2... Srini was going to check.

Dan

Quoted 63 lines · Dan Magenheimer
Quoted 45 lines

FYI, it is likely that ocfs2 will not work on 3.7-rcN until the following one-line patch is merged, as the code in ramster that provoked it is directly leveraged from ocfs2 o2net.

Quoted 41 lines

From: Tejun Heo [mailto:tj at kernel.org]
Sent: Thursday, October 18, 2012 5:39 PM
To: Dan Magenheimer
Cc: linux-kernel at vger.kernel.org; Konrad Wilk
Subject: [PATCH] workqueue: cancel_delayed_work() should return %NULL if work item is idle

From e65120fcfc1cb9697655d29ecd7982451c05d3c2 Mon Sep 17 00:00:00 2001
From: Dan Magenheimer <[email protected]>
Date: Thu, 18 Oct 2012 16:31:37 -0700

57b30ae77b ("workqueue: reimplement cancel_delayed_work() using try_to_grab_pending()") made cancel_delayed_work() always return %true unless someone else is also trying to cancel the work item, which is broken - if the target work item is idle, the return value should be %false.

try_to_grab_pending() indicates that the target work item was idle by zero return value. Use it for return. Note that this brings cancel_delayed_work() in line with __cancel_work_timer() in return value handling.

LKML-Reference: <444a6439-b1a4-4740-9e7e-bc37267cfe73@default>

---
 kernel/workqueue.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/workqueue.c +1 -1
index d951daa..042d221 100644
@@ -2982,7 +2982,7 @@ bool cancel_delayed_work(struct delayed_work *dwork)
 
 	set_work_cpu_and_clear_pending(&dwork->work, work_cpu(&dwork->work));
 	local_irq_restore(flags);
-	return true;
+	return ret;
 }
 EXPORT_SYMBOL(cancel_delayed_work);
 
Quoted 8 lines
Quoted 3 lines

--
1.7.7.3

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

--

Life's Little Instruction Book #139

"Never deprive someone of hope; it might be all they have."

http://www.jlbec.org/
jlbec at evilplan.org