Skip to content

Commit 7197e77

Browse files
Peter ZijlstraKAGA-KOKO
authored andcommitted
clocksource: Remove kthread
The clocksource watchdog uses a work to spawn a kthread to run the watchdog. That is about as silly as it sounds, run the watchdog directly from the work. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Cc: len.brown@intel.com Cc: rjw@rjwysocki.net Cc: diego.viola@gmail.com Cc: rui.zhang@intel.com Link: https://lkml.kernel.org/r/20180430100344.713862818@infradead.org
1 parent 604a98f commit 7197e77

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

kernel/time/clocksource.c

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -129,31 +129,19 @@ static void inline clocksource_watchdog_unlock(unsigned long *flags)
129129
spin_unlock_irqrestore(&watchdog_lock, *flags);
130130
}
131131

132-
static int clocksource_watchdog_kthread(void *data);
133-
static void __clocksource_change_rating(struct clocksource *cs, int rating);
134-
135132
/*
136133
* Interval: 0.5sec Threshold: 0.0625s
137134
*/
138135
#define WATCHDOG_INTERVAL (HZ >> 1)
139136
#define WATCHDOG_THRESHOLD (NSEC_PER_SEC >> 4)
140137

141-
static void clocksource_watchdog_work(struct work_struct *work)
142-
{
143-
/*
144-
* If kthread_run fails the next watchdog scan over the
145-
* watchdog_list will find the unstable clock again.
146-
*/
147-
kthread_run(clocksource_watchdog_kthread, NULL, "kwatchdog");
148-
}
149-
150138
static void __clocksource_unstable(struct clocksource *cs)
151139
{
152140
cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG);
153141
cs->flags |= CLOCK_SOURCE_UNSTABLE;
154142

155143
/*
156-
* If the clocksource is registered clocksource_watchdog_kthread() will
144+
* If the clocksource is registered clocksource_watchdog_work() will
157145
* re-rate and re-select.
158146
*/
159147
if (list_empty(&cs->list)) {
@@ -164,7 +152,7 @@ static void __clocksource_unstable(struct clocksource *cs)
164152
if (cs->mark_unstable)
165153
cs->mark_unstable(cs);
166154

167-
/* kick clocksource_watchdog_kthread() */
155+
/* kick clocksource_watchdog_work() */
168156
if (finished_booting)
169157
schedule_work(&watchdog_work);
170158
}
@@ -174,7 +162,7 @@ static void __clocksource_unstable(struct clocksource *cs)
174162
* @cs: clocksource to be marked unstable
175163
*
176164
* This function is called by the x86 TSC code to mark clocksources as unstable;
177-
* it defers demotion and re-selection to a kthread.
165+
* it defers demotion and re-selection to a work.
178166
*/
179167
void clocksource_mark_unstable(struct clocksource *cs)
180168
{
@@ -399,7 +387,9 @@ static void clocksource_dequeue_watchdog(struct clocksource *cs)
399387
}
400388
}
401389

402-
static int __clocksource_watchdog_kthread(void)
390+
static void __clocksource_change_rating(struct clocksource *cs, int rating);
391+
392+
static int __clocksource_watchdog_work(void)
403393
{
404394
struct clocksource *cs, *tmp;
405395
unsigned long flags;
@@ -424,13 +414,12 @@ static int __clocksource_watchdog_kthread(void)
424414
return select;
425415
}
426416

427-
static int clocksource_watchdog_kthread(void *data)
417+
static void clocksource_watchdog_work(struct work_struct *work)
428418
{
429419
mutex_lock(&clocksource_mutex);
430-
if (__clocksource_watchdog_kthread())
420+
if (__clocksource_watchdog_work())
431421
clocksource_select();
432422
mutex_unlock(&clocksource_mutex);
433-
return 0;
434423
}
435424

436425
static bool clocksource_is_watchdog(struct clocksource *cs)
@@ -449,7 +438,7 @@ static void clocksource_enqueue_watchdog(struct clocksource *cs)
449438
static void clocksource_select_watchdog(bool fallback) { }
450439
static inline void clocksource_dequeue_watchdog(struct clocksource *cs) { }
451440
static inline void clocksource_resume_watchdog(void) { }
452-
static inline int __clocksource_watchdog_kthread(void) { return 0; }
441+
static inline int __clocksource_watchdog_work(void) { return 0; }
453442
static bool clocksource_is_watchdog(struct clocksource *cs) { return false; }
454443
void clocksource_mark_unstable(struct clocksource *cs) { }
455444

@@ -683,7 +672,7 @@ static int __init clocksource_done_booting(void)
683672
/*
684673
* Run the watchdog first to eliminate unstable clock sources
685674
*/
686-
__clocksource_watchdog_kthread();
675+
__clocksource_watchdog_work();
687676
clocksource_select();
688677
mutex_unlock(&clocksource_mutex);
689678
return 0;

0 commit comments

Comments
 (0)