* [PATCH v2 0/2] Clean up schedstat and task delay acct config options
@ 2015-06-25 18:23 Naveen N. Rao
2015-06-25 18:23 ` [PATCH v2 1/2] schedstat: Simplify sched_info accounting dependency Naveen N. Rao
2015-06-25 18:23 ` [PATCH v2 2/2] schedstat: Expose /proc/pid/schedstat if CONFIG_SCHED_INFO is set Naveen N. Rao
0 siblings, 2 replies; 14+ messages in thread
From: Naveen N. Rao @ 2015-06-25 18:23 UTC (permalink / raw)
To: bsingharora, mingo; +Cc: linux-kernel, srikar, ricklind, a.p.zijlstra
Further to the earlier discussion [1], this patch set introduces CONFIG_SCHED_INFO for the common code associated with CONFIG_SCHEDSTATS and CONFIG_TASK_DELAY_ACCT. Further, /proc/<pid>/schedstat is now exposed if either of these is enabled.
[1] http://thread.gmane.org/gmane.linux.kernel/1961707
- Naveen
Naveen N. Rao (2):
schedstat: Simplify sched_info accounting dependency
schedstat: Expose /proc/pid/schedstat if CONFIG_SCHED_INFO is set
fs/proc/base.c | 11 +++++++----
include/linux/sched.h | 6 +++---
init/Kconfig | 1 +
kernel/sched/core.c | 2 +-
kernel/sched/stats.h | 4 ++--
lib/Kconfig.debug | 5 +++++
6 files changed, 19 insertions(+), 10 deletions(-)
--
2.4.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 1/2] schedstat: Simplify sched_info accounting dependency
2015-06-25 18:23 [PATCH v2 0/2] Clean up schedstat and task delay acct config options Naveen N. Rao
@ 2015-06-25 18:23 ` Naveen N. Rao
2015-06-30 13:30 ` Srikar Dronamraju
` (2 more replies)
2015-06-25 18:23 ` [PATCH v2 2/2] schedstat: Expose /proc/pid/schedstat if CONFIG_SCHED_INFO is set Naveen N. Rao
1 sibling, 3 replies; 14+ messages in thread
From: Naveen N. Rao @ 2015-06-25 18:23 UTC (permalink / raw)
To: bsingharora, mingo; +Cc: linux-kernel, srikar, ricklind, a.p.zijlstra
Both CONFIG_SCHEDSTATS and CONFIG_TASK_DELAY_ACCT track task sched_info.
Simplify by introducing a common CONFIG_SCHED_INFO selected by both.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
include/linux/sched.h | 6 +++---
init/Kconfig | 1 +
kernel/sched/core.c | 2 +-
kernel/sched/stats.h | 4 ++--
lib/Kconfig.debug | 5 +++++
5 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 6633e83..9bf4bc0 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -849,7 +849,7 @@ extern struct user_struct root_user;
struct backing_dev_info;
struct reclaim_state;
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_SCHED_INFO
struct sched_info {
/* cumulative counters */
unsigned long pcount; /* # of times run on this cpu */
@@ -859,7 +859,7 @@ struct sched_info {
unsigned long long last_arrival,/* when we last ran on a cpu */
last_queued; /* when we were last queued to run */
};
-#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
+#endif /* CONFIG_SCHED_INFO */
#ifdef CONFIG_TASK_DELAY_ACCT
struct task_delay_info {
@@ -1408,7 +1408,7 @@ struct task_struct {
int rcu_tasks_idle_cpu;
#endif /* #ifdef CONFIG_TASKS_RCU */
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_SCHED_INFO
struct sched_info sched_info;
#endif
diff --git a/init/Kconfig b/init/Kconfig
index b999fa3..12cb556 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -435,6 +435,7 @@ config TASKSTATS
config TASK_DELAY_ACCT
bool "Enable per-task delay accounting"
depends on TASKSTATS
+ select SCHED_INFO
help
Collect information on time spent by a task waiting for system
resources like cpu, synchronous block I/O completion and swapping
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b803e1b..5caa029 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2164,7 +2164,7 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
set_task_cpu(p, cpu);
raw_spin_unlock_irqrestore(&p->pi_lock, flags);
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_SCHED_INFO
if (likely(sched_info_on()))
memset(&p->sched_info, 0, sizeof(p->sched_info));
#endif
diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h
index 077ebbd..b0fbc76 100644
--- a/kernel/sched/stats.h
+++ b/kernel/sched/stats.h
@@ -47,7 +47,7 @@ rq_sched_info_depart(struct rq *rq, unsigned long long delta)
# define schedstat_set(var, val) do { } while (0)
#endif
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_SCHED_INFO
static inline void sched_info_reset_dequeued(struct task_struct *t)
{
t->sched_info.last_queued = 0;
@@ -156,7 +156,7 @@ sched_info_switch(struct rq *rq,
#define sched_info_depart(rq, t) do { } while (0)
#define sched_info_arrive(rq, next) do { } while (0)
#define sched_info_switch(rq, t, next) do { } while (0)
-#endif /* CONFIG_SCHEDSTATS || CONFIG_TASK_DELAY_ACCT */
+#endif /* CONFIG_SCHED_INFO */
/*
* The following are functions that support scheduler-internal time accounting.
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index b908048..e2894b2 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -841,9 +841,14 @@ config SCHED_DEBUG
that can help debug the scheduler. The runtime overhead of this
option is minimal.
+config SCHED_INFO
+ bool
+ default n
+
config SCHEDSTATS
bool "Collect scheduler statistics"
depends on DEBUG_KERNEL && PROC_FS
+ select SCHED_INFO
help
If you say Y here, additional code will be inserted into the
scheduler and related routines to collect statistics about
--
2.4.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2 2/2] schedstat: Expose /proc/pid/schedstat if CONFIG_SCHED_INFO is set
2015-06-25 18:23 [PATCH v2 0/2] Clean up schedstat and task delay acct config options Naveen N. Rao
2015-06-25 18:23 ` [PATCH v2 1/2] schedstat: Simplify sched_info accounting dependency Naveen N. Rao
@ 2015-06-25 18:23 ` Naveen N. Rao
2015-06-30 5:55 ` Srikar Dronamraju
1 sibling, 1 reply; 14+ messages in thread
From: Naveen N. Rao @ 2015-06-25 18:23 UTC (permalink / raw)
To: bsingharora, mingo; +Cc: linux-kernel, srikar, ricklind, a.p.zijlstra
In the unlikely scenario that the kernel is booted with nodelayacct, we
dump all zeroes so as to make it clear that scheduler statistics are not
available.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
fs/proc/base.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 286a422..a299131 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -304,14 +304,17 @@ static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns,
}
#endif
-#ifdef CONFIG_SCHEDSTATS
+#ifdef CONFIG_SCHED_INFO
/*
* Provides /proc/PID/schedstat
*/
static int proc_pid_schedstat(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *task)
{
- seq_printf(m, "%llu %llu %lu\n",
+ if (unlikely(!sched_info_on()))
+ seq_printf(m, "0 0 0\n");
+ else
+ seq_printf(m, "%llu %lld %ld\n",
(unsigned long long)task->se.sum_exec_runtime,
(unsigned long long)task->sched_info.run_delay,
task->sched_info.pcount);
@@ -2600,7 +2603,7 @@ static const struct pid_entry tgid_base_stuff[] = {
#ifdef CONFIG_STACKTRACE
ONE("stack", S_IRUSR, proc_pid_stack),
#endif
-#ifdef CONFIG_SCHEDSTATS
+#ifdef CONFIG_SCHED_INFO
ONE("schedstat", S_IRUGO, proc_pid_schedstat),
#endif
#ifdef CONFIG_LATENCYTOP
@@ -2948,7 +2951,7 @@ static const struct pid_entry tid_base_stuff[] = {
#ifdef CONFIG_STACKTRACE
ONE("stack", S_IRUSR, proc_pid_stack),
#endif
-#ifdef CONFIG_SCHEDSTATS
+#ifdef CONFIG_SCHED_INFO
ONE("schedstat", S_IRUGO, proc_pid_schedstat),
#endif
#ifdef CONFIG_LATENCYTOP
--
2.4.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2 2/2] schedstat: Expose /proc/pid/schedstat if CONFIG_SCHED_INFO is set
2015-06-25 18:23 ` [PATCH v2 2/2] schedstat: Expose /proc/pid/schedstat if CONFIG_SCHED_INFO is set Naveen N. Rao
@ 2015-06-30 5:55 ` Srikar Dronamraju
2015-06-30 6:16 ` Naveen N. Rao
2015-06-30 9:06 ` [PATCH v3 " Naveen N. Rao
0 siblings, 2 replies; 14+ messages in thread
From: Srikar Dronamraju @ 2015-06-30 5:55 UTC (permalink / raw)
To: Naveen N. Rao; +Cc: bsingharora, mingo, linux-kernel, ricklind, a.p.zijlstra
* Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> [2015-06-25 23:53:38]:
> /*
> * Provides /proc/PID/schedstat
> */
> static int proc_pid_schedstat(struct seq_file *m, struct pid_namespace *ns,
> struct pid *pid, struct task_struct *task)
> {
> - seq_printf(m, "%llu %llu %lu\n",
> + if (unlikely(!sched_info_on()))
> + seq_printf(m, "0 0 0\n");
> + else
> + seq_printf(m, "%llu %lld %ld\n",
Should the above be seq_printf(m, "%llu %llu %lu\n", ?
> (unsigned long long)task->se.sum_exec_runtime,
> (unsigned long long)task->sched_info.run_delay,
> task->sched_info.pcount);
> --
> 2.4.0
>
--
Thanks and Regards
Srikar Dronamraju
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 2/2] schedstat: Expose /proc/pid/schedstat if CONFIG_SCHED_INFO is set
2015-06-30 5:55 ` Srikar Dronamraju
@ 2015-06-30 6:16 ` Naveen N. Rao
2015-06-30 9:06 ` [PATCH v3 " Naveen N. Rao
1 sibling, 0 replies; 14+ messages in thread
From: Naveen N. Rao @ 2015-06-30 6:16 UTC (permalink / raw)
To: Srikar Dronamraju
Cc: bsingharora, mingo, linux-kernel, ricklind, a.p.zijlstra
On 2015/06/30 11:25AM, Srikar Dronamraju wrote:
> * Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> [2015-06-25 23:53:38]:
>
> > /*
> > * Provides /proc/PID/schedstat
> > */
> > static int proc_pid_schedstat(struct seq_file *m, struct pid_namespace *ns,
> > struct pid *pid, struct task_struct *task)
> > {
> > - seq_printf(m, "%llu %llu %lu\n",
> > + if (unlikely(!sched_info_on()))
> > + seq_printf(m, "0 0 0\n");
> > + else
> > + seq_printf(m, "%llu %lld %ld\n",
>
> Should the above be seq_printf(m, "%llu %llu %lu\n", ?
Yikes! Nice catch, thanks! This looks to be left over from my tests with
returning -1. Fixed patch on the way...
Regards,
Naveen
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 2/2] schedstat: Expose /proc/pid/schedstat if CONFIG_SCHED_INFO is set
2015-06-30 5:55 ` Srikar Dronamraju
2015-06-30 6:16 ` Naveen N. Rao
@ 2015-06-30 9:06 ` Naveen N. Rao
2015-06-30 13:29 ` Srikar Dronamraju
` (2 more replies)
1 sibling, 3 replies; 14+ messages in thread
From: Naveen N. Rao @ 2015-06-30 9:06 UTC (permalink / raw)
To: bsingharora, mingo; +Cc: linux-kernel, srikar, ricklind, a.p.zijlstra
In the unlikely scenario that the kernel is booted with nodelayacct, we
dump all zeroes so as to make it clear that scheduler statistics are not
available.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
Changes since v2: Revert to unsigned long in printf
fs/proc/base.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 286a422..ad63fa3 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -304,14 +304,17 @@ static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns,
}
#endif
-#ifdef CONFIG_SCHEDSTATS
+#ifdef CONFIG_SCHED_INFO
/*
* Provides /proc/PID/schedstat
*/
static int proc_pid_schedstat(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *task)
{
- seq_printf(m, "%llu %llu %lu\n",
+ if (unlikely(!sched_info_on()))
+ seq_printf(m, "0 0 0\n");
+ else
+ seq_printf(m, "%llu %llu %lu\n",
(unsigned long long)task->se.sum_exec_runtime,
(unsigned long long)task->sched_info.run_delay,
task->sched_info.pcount);
@@ -2600,7 +2603,7 @@ static const struct pid_entry tgid_base_stuff[] = {
#ifdef CONFIG_STACKTRACE
ONE("stack", S_IRUSR, proc_pid_stack),
#endif
-#ifdef CONFIG_SCHEDSTATS
+#ifdef CONFIG_SCHED_INFO
ONE("schedstat", S_IRUGO, proc_pid_schedstat),
#endif
#ifdef CONFIG_LATENCYTOP
@@ -2948,7 +2951,7 @@ static const struct pid_entry tid_base_stuff[] = {
#ifdef CONFIG_STACKTRACE
ONE("stack", S_IRUSR, proc_pid_stack),
#endif
-#ifdef CONFIG_SCHEDSTATS
+#ifdef CONFIG_SCHED_INFO
ONE("schedstat", S_IRUGO, proc_pid_schedstat),
#endif
#ifdef CONFIG_LATENCYTOP
--
2.4.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v3 2/2] schedstat: Expose /proc/pid/schedstat if CONFIG_SCHED_INFO is set
2015-06-30 9:06 ` [PATCH v3 " Naveen N. Rao
@ 2015-06-30 13:29 ` Srikar Dronamraju
2015-06-30 13:32 ` Balbir Singh
2015-07-03 7:46 ` [tip:sched/urgent] sched/stat: Expose /proc/pid/ schedstat if CONFIG_SCHED_INFO=y tip-bot for Naveen N. Rao
2015-07-04 8:07 ` tip-bot for Naveen N. Rao
2 siblings, 1 reply; 14+ messages in thread
From: Srikar Dronamraju @ 2015-06-30 13:29 UTC (permalink / raw)
To: Naveen N. Rao; +Cc: bsingharora, mingo, linux-kernel, ricklind, a.p.zijlstra
* Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> [2015-06-30 14:36:03]:
> In the unlikely scenario that the kernel is booted with nodelayacct, we
> dump all zeroes so as to make it clear that scheduler statistics are not
> available.
>
> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> ---
> Changes since v2: Revert to unsigned long in printf
>
Looks good to me.
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
--
Thanks and Regards
Srikar Dronamraju
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] schedstat: Simplify sched_info accounting dependency
2015-06-25 18:23 ` [PATCH v2 1/2] schedstat: Simplify sched_info accounting dependency Naveen N. Rao
@ 2015-06-30 13:30 ` Srikar Dronamraju
2015-06-30 13:33 ` Balbir Singh
2015-07-03 7:45 ` [tip:sched/urgent] sched/stat: Simplify the " tip-bot for Naveen N. Rao
2015-07-04 8:07 ` tip-bot for Naveen N. Rao
2 siblings, 1 reply; 14+ messages in thread
From: Srikar Dronamraju @ 2015-06-30 13:30 UTC (permalink / raw)
To: Naveen N. Rao; +Cc: bsingharora, mingo, linux-kernel, ricklind, a.p.zijlstra
* Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> [2015-06-25 23:53:37]:
> Both CONFIG_SCHEDSTATS and CONFIG_TASK_DELAY_ACCT track task sched_info.
> Simplify by introducing a common CONFIG_SCHED_INFO selected by both.
>
> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> ---
Looks good to me.
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
--
Thanks and Regards
Srikar Dronamraju
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 2/2] schedstat: Expose /proc/pid/schedstat if CONFIG_SCHED_INFO is set
2015-06-30 13:29 ` Srikar Dronamraju
@ 2015-06-30 13:32 ` Balbir Singh
0 siblings, 0 replies; 14+ messages in thread
From: Balbir Singh @ 2015-06-30 13:32 UTC (permalink / raw)
To: Srikar Dronamraju
Cc: Naveen N. Rao, mingo, linux-kernel@vger.kernel.org, ricklind,
Peter Zijlstra
On Tue, Jun 30, 2015 at 6:59 PM, Srikar Dronamraju
<srikar@linux.vnet.ibm.com> wrote:
> * Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> [2015-06-30 14:36:03]:
>
>> In the unlikely scenario that the kernel is booted with nodelayacct, we
>> dump all zeroes so as to make it clear that scheduler statistics are not
>> available.
>>
>> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
>> ---
>> Changes since v2: Revert to unsigned long in printf
>>
>
> Looks good to me.
>
> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Acked-by: Balbir Singh <bsingharora@gmail.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] schedstat: Simplify sched_info accounting dependency
2015-06-30 13:30 ` Srikar Dronamraju
@ 2015-06-30 13:33 ` Balbir Singh
0 siblings, 0 replies; 14+ messages in thread
From: Balbir Singh @ 2015-06-30 13:33 UTC (permalink / raw)
To: Srikar Dronamraju
Cc: Naveen N. Rao, mingo, linux-kernel@vger.kernel.org, ricklind,
Peter Zijlstra
On Tue, Jun 30, 2015 at 7:00 PM, Srikar Dronamraju
<srikar@linux.vnet.ibm.com> wrote:
> * Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> [2015-06-25 23:53:37]:
>
>> Both CONFIG_SCHEDSTATS and CONFIG_TASK_DELAY_ACCT track task sched_info.
>> Simplify by introducing a common CONFIG_SCHED_INFO selected by both.
>>
>> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
>> ---
>
> Looks good to me.
>
> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Acked-by: Balbir Singh <bsingharora@gmail.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [tip:sched/urgent] sched/stat: Simplify the sched_info accounting dependency
2015-06-25 18:23 ` [PATCH v2 1/2] schedstat: Simplify sched_info accounting dependency Naveen N. Rao
2015-06-30 13:30 ` Srikar Dronamraju
@ 2015-07-03 7:45 ` tip-bot for Naveen N. Rao
2015-07-04 8:07 ` tip-bot for Naveen N. Rao
2 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Naveen N. Rao @ 2015-07-03 7:45 UTC (permalink / raw)
To: linux-tip-commits
Cc: naveen.n.rao, bsingharora, mingo, srikar, tglx, hpa, linux-kernel,
torvalds, peterz
Commit-ID: 640032ed8d55bf6f09b0701e7464aab7e24e0361
Gitweb: http://git.kernel.org/tip/640032ed8d55bf6f09b0701e7464aab7e24e0361
Author: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
AuthorDate: Thu, 25 Jun 2015 23:53:37 +0530
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 1 Jul 2015 10:02:58 +0200
sched/stat: Simplify the sched_info accounting dependency
Both CONFIG_SCHEDSTATS=y and CONFIG_TASK_DELAY_ACCT=y track task
sched_info, which results in ugly #if clauses.
Simplify the code by introducing a synthethic CONFIG_SCHED_INFO
switch, selected by both.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: a.p.zijlstra@chello.nl
Cc: ricklind@us.ibm.com
Link: http://lkml.kernel.org/r/8d19eef800811a94b0f91bcbeb27430a884d7433.1435255405.git.naveen.n.rao@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/sched.h | 6 +++---
init/Kconfig | 1 +
kernel/sched/core.c | 2 +-
kernel/sched/stats.h | 4 ++--
lib/Kconfig.debug | 5 +++++
5 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 6633e83..9bf4bc0 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -849,7 +849,7 @@ extern struct user_struct root_user;
struct backing_dev_info;
struct reclaim_state;
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_SCHED_INFO
struct sched_info {
/* cumulative counters */
unsigned long pcount; /* # of times run on this cpu */
@@ -859,7 +859,7 @@ struct sched_info {
unsigned long long last_arrival,/* when we last ran on a cpu */
last_queued; /* when we were last queued to run */
};
-#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
+#endif /* CONFIG_SCHED_INFO */
#ifdef CONFIG_TASK_DELAY_ACCT
struct task_delay_info {
@@ -1408,7 +1408,7 @@ struct task_struct {
int rcu_tasks_idle_cpu;
#endif /* #ifdef CONFIG_TASKS_RCU */
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_SCHED_INFO
struct sched_info sched_info;
#endif
diff --git a/init/Kconfig b/init/Kconfig
index b999fa3..12cb556 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -435,6 +435,7 @@ config TASKSTATS
config TASK_DELAY_ACCT
bool "Enable per-task delay accounting"
depends on TASKSTATS
+ select SCHED_INFO
help
Collect information on time spent by a task waiting for system
resources like cpu, synchronous block I/O completion and swapping
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 5bcf926..435d8e4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1975,7 +1975,7 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
set_task_cpu(p, cpu);
raw_spin_unlock_irqrestore(&p->pi_lock, flags);
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_SCHED_INFO
if (likely(sched_info_on()))
memset(&p->sched_info, 0, sizeof(p->sched_info));
#endif
diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h
index 077ebbd..b0fbc76 100644
--- a/kernel/sched/stats.h
+++ b/kernel/sched/stats.h
@@ -47,7 +47,7 @@ rq_sched_info_depart(struct rq *rq, unsigned long long delta)
# define schedstat_set(var, val) do { } while (0)
#endif
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_SCHED_INFO
static inline void sched_info_reset_dequeued(struct task_struct *t)
{
t->sched_info.last_queued = 0;
@@ -156,7 +156,7 @@ sched_info_switch(struct rq *rq,
#define sched_info_depart(rq, t) do { } while (0)
#define sched_info_arrive(rq, next) do { } while (0)
#define sched_info_switch(rq, t, next) do { } while (0)
-#endif /* CONFIG_SCHEDSTATS || CONFIG_TASK_DELAY_ACCT */
+#endif /* CONFIG_SCHED_INFO */
/*
* The following are functions that support scheduler-internal time accounting.
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index b908048..e2894b2 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -841,9 +841,14 @@ config SCHED_DEBUG
that can help debug the scheduler. The runtime overhead of this
option is minimal.
+config SCHED_INFO
+ bool
+ default n
+
config SCHEDSTATS
bool "Collect scheduler statistics"
depends on DEBUG_KERNEL && PROC_FS
+ select SCHED_INFO
help
If you say Y here, additional code will be inserted into the
scheduler and related routines to collect statistics about
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [tip:sched/urgent] sched/stat: Expose /proc/pid/ schedstat if CONFIG_SCHED_INFO=y
2015-06-30 9:06 ` [PATCH v3 " Naveen N. Rao
2015-06-30 13:29 ` Srikar Dronamraju
@ 2015-07-03 7:46 ` tip-bot for Naveen N. Rao
2015-07-04 8:07 ` tip-bot for Naveen N. Rao
2 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Naveen N. Rao @ 2015-07-03 7:46 UTC (permalink / raw)
To: linux-tip-commits
Cc: mingo, torvalds, hpa, bsingharora, naveen.n.rao, tglx, peterz,
srikar, linux-kernel
Commit-ID: 74ed568374f0e74d80a63ab5496bf32db641ec60
Gitweb: http://git.kernel.org/tip/74ed568374f0e74d80a63ab5496bf32db641ec60
Author: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
AuthorDate: Tue, 30 Jun 2015 14:36:03 +0530
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 1 Jul 2015 10:02:58 +0200
sched/stat: Expose /proc/pid/schedstat if CONFIG_SCHED_INFO=y
Expand /proc/pid/schedstat output:
- enable it on CONFIG_TASK_DELAY_ACCT=y && !CONFIG_SCHEDSTATS kernels.
- dump all zeroes on kernels that are booted with the 'nodelayacct'
option, which boot option disables delay accounting on
CONFIG_TASK_DELAY_ACCT=y kernels.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: a.p.zijlstra@chello.nl
Cc: ricklind@us.ibm.com
Link: http://lkml.kernel.org/r/5ccbef17d4bc841084ea6e6421d4e4a23b7b806f.1435654789.git.naveen.n.rao@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
fs/proc/base.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 286a422..ad63fa3 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -304,14 +304,17 @@ static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns,
}
#endif
-#ifdef CONFIG_SCHEDSTATS
+#ifdef CONFIG_SCHED_INFO
/*
* Provides /proc/PID/schedstat
*/
static int proc_pid_schedstat(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *task)
{
- seq_printf(m, "%llu %llu %lu\n",
+ if (unlikely(!sched_info_on()))
+ seq_printf(m, "0 0 0\n");
+ else
+ seq_printf(m, "%llu %llu %lu\n",
(unsigned long long)task->se.sum_exec_runtime,
(unsigned long long)task->sched_info.run_delay,
task->sched_info.pcount);
@@ -2600,7 +2603,7 @@ static const struct pid_entry tgid_base_stuff[] = {
#ifdef CONFIG_STACKTRACE
ONE("stack", S_IRUSR, proc_pid_stack),
#endif
-#ifdef CONFIG_SCHEDSTATS
+#ifdef CONFIG_SCHED_INFO
ONE("schedstat", S_IRUGO, proc_pid_schedstat),
#endif
#ifdef CONFIG_LATENCYTOP
@@ -2948,7 +2951,7 @@ static const struct pid_entry tid_base_stuff[] = {
#ifdef CONFIG_STACKTRACE
ONE("stack", S_IRUSR, proc_pid_stack),
#endif
-#ifdef CONFIG_SCHEDSTATS
+#ifdef CONFIG_SCHED_INFO
ONE("schedstat", S_IRUGO, proc_pid_schedstat),
#endif
#ifdef CONFIG_LATENCYTOP
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [tip:sched/urgent] sched/stat: Simplify the sched_info accounting dependency
2015-06-25 18:23 ` [PATCH v2 1/2] schedstat: Simplify sched_info accounting dependency Naveen N. Rao
2015-06-30 13:30 ` Srikar Dronamraju
2015-07-03 7:45 ` [tip:sched/urgent] sched/stat: Simplify the " tip-bot for Naveen N. Rao
@ 2015-07-04 8:07 ` tip-bot for Naveen N. Rao
2 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Naveen N. Rao @ 2015-07-04 8:07 UTC (permalink / raw)
To: linux-tip-commits
Cc: mingo, peterz, hpa, naveen.n.rao, tglx, srikar, torvalds,
linux-kernel, bsingharora
Commit-ID: f6db8347993256b58bd4746b0c4c5b935c32210d
Gitweb: http://git.kernel.org/tip/f6db8347993256b58bd4746b0c4c5b935c32210d
Author: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
AuthorDate: Thu, 25 Jun 2015 23:53:37 +0530
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 4 Jul 2015 10:04:30 +0200
sched/stat: Simplify the sched_info accounting dependency
Both CONFIG_SCHEDSTATS=y and CONFIG_TASK_DELAY_ACCT=y track task
sched_info, which results in ugly #if clauses.
Simplify the code by introducing a synthethic CONFIG_SCHED_INFO
switch, selected by both.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: a.p.zijlstra@chello.nl
Cc: ricklind@us.ibm.com
Link: http://lkml.kernel.org/r/8d19eef800811a94b0f91bcbeb27430a884d7433.1435255405.git.naveen.n.rao@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/sched.h | 6 +++---
init/Kconfig | 1 +
kernel/sched/core.c | 2 +-
kernel/sched/stats.h | 4 ++--
lib/Kconfig.debug | 5 +++++
5 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 6633e83..9bf4bc0 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -849,7 +849,7 @@ extern struct user_struct root_user;
struct backing_dev_info;
struct reclaim_state;
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_SCHED_INFO
struct sched_info {
/* cumulative counters */
unsigned long pcount; /* # of times run on this cpu */
@@ -859,7 +859,7 @@ struct sched_info {
unsigned long long last_arrival,/* when we last ran on a cpu */
last_queued; /* when we were last queued to run */
};
-#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
+#endif /* CONFIG_SCHED_INFO */
#ifdef CONFIG_TASK_DELAY_ACCT
struct task_delay_info {
@@ -1408,7 +1408,7 @@ struct task_struct {
int rcu_tasks_idle_cpu;
#endif /* #ifdef CONFIG_TASKS_RCU */
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_SCHED_INFO
struct sched_info sched_info;
#endif
diff --git a/init/Kconfig b/init/Kconfig
index b999fa3..12cb556 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -435,6 +435,7 @@ config TASKSTATS
config TASK_DELAY_ACCT
bool "Enable per-task delay accounting"
depends on TASKSTATS
+ select SCHED_INFO
help
Collect information on time spent by a task waiting for system
resources like cpu, synchronous block I/O completion and swapping
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index c86935a..abb8785 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1975,7 +1975,7 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
set_task_cpu(p, cpu);
raw_spin_unlock_irqrestore(&p->pi_lock, flags);
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_SCHED_INFO
if (likely(sched_info_on()))
memset(&p->sched_info, 0, sizeof(p->sched_info));
#endif
diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h
index 077ebbd..b0fbc76 100644
--- a/kernel/sched/stats.h
+++ b/kernel/sched/stats.h
@@ -47,7 +47,7 @@ rq_sched_info_depart(struct rq *rq, unsigned long long delta)
# define schedstat_set(var, val) do { } while (0)
#endif
-#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
+#ifdef CONFIG_SCHED_INFO
static inline void sched_info_reset_dequeued(struct task_struct *t)
{
t->sched_info.last_queued = 0;
@@ -156,7 +156,7 @@ sched_info_switch(struct rq *rq,
#define sched_info_depart(rq, t) do { } while (0)
#define sched_info_arrive(rq, next) do { } while (0)
#define sched_info_switch(rq, t, next) do { } while (0)
-#endif /* CONFIG_SCHEDSTATS || CONFIG_TASK_DELAY_ACCT */
+#endif /* CONFIG_SCHED_INFO */
/*
* The following are functions that support scheduler-internal time accounting.
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index b908048..e2894b2 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -841,9 +841,14 @@ config SCHED_DEBUG
that can help debug the scheduler. The runtime overhead of this
option is minimal.
+config SCHED_INFO
+ bool
+ default n
+
config SCHEDSTATS
bool "Collect scheduler statistics"
depends on DEBUG_KERNEL && PROC_FS
+ select SCHED_INFO
help
If you say Y here, additional code will be inserted into the
scheduler and related routines to collect statistics about
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [tip:sched/urgent] sched/stat: Expose /proc/pid/ schedstat if CONFIG_SCHED_INFO=y
2015-06-30 9:06 ` [PATCH v3 " Naveen N. Rao
2015-06-30 13:29 ` Srikar Dronamraju
2015-07-03 7:46 ` [tip:sched/urgent] sched/stat: Expose /proc/pid/ schedstat if CONFIG_SCHED_INFO=y tip-bot for Naveen N. Rao
@ 2015-07-04 8:07 ` tip-bot for Naveen N. Rao
2 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Naveen N. Rao @ 2015-07-04 8:07 UTC (permalink / raw)
To: linux-tip-commits
Cc: peterz, torvalds, mingo, linux-kernel, srikar, bsingharora, hpa,
naveen.n.rao, tglx
Commit-ID: 5968cecedd7a09f23e9fcb5f9fb4e893712f35ba
Gitweb: http://git.kernel.org/tip/5968cecedd7a09f23e9fcb5f9fb4e893712f35ba
Author: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
AuthorDate: Tue, 30 Jun 2015 14:36:03 +0530
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 4 Jul 2015 10:04:31 +0200
sched/stat: Expose /proc/pid/schedstat if CONFIG_SCHED_INFO=y
Expand /proc/pid/schedstat output:
- enable it on CONFIG_TASK_DELAY_ACCT=y && !CONFIG_SCHEDSTATS kernels.
- dump all zeroes on kernels that are booted with the 'nodelayacct'
option, which boot option disables delay accounting on
CONFIG_TASK_DELAY_ACCT=y kernels.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: a.p.zijlstra@chello.nl
Cc: ricklind@us.ibm.com
Link: http://lkml.kernel.org/r/5ccbef17d4bc841084ea6e6421d4e4a23b7b806f.1435654789.git.naveen.n.rao@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
fs/proc/base.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 286a422..ad63fa3 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -304,14 +304,17 @@ static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns,
}
#endif
-#ifdef CONFIG_SCHEDSTATS
+#ifdef CONFIG_SCHED_INFO
/*
* Provides /proc/PID/schedstat
*/
static int proc_pid_schedstat(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *task)
{
- seq_printf(m, "%llu %llu %lu\n",
+ if (unlikely(!sched_info_on()))
+ seq_printf(m, "0 0 0\n");
+ else
+ seq_printf(m, "%llu %llu %lu\n",
(unsigned long long)task->se.sum_exec_runtime,
(unsigned long long)task->sched_info.run_delay,
task->sched_info.pcount);
@@ -2600,7 +2603,7 @@ static const struct pid_entry tgid_base_stuff[] = {
#ifdef CONFIG_STACKTRACE
ONE("stack", S_IRUSR, proc_pid_stack),
#endif
-#ifdef CONFIG_SCHEDSTATS
+#ifdef CONFIG_SCHED_INFO
ONE("schedstat", S_IRUGO, proc_pid_schedstat),
#endif
#ifdef CONFIG_LATENCYTOP
@@ -2948,7 +2951,7 @@ static const struct pid_entry tid_base_stuff[] = {
#ifdef CONFIG_STACKTRACE
ONE("stack", S_IRUSR, proc_pid_stack),
#endif
-#ifdef CONFIG_SCHEDSTATS
+#ifdef CONFIG_SCHED_INFO
ONE("schedstat", S_IRUGO, proc_pid_schedstat),
#endif
#ifdef CONFIG_LATENCYTOP
^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2015-07-05 8:36 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-25 18:23 [PATCH v2 0/2] Clean up schedstat and task delay acct config options Naveen N. Rao
2015-06-25 18:23 ` [PATCH v2 1/2] schedstat: Simplify sched_info accounting dependency Naveen N. Rao
2015-06-30 13:30 ` Srikar Dronamraju
2015-06-30 13:33 ` Balbir Singh
2015-07-03 7:45 ` [tip:sched/urgent] sched/stat: Simplify the " tip-bot for Naveen N. Rao
2015-07-04 8:07 ` tip-bot for Naveen N. Rao
2015-06-25 18:23 ` [PATCH v2 2/2] schedstat: Expose /proc/pid/schedstat if CONFIG_SCHED_INFO is set Naveen N. Rao
2015-06-30 5:55 ` Srikar Dronamraju
2015-06-30 6:16 ` Naveen N. Rao
2015-06-30 9:06 ` [PATCH v3 " Naveen N. Rao
2015-06-30 13:29 ` Srikar Dronamraju
2015-06-30 13:32 ` Balbir Singh
2015-07-03 7:46 ` [tip:sched/urgent] sched/stat: Expose /proc/pid/ schedstat if CONFIG_SCHED_INFO=y tip-bot for Naveen N. Rao
2015-07-04 8:07 ` tip-bot for Naveen N. Rao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox