Re: [PATCH v2 1/1] sched: watchdog: Touch kernel watchdog with sched count

From: Peter Zijlstra
Date: Wed Oct 21 2020 - 06:13:12 EST


On Tue, Oct 20, 2020 at 01:57:04PM -0700, Xi Wang wrote:

> + if (watchdog_touch_with_sched) {
> + /* Trigger reschedule for the next round */
> + set_tsk_need_resched(current);
> + set_preempt_need_resched();

Blergh.. that's gross. This relies on this being in IRQ context and
either: PREEMPT=y *OR* this always being from userspace. Otherwise
there's no guarantee the return-from-interrupt will actually schedule.

> + /* sched_count increase in __schedule is taken as watchdog touched */
> + if (sched_get_count(smp_processor_id()) -
> + __this_cpu_read(watchdog_sched_prev)) {
> + __touch_watchdog();
> + __this_cpu_write(soft_watchdog_warn, false);
> + return HRTIMER_RESTART;
> + }
> + }
> +
> /* check for a softlockup
> * This is done by making sure a high priority task is
> * being scheduled. The task touches the watchdog to
> --
> 2.29.0.rc1.297.gfa9743e501-goog
>