Skip to content

Commit e8d4d4d

Browse files
Zhen Leichantra
authored andcommitted
sched: Add helper nr_context_switches_cpu()
Returns the number of context switches on the specified CPU, which can be used to diagnose rcu stall. Signed-off-by: Zhen Lei <[email protected]>
1 parent 9f1c63d commit e8d4d4d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

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
@@ -5229,6 +5229,11 @@ bool single_task_running(void)
52295229
}
52305230
EXPORT_SYMBOL(single_task_running);
52315231

5232+
unsigned long long nr_context_switches_cpu(int cpu)
5233+
{
5234+
return cpu_rq(cpu)->nr_switches;
5235+
}
5236+
52325237
unsigned long long nr_context_switches(void)
52335238
{
52345239
int i;

0 commit comments

Comments
 (0)