Skip to contentSkip to conversation

make cancel_xxx_work_sync() return a boolean

PATCH In review Oleg Nesterov 2 participants 2 messages Jul 1, 2007 – Jul 3, 2007 Workqueue

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 make cancel_xxx_work_sync() return a boolean

Change cancel_work_sync() and cancel_delayed_work_sync() to return a boolean indicating whether the work was actually cancelled. A zero return value means that the work was not pending/queued.

Without that kind of change it is not possible to avoid flush_workqueue() sometimes, see the next patch as an example.

Also, this patch unifies both functions and kills the (unlikely) busy-wait loop.

include/linux/workqueue.h renamed from include/linux/workqueue.h~2_retval +2 -2
@@ -148,7 +148,7 @@ extern int keventd_up(void);
 extern void init_workqueues(void);
 int execute_in_process_context(work_func_t fn, struct execute_work *);
 
-extern void cancel_work_sync(struct work_struct *work);
+extern int cancel_work_sync(struct work_struct *work);
 
 /*
  * Kill off a pending schedule_delayed_work().  Note that the work callback
@@ -166,7 +166,7 @@ static inline int cancel_delayed_work(st
 	return ret;
 }
 
-extern void cancel_delayed_work_sync(struct delayed_work *work);
+extern int cancel_delayed_work_sync(struct delayed_work *work);
 
 /* Obsolete. use cancel_delayed_work_sync() */
 static inline
kernel/workqueue.c renamed from kernel/workqueue.c~2_retval +27 -14

81 lines not on this page · raw message

Acked-by on v1 2/3
#1 lore raw
Quoted 10 lines · Oleg Nesterov

Change cancel_work_sync() and cancel_delayed_work_sync() to return a boolean indicating whether the work was actually cancelled. A zero return value means that the work was not pending/queued.

Without that kind of change it is not possible to avoid flush_workqueue() sometimes, see the next patch as an example.

Also, this patch unifies both functions and kills the (unlikely) busy-wait loop.