forked from rrcarlosr/Jetpack
154 lines
4.7 KiB
Diff
154 lines
4.7 KiB
Diff
From a2f98579c13665d73e8fcaeef60f10c618685b37 Mon Sep 17 00:00:00 2001
|
|
From: Thomas Gleixner <tglx@linutronix.de>
|
|
Date: Sun, 17 Jul 2011 21:42:26 +0200
|
|
Subject: [PATCH 225/352] workqueue: Use local irq lock instead of irq disable
|
|
regions
|
|
|
|
Use a local_irq_lock as a replacement for irq off regions. We keep the
|
|
semantic of irq-off in regard to the pool->lock and remain preemptible.
|
|
|
|
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
|
|
---
|
|
kernel/workqueue.c | 33 +++++++++++++++++++--------------
|
|
1 file changed, 19 insertions(+), 14 deletions(-)
|
|
|
|
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
|
|
index 875bcede..6d82876 100644
|
|
--- a/kernel/workqueue.c
|
|
+++ b/kernel/workqueue.c
|
|
@@ -48,6 +48,7 @@
|
|
#include <linux/nodemask.h>
|
|
#include <linux/moduleparam.h>
|
|
#include <linux/uaccess.h>
|
|
+#include <linux/locallock.h>
|
|
#include <linux/nmi.h>
|
|
|
|
#include "workqueue_internal.h"
|
|
@@ -350,6 +351,8 @@ EXPORT_SYMBOL_GPL(system_power_efficient_wq);
|
|
struct workqueue_struct *system_freezable_power_efficient_wq __read_mostly;
|
|
EXPORT_SYMBOL_GPL(system_freezable_power_efficient_wq);
|
|
|
|
+static DEFINE_LOCAL_IRQ_LOCK(pendingb_lock);
|
|
+
|
|
static int worker_thread(void *__worker);
|
|
static void workqueue_sysfs_unregister(struct workqueue_struct *wq);
|
|
|
|
@@ -1103,9 +1106,11 @@ static void put_pwq_unlocked(struct pool_workqueue *pwq)
|
|
* As both pwqs and pools are RCU protected, the
|
|
* following lock operations are safe.
|
|
*/
|
|
- spin_lock_irq(&pwq->pool->lock);
|
|
+ rcu_read_lock();
|
|
+ local_spin_lock_irq(pendingb_lock, &pwq->pool->lock);
|
|
put_pwq(pwq);
|
|
- spin_unlock_irq(&pwq->pool->lock);
|
|
+ local_spin_unlock_irq(pendingb_lock, &pwq->pool->lock);
|
|
+ rcu_read_unlock();
|
|
}
|
|
}
|
|
|
|
@@ -1209,7 +1214,7 @@ static int try_to_grab_pending(struct work_struct *work, bool is_dwork,
|
|
struct worker_pool *pool;
|
|
struct pool_workqueue *pwq;
|
|
|
|
- local_irq_save(*flags);
|
|
+ local_lock_irqsave(pendingb_lock, *flags);
|
|
|
|
/* try to steal the timer if it exists */
|
|
if (is_dwork) {
|
|
@@ -1273,7 +1278,7 @@ static int try_to_grab_pending(struct work_struct *work, bool is_dwork,
|
|
spin_unlock(&pool->lock);
|
|
fail:
|
|
rcu_read_unlock();
|
|
- local_irq_restore(*flags);
|
|
+ local_unlock_irqrestore(pendingb_lock, *flags);
|
|
if (work_is_canceling(work))
|
|
return -ENOENT;
|
|
cpu_relax();
|
|
@@ -1378,7 +1383,7 @@ static void __queue_work(int cpu, struct workqueue_struct *wq,
|
|
* 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);
|
|
|
|
@@ -1484,14 +1489,14 @@ bool queue_work_on(int cpu, struct workqueue_struct *wq,
|
|
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(queue_work_on);
|
|
@@ -1559,14 +1564,14 @@ bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
|
|
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(queue_delayed_work_on);
|
|
@@ -1601,7 +1606,7 @@ bool mod_delayed_work_on(int cpu, struct workqueue_struct *wq,
|
|
|
|
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 */
|
|
@@ -2912,7 +2917,7 @@ static bool __cancel_work_timer(struct work_struct *work, bool is_dwork)
|
|
|
|
/* 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);
|
|
@@ -2967,10 +2972,10 @@ 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, dwork->wq, &dwork->work);
|
|
- local_irq_enable();
|
|
+ local_unlock_irq(pendingb_lock);
|
|
return flush_work(&dwork->work);
|
|
}
|
|
EXPORT_SYMBOL(flush_delayed_work);
|
|
@@ -2988,7 +2993,7 @@ static bool __cancel_work(struct work_struct *work, bool is_dwork)
|
|
return false;
|
|
|
|
set_work_pool_and_clear_pending(work, get_work_pool_id(work));
|
|
- local_irq_restore(flags);
|
|
+ local_unlock_irqrestore(pendingb_lock, flags);
|
|
return ret;
|
|
}
|
|
|
|
--
|
|
2.7.4
|
|
|