Skip to content

Commit 03e0d46

Browse files
committed
watchdog: introduce touch_softlockup_watchdog_sched()
touch_softlockup_watchdog() is used to tell watchdog that scheduler stall is expected. One group of usage is from paths where the task may not be able to yield for a long time such as performing slow PIO to finicky device and coming out of suspend. The other is to account for scheduler and timer going idle. For scheduler softlockup detection, there's no reason to distinguish the two cases; however, workqueue lockup detector is planned and it can use the same signals from the former group while the latter would spuriously prevent detection. This patch introduces a new function touch_softlockup_watchdog_sched() and convert the latter group to call it instead. For now, it just calls touch_softlockup_watchdog() and there's no functional difference. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Ulrich Obergfell <uobergfe@redhat.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Andrew Morton <akpm@linux-foundation.org>
1 parent fca839c commit 03e0d46

4 files changed

Lines changed: 22 additions & 5 deletions

File tree

‎include/linux/sched.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ extern void scheduler_tick(void);
377377
extern void sched_show_task(struct task_struct *p);
378378

379379
#ifdef CONFIG_LOCKUP_DETECTOR
380+
extern void touch_softlockup_watchdog_sched(void);
380381
extern void touch_softlockup_watchdog(void);
381382
extern void touch_softlockup_watchdog_sync(void);
382383
extern void touch_all_softlockup_watchdogs(void);
@@ -387,6 +388,9 @@ extern unsigned int softlockup_panic;
387388
extern unsigned int hardlockup_panic;
388389
void lockup_detector_init(void);
389390
#else
391+
static inline void touch_softlockup_watchdog_sched(void)
392+
{
393+
}
390394
static inline void touch_softlockup_watchdog(void)
391395
{
392396
}

‎kernel/sched/clock.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ void sched_clock_idle_wakeup_event(u64 delta_ns)
354354
return;
355355

356356
sched_clock_tick();
357-
touch_softlockup_watchdog();
357+
touch_softlockup_watchdog_sched();
358358
}
359359
EXPORT_SYMBOL_GPL(sched_clock_idle_wakeup_event);
360360

‎kernel/time/tick-sched.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs)
143143
* when we go busy again does not account too much ticks.
144144
*/
145145
if (ts->tick_stopped) {
146-
touch_softlockup_watchdog();
146+
touch_softlockup_watchdog_sched();
147147
if (is_idle_task(current))
148148
ts->idle_jiffies++;
149149
}
@@ -430,7 +430,7 @@ static void tick_nohz_update_jiffies(ktime_t now)
430430
tick_do_update_jiffies64(now);
431431
local_irq_restore(flags);
432432

433-
touch_softlockup_watchdog();
433+
touch_softlockup_watchdog_sched();
434434
}
435435

436436
/*
@@ -701,7 +701,7 @@ static void tick_nohz_restart_sched_tick(struct tick_sched *ts, ktime_t now)
701701
update_cpu_load_nohz();
702702

703703
calc_load_exit_idle();
704-
touch_softlockup_watchdog();
704+
touch_softlockup_watchdog_sched();
705705
/*
706706
* Cancel the scheduled timer and restore the tick
707707
*/

‎kernel/watchdog.c‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,27 @@ static void __touch_watchdog(void)
225225
__this_cpu_write(watchdog_touch_ts, get_timestamp());
226226
}
227227

228-
void touch_softlockup_watchdog(void)
228+
/**
229+
* touch_softlockup_watchdog_sched - touch watchdog on scheduler stalls
230+
*
231+
* Call when the scheduler may have stalled for legitimate reasons
232+
* preventing the watchdog task from executing - e.g. the scheduler
233+
* entering idle state. This should only be used for scheduler events.
234+
* Use touch_softlockup_watchdog() for everything else.
235+
*/
236+
void touch_softlockup_watchdog_sched(void)
229237
{
230238
/*
231239
* Preemption can be enabled. It doesn't matter which CPU's timestamp
232240
* gets zeroed here, so use the raw_ operation.
233241
*/
234242
raw_cpu_write(watchdog_touch_ts, 0);
235243
}
244+
245+
void touch_softlockup_watchdog(void)
246+
{
247+
touch_softlockup_watchdog_sched();
248+
}
236249
EXPORT_SYMBOL(touch_softlockup_watchdog);
237250

238251
void touch_all_softlockup_watchdogs(void)

0 commit comments

Comments
 (0)