Skip to content

Commit

Permalink
sched: Add helper nr_context_switches_cpu()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Zhen Lei authored and chantra committed Oct 20, 2022
1 parent 8dd6f6f commit 091bef2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/kernel_stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 091bef2

Please sign in to comment.