Re: [patch 2/2] nohz: change signal tick dependency to wakeup CPUs of member tasks

From: Peter Zijlstra
Date: Thu Oct 08 2020 - 08:35:52 EST


On Wed, Oct 07, 2020 at 03:01:53PM -0300, Marcelo Tosatti wrote:
> Rather than waking up all nohz_full CPUs on the system, only wakeup
> the target CPUs of member threads of the signal.
>
> Reduces interruptions to nohz_full CPUs.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx>
>
> Index: linux-2.6/kernel/time/tick-sched.c
> ===================================================================
> --- linux-2.6.orig/kernel/time/tick-sched.c
> +++ linux-2.6/kernel/time/tick-sched.c
> @@ -398,7 +398,15 @@ EXPORT_SYMBOL_GPL(tick_nohz_dep_clear_ta
> */
> void tick_nohz_dep_set_signal(struct signal_struct *sig, enum tick_dep_bits bit)
> {
> - tick_nohz_dep_set_all(&sig->tick_dep_mask, bit);
> + int prev;
> +
> + prev = atomic_fetch_or(BIT(bit), &sig->tick_dep_mask);
> + if (!prev) {
> + rcu_read_lock();
> + for_each_thread(sig, t)
> + tick_nohz_kick_task(t);
> + rcu_read_unlock();
> + }
> }

AFAICT, and this makes perfect sense, this function is only ever used
while holding sighand->siglock, which makes the RCU read lock
superfluous.

Would it make sense to change the signal_struct argument to task_struct,
such that we can write:

lockdep_assert_held(&p->sighand->siglock);
for_each_thread(p->signal, t)
tick_nohz_kick_task(t);

?