[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <MW5PR84MB18423C3F30D3F789EB48D0A5AB339@MW5PR84MB1842.NAMPRD84.PROD.OUTLOOK.COM>
Date: Thu, 27 Oct 2022 19:04:53 +0000
From: "Elliott, Robert (Servers)" <elliott@....com>
To: Zhen Lei <thunder.leizhen@...wei.com>,
"Paul E . McKenney" <paulmck@...nel.org>,
Frederic Weisbecker <frederic@...nel.org>,
"Neeraj Upadhyay" <quic_neeraju@...cinc.com>,
Josh Triplett <josh@...htriplett.org>,
Steven Rostedt <rostedt@...dmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Lai Jiangshan <jiangshanlai@...il.com>,
Joel Fernandes <joel@...lfernandes.org>,
"rcu@...r.kernel.org" <rcu@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v2 1/3] sched: Add helper kstat_cpu_softirqs_sum()
> Similar to kstat_cpu_irqs_sum(), it counts the sum of all software
> interrupts on a specified CPU.
>
> diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
> @@ -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;
> +}
In the function upon which this is based:
irqs_sumstruct kernel_stat {
unsigned long irqs_sum;
unsigned int softirqs[NR_SOFTIRQS];
};
static inline unsigned int kstat_cpu_irqs_sum(unsigned int cpu)
{
return kstat_cpu(cpu).irqs_sum;
}
kstat_cpu_irqs_sum returns an unsigned long as an unsigned int, which
could cause large values to be truncated. Should that return
unsigned long? The only existing caller is fs/proc/stat.c which
puts it into a u64:
u64 sum = 0;
...
sum += kstat_cpu_irqs_sum(i);
The softirqs field is an unsigned int, so the new function doesn't have
this inconsistency.
Powered by blists - more mailing lists