Skip to content

Commit 7c18272

Browse files
Zhen Leipaulmckrcu
authored andcommitted
sched: Add helper nr_context_switches_cpu()
Add a function nr_context_switches_cpu() that returns number of context switches since boot on the specified CPU. This information will be used to diagnose RCU CPU stalls. Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Juri Lelli <juri.lelli@redhat.com> Cc: Vincent Guittot <vincent.guittot@linaro.org> Cc: Dietmar Eggemann <dietmar.eggemann@arm.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Ben Segall <bsegall@google.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Daniel Bristot de Oliveira <bristot@redhat.com> Cc: Valentin Schneider <vschneid@redhat.com> Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent 3ca0a6e commit 7c18272

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

include/linux/kernel_stat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ DECLARE_PER_CPU(struct kernel_cpustat, kernel_cpustat);
5252
#define kstat_cpu(cpu) per_cpu(kstat, cpu)
5353
#define kcpustat_cpu(cpu) per_cpu(kernel_cpustat, cpu)
5454

55+
extern unsigned long long nr_context_switches_cpu(int cpu);
5556
extern unsigned long long nr_context_switches(void);
5657

5758
extern unsigned int kstat_irqs_cpu(unsigned int irq, int cpu);

kernel/sched/core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5282,6 +5282,11 @@ bool single_task_running(void)
52825282
}
52835283
EXPORT_SYMBOL(single_task_running);
52845284

5285+
unsigned long long nr_context_switches_cpu(int cpu)
5286+
{
5287+
return cpu_rq(cpu)->nr_switches;
5288+
}
5289+
52855290
unsigned long long nr_context_switches(void)
52865291
{
52875292
int i;

0 commit comments

Comments
 (0)