| Subject: Use local irq lock instead of irq disable regions |
| From: Thomas Gleixner <tglx@linutronix.de> |
| Date: Sun, 17 Jul 2011 21:42:26 +0200 |
| |
| Signed-off-by: Thomas Gleixner <tglx@linutronix.de> |
| --- |
| kernel/workqueue.c | 27 +++++++++++++++------------ |
| 1 file changed, 15 insertions(+), 12 deletions(-) |
| |
| --- a/kernel/workqueue.c |
| +++ b/kernel/workqueue.c |
| @@ -41,6 +41,7 @@ |
| #include <linux/debug_locks.h> |
| #include <linux/lockdep.h> |
| #include <linux/idr.h> |
| +#include <linux/locallock.h> |
| |
| #include "workqueue_sched.h" |
| |
| @@ -278,6 +279,8 @@ EXPORT_SYMBOL_GPL(system_unbound_wq); |
| struct workqueue_struct *system_freezable_wq __read_mostly; |
| EXPORT_SYMBOL_GPL(system_freezable_wq); |
| |
| +static DEFINE_LOCAL_IRQ_LOCK(pendingb_lock); |
| + |
| #define CREATE_TRACE_POINTS |
| #include <trace/events/workqueue.h> |
| |
| @@ -1092,7 +1095,7 @@ static int try_to_grab_pending(struct wo |
| { |
| struct global_cwq *gcwq; |
| |
| - local_irq_save(*flags); |
| + local_lock_irqsave(pendingb_lock, *flags); |
| |
| /* try to steal the timer if it exists */ |
| if (is_dwork) { |
| @@ -1151,7 +1154,7 @@ static int try_to_grab_pending(struct wo |
| } |
| spin_unlock(&gcwq->lock); |
| fail: |
| - local_irq_restore(*flags); |
| + local_unlock_irqrestore(pendingb_lock, *flags); |
| if (work_is_canceling(work)) |
| return -ENOENT; |
| cpu_relax(); |
| @@ -1246,7 +1249,7 @@ static void __queue_work(unsigned int cp |
| * queued or lose PENDING. Grabbing PENDING and queueing should |
| * happen with IRQ disabled. |
| */ |
| - WARN_ON_ONCE(!irqs_disabled()); |
| + WARN_ON_ONCE_NONRT(!irqs_disabled()); |
| |
| debug_work_activate(work); |
| |
| @@ -1336,14 +1339,14 @@ bool queue_work_on(int cpu, struct workq |
| bool ret = false; |
| unsigned long flags; |
| |
| - local_irq_save(flags); |
| + local_lock_irqsave(pendingb_lock,flags); |
| |
| if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))) { |
| __queue_work(cpu, wq, work); |
| ret = true; |
| } |
| |
| - local_irq_restore(flags); |
| + local_unlock_irqrestore(pendingb_lock, flags); |
| return ret; |
| } |
| EXPORT_SYMBOL_GPL(queue_work_on); |
| @@ -1451,14 +1454,14 @@ bool queue_delayed_work_on(int cpu, stru |
| unsigned long flags; |
| |
| /* read the comment in __queue_work() */ |
| - local_irq_save(flags); |
| + local_lock_irqsave(pendingb_lock, flags); |
| |
| if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))) { |
| __queue_delayed_work(cpu, wq, dwork, delay); |
| ret = true; |
| } |
| |
| - local_irq_restore(flags); |
| + local_unlock_irqrestore(pendingb_lock, flags); |
| return ret; |
| } |
| EXPORT_SYMBOL_GPL(queue_delayed_work_on); |
| @@ -1508,7 +1511,7 @@ bool mod_delayed_work_on(int cpu, struct |
| |
| if (likely(ret >= 0)) { |
| __queue_delayed_work(cpu, wq, dwork, delay); |
| - local_irq_restore(flags); |
| + local_unlock_irqrestore(pendingb_lock, flags); |
| } |
| |
| /* -ENOENT from try_to_grab_pending() becomes %true */ |
| @@ -2936,7 +2939,7 @@ static bool __cancel_work_timer(struct w |
| |
| /* tell other tasks trying to grab @work to back off */ |
| mark_work_canceling(work); |
| - local_irq_restore(flags); |
| + local_unlock_irqrestore(pendingb_lock, flags); |
| |
| flush_work(work); |
| clear_work_data(work); |
| @@ -2981,11 +2984,11 @@ EXPORT_SYMBOL_GPL(cancel_work_sync); |
| */ |
| bool flush_delayed_work(struct delayed_work *dwork) |
| { |
| - local_irq_disable(); |
| + local_lock_irq(pendingb_lock); |
| if (del_timer_sync(&dwork->timer)) |
| __queue_work(dwork->cpu, |
| get_work_cwq(&dwork->work)->wq, &dwork->work); |
| - local_irq_enable(); |
| + local_unlock_irq(pendingb_lock); |
| return flush_work(&dwork->work); |
| } |
| EXPORT_SYMBOL(flush_delayed_work); |
| @@ -3015,7 +3018,7 @@ bool cancel_delayed_work(struct delayed_ |
| return false; |
| |
| set_work_cpu_and_clear_pending(&dwork->work, work_cpu(&dwork->work)); |
| - local_irq_restore(flags); |
| + local_unlock_irqrestore(pendingb_lock, flags); |
| return ret; |
| } |
| EXPORT_SYMBOL(cancel_delayed_work); |