[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2a72fbf3-a6b7-0621-9671-d06409fe026b@quicinc.com>
Date: Tue, 8 Nov 2022 20:03:57 +0530
From: Mukesh Ojha <quic_mojha@...cinc.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>,
<linux-kernel@...r.kernel.org>
CC: Robert Elliott <elliott@....com>
Subject: Re: [PATCH v5 3/4] sched: Add helper nr_context_switches_cpu()
Hi,
On 11/4/2022 7:41 PM, Zhen Lei wrote:
> Returns the number of context switches on the specified CPU, which can be
> used to diagnose rcu stall.
>
> Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com> > ---
> include/linux/kernel_stat.h | 1 +
> kernel/sched/core.c | 5 +++++
> 2 files changed, 6 insertions(+)
>
> diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
> index 898076e173a928a..9935f7ecbfb9e31 100644
> --- a/include/linux/kernel_stat.h
> +++ b/include/linux/kernel_stat.h
> @@ -52,6 +52,7 @@ DECLARE_PER_CPU(struct kernel_cpustat, kernel_cpustat);
> #define kstat_cpu(cpu) per_cpu(kstat, cpu)
> #define kcpustat_cpu(cpu) per_cpu(kernel_cpustat, cpu)
>
> +extern unsigned long long nr_context_switches_cpu(int cpu);
> extern unsigned long long nr_context_switches(void);
>
> extern unsigned int kstat_irqs_cpu(unsigned int irq, int cpu);
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 5800b0623ff3068..a0d19f67f2046d9 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -5229,6 +5229,11 @@ bool single_task_running(void)
> }
> EXPORT_SYMBOL(single_task_running);
>
> +unsigned long long nr_context_switches_cpu(int cpu)
> +{
> + return cpu_rq(cpu)->nr_switches;
> +}
> +
> unsigned long long nr_context_switches(void)
> {
> int i;
LGTM.
Reviewed-by: Mukesh Ojha <quic_mojha@...cinc.com>
-Mukesh
Powered by blists - more mailing lists