Re: [patch 1/2] nohz: try to avoid IPI when configuring per-CPU posix timer

From: Frederic Weisbecker
Date: Tue Sep 01 2020 - 19:39:06 EST


On Tue, Aug 25, 2020 at 03:41:48PM -0300, Marcelo Tosatti wrote:
> When enabling per-CPU posix timers, an IPI to nohz_full CPUs might be
> performed (to re-read the dependencies and possibly not re-enter
> nohz_full on a given CPU).
>
> A common case is for applications that run on nohz_full= CPUs
> to not use POSIX timers (eg DPDK). This patch skips the IPI
> in case the task allowed mask does not intersect with nohz_full= CPU mask,
> when going through tick_nohz_dep_set_signal.
>
> This reduces interruptions to nohz_full= CPUs.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx>
[...]
> /*
> + * Set bit on nohz full dependency, kicking all cpus
> + * only if task can run on nohz full CPUs.
> + */
> +static void tick_nohz_dep_set_all_cond(struct task_struct *tsk,
> + atomic_t *dep,
> + enum tick_dep_bits bit)
> +{
> + int prev;
> + unsigned long flags;
> +
> + prev = atomic_fetch_or(BIT(bit), dep);
> + if (prev)
> + return;
> +
> + raw_spin_lock_irqsave(&tsk->pi_lock, flags);
> + if (cpumask_intersects(&tsk->cpus_mask, tick_nohz_full_mask))
> + tick_nohz_full_kick_all();

So that's for one task but what about the other threads in that
process? We are setting the tick dependency on all tasks sharing that
struct signal.

Thanks.

> + raw_spin_unlock_irqrestore(&tsk->pi_lock, flags);
> +}
> +