Skip to content

Commit b11c89a

Browse files
committed
Merge tag 'core-core-2020-01-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull watchdog updates from Thomas Gleixner: "A set of watchdog/softlockup related improvements: - Enforce that the watchdog timestamp is always valid on boot. The original implementation caused a watchdog disabled gap of one second in the boot process due to truncation of the underlying sched clock. The sched clock is divided by 1e9 to convert nanoseconds to seconds. So for the first second of the boot process the result is 0 which is at the same time the indicator to disable the watchdog. The trivial fix is to change the disabled indicator to ULONG_MAX. - Two cleanup patches removing unused and redundant code which got forgotten to be cleaned up in previous changes" * tag 'core-core-2020-01-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: watchdog/softlockup: Enforce that timestamp is valid on boot watchdog/softlockup: Remove obsolete check of last reported task watchdog: Remove soft_lockup_hrtimer_cnt and related code
2 parents a56c41e + 11e31f6 commit b11c89a

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed

kernel/watchdog.c

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ static void lockup_detector_update_enable(void)
161161

162162
#ifdef CONFIG_SOFTLOCKUP_DETECTOR
163163

164+
#define SOFTLOCKUP_RESET ULONG_MAX
165+
164166
/* Global variables, exported for sysctl */
165167
unsigned int __read_mostly softlockup_panic =
166168
CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE;
@@ -173,8 +175,6 @@ static DEFINE_PER_CPU(struct hrtimer, watchdog_hrtimer);
173175
static DEFINE_PER_CPU(bool, softlockup_touch_sync);
174176
static DEFINE_PER_CPU(bool, soft_watchdog_warn);
175177
static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts);
176-
static DEFINE_PER_CPU(unsigned long, soft_lockup_hrtimer_cnt);
177-
static DEFINE_PER_CPU(struct task_struct *, softlockup_task_ptr_saved);
178178
static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts_saved);
179179
static unsigned long soft_lockup_nmi_warn;
180180

@@ -274,7 +274,7 @@ notrace void touch_softlockup_watchdog_sched(void)
274274
* Preemption can be enabled. It doesn't matter which CPU's timestamp
275275
* gets zeroed here, so use the raw_ operation.
276276
*/
277-
raw_cpu_write(watchdog_touch_ts, 0);
277+
raw_cpu_write(watchdog_touch_ts, SOFTLOCKUP_RESET);
278278
}
279279

280280
notrace void touch_softlockup_watchdog(void)
@@ -298,14 +298,14 @@ void touch_all_softlockup_watchdogs(void)
298298
* the softlockup check.
299299
*/
300300
for_each_cpu(cpu, &watchdog_allowed_mask)
301-
per_cpu(watchdog_touch_ts, cpu) = 0;
301+
per_cpu(watchdog_touch_ts, cpu) = SOFTLOCKUP_RESET;
302302
wq_watchdog_touch(-1);
303303
}
304304

305305
void touch_softlockup_watchdog_sync(void)
306306
{
307307
__this_cpu_write(softlockup_touch_sync, true);
308-
__this_cpu_write(watchdog_touch_ts, 0);
308+
__this_cpu_write(watchdog_touch_ts, SOFTLOCKUP_RESET);
309309
}
310310

311311
static int is_softlockup(unsigned long touch_ts)
@@ -350,8 +350,6 @@ static DEFINE_PER_CPU(struct cpu_stop_work, softlockup_stop_work);
350350
*/
351351
static int softlockup_fn(void *data)
352352
{
353-
__this_cpu_write(soft_lockup_hrtimer_cnt,
354-
__this_cpu_read(hrtimer_interrupts));
355353
__touch_watchdog();
356354
complete(this_cpu_ptr(&softlockup_completion));
357355

@@ -383,7 +381,7 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
383381
/* .. and repeat */
384382
hrtimer_forward_now(hrtimer, ns_to_ktime(sample_period));
385383

386-
if (touch_ts == 0) {
384+
if (touch_ts == SOFTLOCKUP_RESET) {
387385
if (unlikely(__this_cpu_read(softlockup_touch_sync))) {
388386
/*
389387
* If the time stamp was touched atomically
@@ -416,22 +414,8 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
416414
return HRTIMER_RESTART;
417415

418416
/* only warn once */
419-
if (__this_cpu_read(soft_watchdog_warn) == true) {
420-
/*
421-
* When multiple processes are causing softlockups the
422-
* softlockup detector only warns on the first one
423-
* because the code relies on a full quiet cycle to
424-
* re-arm. The second process prevents the quiet cycle
425-
* and never gets reported. Use task pointers to detect
426-
* this.
427-
*/
428-
if (__this_cpu_read(softlockup_task_ptr_saved) !=
429-
current) {
430-
__this_cpu_write(soft_watchdog_warn, false);
431-
__touch_watchdog();
432-
}
417+
if (__this_cpu_read(soft_watchdog_warn) == true)
433418
return HRTIMER_RESTART;
434-
}
435419

436420
if (softlockup_all_cpu_backtrace) {
437421
/* Prevent multiple soft-lockup reports if one cpu is already
@@ -447,7 +431,6 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
447431
pr_emerg("BUG: soft lockup - CPU#%d stuck for %us! [%s:%d]\n",
448432
smp_processor_id(), duration,
449433
current->comm, task_pid_nr(current));
450-
__this_cpu_write(softlockup_task_ptr_saved, current);
451434
print_modules();
452435
print_irqtrace_events(current);
453436
if (regs)

0 commit comments

Comments
 (0)