[PATCH 15/26] clocksource: Convert watchdog_lock to raw_spinlock

John Kacur
2010-01-11T21:27:34Z

Convert locks that cannot sleep in preempt-rt to raw-spinlocks.

See also fea886ed3f18a93ab76fbeed13f1f73c97bd8982

Signed-off-by: John Kacur <jkacur@redhat.com>
---
kernel/time/clocksource.c | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index e85c234..ffcb48f 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -183,7 +183,7 @@ static LIST_HEAD(watchdog_list);
static struct clocksource *watchdog;
static struct timer_list watchdog_timer;
static DECLARE_WORK(watchdog_work, clocksource_watchdog_work);
-static DEFINE_SPINLOCK(watchdog_lock);
+static DEFINE_RAW_SPINLOCK(watchdog_lock);
static cycle_t watchdog_last;
static int watchdog_running;

@@ -233,13 +233,13 @@ void clocksource_mark_unstable(struct clocksource *cs)
{
unsigned long flags;

- spin_lock_irqsave(&watchdog_lock, flags);
+ raw_spin_lock_irqsave(&watchdog_lock, flags);
if (!(cs->flags & CLOCK_SOURCE_UNSTABLE)) {
if (list_empty(&cs->wd_list))
list_add(&cs->wd_list, &watchdog_list);
__clocksource_unstable(cs);
}
- spin_unlock_irqrestore(&watchdog_lock, flags);
+ raw_spin_unlock_irqrestore(&watchdog_lock, flags);
}

static void clocksource_watchdog(unsigned long data)
@@ -249,7 +249,7 @@ static void clocksource_watchdog(unsigned long data)
int64_t wd_nsec, cs_nsec;
int next_cpu;

- spin_lock(&watchdog_lock);
+ raw_spin_lock(&watchdog_lock);
if (!watchdog_running)
goto out;

@@ -308,7 +308,7 @@ static void clocksource_watchdog(unsigned long data)
watchdog_timer.expires += WATCHDOG_INTERVAL;
add_timer_on(&watchdog_timer, next_cpu);
out:
- spin_unlock(&watchdog_lock);
+ raw_spin_unlock(&watchdog_lock);
}

static inline void clocksource_start_watchdog(void)
@@ -343,16 +343,16 @@ static void clocksource_resume_watchdog(void)
{
unsigned long flags;

- spin_lock_irqsave(&watchdog_lock, flags);
+ raw_spin_lock_irqsave(&watchdog_lock, flags);
clocksource_reset_watchdog();
- spin_unlock_irqrestore(&watchdog_lock, flags);
+ raw_spin_unlock_irqrestore(&watchdog_lock, flags);
}

static void clocksource_enqueue_watchdog(struct clocksource *cs)
{
unsigned long flags;

- spin_lock_irqsave(&watchdog_lock, flags);
+ raw_spin_lock_irqsave(&watchdog_lock, flags);
if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) {
/* cs is a clocksource to be watched. */
list_add(&cs->wd_list, &watchdog_list);
@@ -370,7 +370,7 @@ static void clocksource_enqueue_watchdog(struct clocksource *cs)
}
/* Check if the watchdog timer needs to be started. */
clocksource_start_watchdog();
- spin_unlock_irqrestore(&watchdog_lock, flags);
+ raw_spin_unlock_irqrestore(&watchdog_lock, flags);
}

static void clocksource_dequeue_watchdog(struct clocksource *cs)
@@ -378,7 +378,7 @@ static void clocksource_dequeue_watchdog(struct clocksource *cs)
struct clocksource *tmp;
unsigned long flags;

- spin_lock_irqsave(&watchdog_lock, flags);
+ raw_spin_lock_irqsave(&watchdog_lock, flags);
if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) {
/* cs is a watched clocksource. */
list_del_init(&cs->wd_list);
@@ -397,7 +397,7 @@ static void clocksource_dequeue_watchdog(struct clocksource *cs)
cs->flags &= ~CLOCK_SOURCE_WATCHDOG;
/* Check if the watchdog timer needs to be stopped. */
clocksource_stop_watchdog();
- spin_unlock_irqrestore(&watchdog_lock, flags);
+ raw_spin_unlock_irqrestore(&watchdog_lock, flags);
}

static int clocksource_watchdog_kthread(void *data)
@@ -407,7 +407,7 @@ static int clocksource_watchdog_kthread(void *data)
LIST_HEAD(unstable);

mutex_lock(&clocksource_mutex);
- spin_lock_irqsave(&watchdog_lock, flags);
+ raw_spin_lock_irqsave(&watchdog_lock, flags);
list_for_each_entry_safe(cs, tmp, &watchdog_list, wd_list)
if (cs->flags & CLOCK_SOURCE_UNSTABLE) {
list_del_init(&cs->wd_list);
@@ -415,7 +415,7 @@ static int clocksource_watchdog_kthread(void *data)
}
/* Check if the watchdog timer needs to be stopped. */
clocksource_stop_watchdog();
- spin_unlock_irqrestore(&watchdog_lock, flags);
+ raw_spin_unlock_irqrestore(&watchdog_lock, flags);

/* Needs to be done outside of watchdog lock */
list_for_each_entry_safe(cs, tmp, &unstable, wd_list) {
--
1.6.5.2