This patch add nr_running_cpu() function to get current number of running threads of each core.
Signed-off-by: Chanwoo Choi <[email protected]> --- include/linux/sched.h | 1 + kernel/sched/core.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 178a8d9..98b7917 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -99,6 +99,7 @@ extern int nr_threads; DECLARE_PER_CPU(unsigned long, process_counts); extern int nr_processes(void); extern unsigned long nr_running(void); +extern unsigned long nr_running_cpu(int cpu); extern unsigned long nr_iowait(void); extern unsigned long nr_iowait_cpu(int cpu); extern unsigned long this_cpu_load(void); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 58453b8..4052dc8 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2014,7 +2014,7 @@ context_switch(struct rq *rq, struct task_struct *prev, } /* - * nr_running and nr_context_switches: + * nr_running, nr_running_cpu and nr_context_switches: * * externally visible scheduler statistics: current number of runnable * threads, total number of context switches performed since bootup. @@ -2029,6 +2029,12 @@ unsigned long nr_running(void) return sum; } +unsigned long nr_running_cpu(int cpu) +{ + struct rq *this = cpu_rq(cpu); + return this->nr_running; +} + unsigned long long nr_context_switches(void) { int i; -- 1.8.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

