Re: [PATCH 03/12] task_isolation: userspace hard isolation from kernel

From: Frederic Weisbecker
Date: Fri Mar 06 2020 - 11:00:41 EST


On Wed, Mar 04, 2020 at 04:07:12PM +0000, Alex Belits wrote:
> +#ifdef CONFIG_TASK_ISOLATION
> +int try_stop_full_tick(void)
> +{
> + int cpu = smp_processor_id();
> + struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
> +
> + /* For an unstable clock, we should return a permanent error code. */
> + if (atomic_read(&tick_dep_mask) & TICK_DEP_MASK_CLOCK_UNSTABLE)
> + return -EINVAL;
> +
> + if (!can_stop_full_tick(cpu, ts))
> + return -EAGAIN;

Note that the stop_tick naming in nohz can be misleading. It means
we actually leave the periodic mode and we enter in dynamic tick mode.

In practice it means that the tick is delayed until the next event, which
in the worst case may well be in 1 ms and in the best case never. So what
you probably want to check instead is whether the tick has been entirely
stopped (ie: we called hrtimer_cancel(&ts->sched_timer)).

Thanks.

> +
> + tick_nohz_stop_sched_tick(ts, cpu);
> + return 0;
> +}
> +#endif
> +
> static bool can_stop_idle_tick(int cpu, struct tick_sched *ts)
> {
> /*
> --
> 2.20.1
>