aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/workqueue.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r--kernel/workqueue.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index ef071ca73fc3..479d840db286 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2974,6 +2974,31 @@ bool flush_delayed_work(struct delayed_work *dwork)
2974} 2974}
2975EXPORT_SYMBOL(flush_delayed_work); 2975EXPORT_SYMBOL(flush_delayed_work);
2976 2976
2977static bool __cancel_work(struct work_struct *work, bool is_dwork)
2978{
2979 unsigned long flags;
2980 int ret;
2981
2982 do {
2983 ret = try_to_grab_pending(work, is_dwork, &flags);
2984 } while (unlikely(ret == -EAGAIN));
2985
2986 if (unlikely(ret < 0))
2987 return false;
2988
2989 set_work_pool_and_clear_pending(work, get_work_pool_id(work));
2990 local_irq_restore(flags);
2991 return ret;
2992}
2993
2994/*
2995 * See cancel_delayed_work()
2996 */
2997bool cancel_work(struct work_struct *work)
2998{
2999 return __cancel_work(work, false);
3000}
3001
2977/** 3002/**
2978 * cancel_delayed_work - cancel a delayed work 3003 * cancel_delayed_work - cancel a delayed work
2979 * @dwork: delayed_work to cancel 3004 * @dwork: delayed_work to cancel
@@ -2992,20 +3017,7 @@ EXPORT_SYMBOL(flush_delayed_work);
2992 */ 3017 */
2993bool cancel_delayed_work(struct delayed_work *dwork) 3018bool cancel_delayed_work(struct delayed_work *dwork)
2994{ 3019{
2995 unsigned long flags; 3020 return __cancel_work(&dwork->work, true);
2996 int ret;
2997
2998 do {
2999 ret = try_to_grab_pending(&dwork->work, true, &flags);
3000 } while (unlikely(ret == -EAGAIN));
3001
3002 if (unlikely(ret < 0))
3003 return false;
3004
3005 set_work_pool_and_clear_pending(&dwork->work,
3006 get_work_pool_id(&dwork->work));
3007 local_irq_restore(flags);
3008 return ret;
3009} 3021}
3010EXPORT_SYMBOL(cancel_delayed_work); 3022EXPORT_SYMBOL(cancel_delayed_work);
3011 3023
@@ -4249,7 +4261,7 @@ void print_worker_info(const char *log_lvl, struct task_struct *task)
4249 * This function is called without any synchronization and @task 4261 * This function is called without any synchronization and @task
4250 * could be in any state. Be careful with dereferences. 4262 * could be in any state. Be careful with dereferences.
4251 */ 4263 */
4252 worker = probe_kthread_data(task); 4264 worker = kthread_probe_data(task);
4253 4265
4254 /* 4266 /*
4255 * Carefully copy the associated workqueue's workfn and name. Keep 4267 * Carefully copy the associated workqueue's workfn and name. Keep