mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mukesh Ojha <quic_mojha@quicinc.com>
To: Zhen Lei <thunder.leizhen@huawei.com>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Frederic Weisbecker <frederic@kernel.org>,
	"Neeraj Upadhyay" <quic_neeraju@quicinc.com>,
	Josh Triplett <josh@joshtriplett.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Joel Fernandes <joel@joelfernandes.org>, <rcu@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Cc: Robert Elliott <elliott@hpe.com>
Subject: Re: [PATCH v5 3/4] sched: Add helper nr_context_switches_cpu()
Date: Tue, 8 Nov 2022 20:03:57 +0530	[thread overview]
Message-ID: <2a72fbf3-a6b7-0621-9671-d06409fe026b@quicinc.com> (raw)
In-Reply-To: <20221104141118.119-4-thunder.leizhen@huawei.com>

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@huawei.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@quicinc.com>

-Mukesh

  reply	other threads:[~2022-11-08 14:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04 14:11 [PATCH v5 0/4] rcu: Add RCU stall diagnosis information Zhen Lei
2022-11-04 14:11 ` [PATCH v5 1/4] genirq: Fix the return type of kstat_cpu_irqs_sum() Zhen Lei
2022-11-08 14:22   ` Mukesh Ojha
2022-11-04 14:11 ` [PATCH v5 2/4] sched: Add helper kstat_cpu_softirqs_sum() Zhen Lei
2022-11-08 14:30   ` Mukesh Ojha
2022-11-08 18:21     ` Paul E. McKenney
2022-11-04 14:11 ` [PATCH v5 3/4] sched: Add helper nr_context_switches_cpu() Zhen Lei
2022-11-08 14:33   ` Mukesh Ojha [this message]
2022-11-04 14:11 ` [PATCH v5 4/4] rcu: Add RCU stall diagnosis information Zhen Lei
2022-11-08 14:51   ` Mukesh Ojha
2022-11-08 18:19     ` Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a72fbf3-a6b7-0621-9671-d06409fe026b@quicinc.com \
    --to=quic_mojha@quicinc.com \
    --cc=elliott@hpe.com \
    --cc=frederic@kernel.org \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=paulmck@kernel.org \
    --cc=quic_neeraju@quicinc.com \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=thunder.leizhen@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®