public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched: Add nr_running_cpu() to get current of running threads of each core
@ 2013-05-13  8:33 Chanwoo Choi
  2013-05-13  8:59 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Chanwoo Choi @ 2013-05-13  8:33 UTC (permalink / raw)
  To: mingo, peterz; +Cc: linux-kernel, myungjoo.ham, kyungmin.park, cw00.choi

This patch add nr_running_cpu() function to get current
number of running threads of each core.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched: Add nr_running_cpu() to get current of running threads of each core
  2013-05-13  8:33 [PATCH] sched: Add nr_running_cpu() to get current of running threads of each core Chanwoo Choi
@ 2013-05-13  8:59 ` Peter Zijlstra
  2013-05-14  5:39   ` Chanwoo Choi
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2013-05-13  8:59 UTC (permalink / raw)
  To: Chanwoo Choi; +Cc: mingo, linux-kernel, myungjoo.ham, kyungmin.park

On Mon, May 13, 2013 at 05:33:12PM +0900, Chanwoo Choi wrote:
> This patch add nr_running_cpu() function to get current
> number of running threads of each core.
> 

Uhm, not without a very good reason. 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched: Add nr_running_cpu() to get current of running threads of each core
  2013-05-13  8:59 ` Peter Zijlstra
@ 2013-05-14  5:39   ` Chanwoo Choi
  0 siblings, 0 replies; 3+ messages in thread
From: Chanwoo Choi @ 2013-05-14  5:39 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: mingo, linux-kernel, myungjoo.ham, kyungmin.park

On 05/13/2013 05:59 PM, Peter Zijlstra wrote:
> On Mon, May 13, 2013 at 05:33:12PM +0900, Chanwoo Choi wrote:
>> This patch add nr_running_cpu() function to get current
>> number of running threads of each core.
>>
> Uhm, not without a very good reason. 
>
I am implementing the cpu hotplug policy for reducing
power-consumption in user-space. The cpu hotplug policy
need specific information of each core to know correct
state of each core through specific kernel node like as /proc/sched_stats.
So, I sent only this patch but I didn't send other patchset
because other patch aren't designed according to the kernel
mainline style.

When I develop patchset, I will resend patchset which get
the information of each core for cpu hotplug in user-space.

Thanks,
Chanwoo Choi


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-14  5:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-13  8:33 [PATCH] sched: Add nr_running_cpu() to get current of running threads of each core Chanwoo Choi
2013-05-13  8:59 ` Peter Zijlstra
2013-05-14  5:39   ` Chanwoo Choi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox