Re: [RFC PATCH 2/3] softirq: implement interrupt flood detection

From: Peter Zijlstra
Date: Wed Dec 18 2019 - 07:30:05 EST


On Wed, Dec 18, 2019 at 11:49:41AM +0100, Peter Zijlstra wrote:
>
> _If_ you want to do something like this, do it like the below. That only
> adds a few instruction to irq_exit() and only touches a cacheline that's
> already touched.
>
> It computes both the avg duration and the avg inter-arrival-time of
> hardirqs. Things get critical when:
>
> inter-arrival-avg < 2*duration-avg
>
> or something like that.

Better yet, try something like:

bool cpu_irq_heavy(int cpu)
{
return cpu_util_irq(cpu_rq(cpu)) >= arch_scale_cpu_capacity(cpu);
}