sched: Add helper kstat_cpu_softirqs_sum()
authorZhen Lei <thunder.leizhen@huawei.com>
Sat, 19 Nov 2022 09:25:04 +0000 (17:25 +0800)
committerPaul E. McKenney <paulmck@kernel.org>
Thu, 5 Jan 2023 20:19:56 +0000 (12:19 -0800)
Add a kstat_cpu_softirqs_sum() function that is similar to
kstat_cpu_irqs_sum(), but which counts software interrupts since boot
on the specified CPU.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Cc: Josh Don <joshdon@google.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
include/linux/kernel_stat.h

index 90e2fdc17d79ff824ff430519bd0710b581b19bd..898076e173a928adc2606466aaf2029ae0c0688b 100644 (file)
@@ -67,6 +67,17 @@ static inline unsigned int kstat_softirqs_cpu(unsigned int irq, int cpu)
        return kstat_cpu(cpu).softirqs[irq];
 }
 
+static inline unsigned int kstat_cpu_softirqs_sum(int cpu)
+{
+       int i;
+       unsigned int sum = 0;
+
+       for (i = 0; i < NR_SOFTIRQS; i++)
+               sum += kstat_softirqs_cpu(i, cpu);
+
+       return sum;
+}
+
 /*
  * Number of interrupts per specific IRQ source, since bootup
  */