[PATCH 1/1] introduce __cancel_delayed_work()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Oleg Nesterov
Date: Friday, August 28, 2009 - 11:00 am

cancel_delayed_work() has to use del_timer_sync() to guarantee the
timer function is not running after return. But most users doesn't
actually need this, and del_timer_sync() has problems: it is not
useable from interrupt, and it depends on every lock which could
be taken from irq.

Introduce __cancel_delayed_work() which calls del_timer() instead.

The immediate reason for this patch is
http://bugzilla.kernel.org/show_bug.cgi?id=13757
but hopefully this helper makes sense anyway.

As for 13757 bug, actually we need requeue_delayed_work(), but its
semantics is not clear yet.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>

--- MINI/include/linux/workqueue.h~CDW	2009-08-27 20:17:08.000000000 +0200
+++ MINI/include/linux/workqueue.h	2009-08-27 20:22:48.000000000 +0200
@@ -240,6 +240,21 @@ static inline int cancel_delayed_work(st
 	return ret;
 }
 
+/*
+ * Like above, but uses del_timer() instead of del_timer_sync(). This means,
+ * if it returns 0 the timer function may be running and the queueing is in
+ * progress.
+ */
+static inline int __cancel_delayed_work(struct delayed_work *work)
+{
+	int ret;
+
+	ret = del_timer(&work->timer);
+	if (ret)
+		work_clear_pending(&work->work);
+	return ret;
+}
+
 extern int cancel_delayed_work_sync(struct delayed_work *work);
 
 /* Obsolete. use cancel_delayed_work_sync() */

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Is adding requeue_delayed_work() a good idea, Roland Dreier, (Thu Aug 20, 2:51 pm)
Re: Is adding requeue_delayed_work() a good idea, Oleg Nesterov, (Fri Aug 21, 4:55 am)
Re: Is adding requeue_delayed_work() a good idea, Roland Dreier, (Fri Aug 21, 2:53 pm)
Re: Is adding requeue_delayed_work() a good idea, Stefan Richter, (Sat Aug 22, 3:35 am)
Re: Is adding requeue_delayed_work() a good idea, Oleg Nesterov, (Mon Aug 24, 11:01 am)
Re: Is adding requeue_delayed_work() a good idea, Roland Dreier, (Mon Aug 24, 2:11 pm)
Re: Is adding requeue_delayed_work() a good idea, Oleg Nesterov, (Tue Aug 25, 2:39 am)
Re: Is adding requeue_delayed_work() a good idea, Roland Dreier, (Wed Aug 26, 11:42 am)
[PATCH 0/1] introduce __cancel_delayed_work(), Oleg Nesterov, (Fri Aug 28, 10:59 am)
[PATCH 1/1] introduce __cancel_delayed_work(), Oleg Nesterov, (Fri Aug 28, 11:00 am)
Re: Is adding requeue_delayed_work() a good idea, Dmitry Torokhov, (Mon Aug 31, 5:44 pm)
Re: [PATCH 1/1] introduce __cancel_delayed_work(), Roland Dreier, (Tue Sep 1, 9:09 am)
Re: [PATCH 1/1] introduce __cancel_delayed_work(), Dmitry Torokhov, (Tue Sep 1, 9:40 am)
Re: [PATCH 1/1] introduce __cancel_delayed_work(), Andrew Morton, (Tue Sep 1, 3:29 pm)