aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>2015-06-25 14:23:37 -0400
committerIngo Molnar <mingo@kernel.org>2015-07-04 04:04:30 -0400
commitf6db8347993256b58bd4746b0c4c5b935c32210d (patch)
tree07accf585bbf5c7cb5f167a11a4e713deabb6043
parent407a2c720556e8e340e06f6a7174f5d6d80cf9ea (diff)
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>
-rw-r--r--include/linux/sched.h6
-rw-r--r--init/Kconfig1
-rw-r--r--kernel/sched/core.c2
-rw-r--r--kernel/sched/stats.h4
-rw-r--r--lib/Kconfig.debug5
5 files changed, 12 insertions, 6 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 6633e83e608a..9bf4bc0e3b8b 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -849,7 +849,7 @@ extern struct user_struct root_user;
849struct backing_dev_info; 849struct backing_dev_info;
850struct reclaim_state; 850struct reclaim_state;
851 851
852#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) 852#ifdef CONFIG_SCHED_INFO
853struct sched_info { 853struct sched_info {
854 /* cumulative counters */ 854 /* cumulative counters */
855 unsigned long pcount; /* # of times run on this cpu */ 855 unsigned long pcount; /* # of times run on this cpu */
@@ -859,7 +859,7 @@ struct sched_info {
859 unsigned long long last_arrival,/* when we last ran on a cpu */ 859 unsigned long long last_arrival,/* when we last ran on a cpu */
860 last_queued; /* when we were last queued to run */ 860 last_queued; /* when we were last queued to run */
861}; 861};
862#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */ 862#endif /* CONFIG_SCHED_INFO */
863 863
864#ifdef CONFIG_TASK_DELAY_ACCT 864#ifdef CONFIG_TASK_DELAY_ACCT
865struct task_delay_info { 865struct task_delay_info {
@@ -1408,7 +1408,7 @@ struct task_struct {
1408 int rcu_tasks_idle_cpu; 1408 int rcu_tasks_idle_cpu;
1409#endif /* #ifdef CONFIG_TASKS_RCU */ 1409#endif /* #ifdef CONFIG_TASKS_RCU */
1410 1410
1411#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) 1411#ifdef CONFIG_SCHED_INFO
1412 struct sched_info sched_info; 1412 struct sched_info sched_info;
1413#endif 1413#endif
1414 1414
diff --git a/init/Kconfig b/init/Kconfig
index b999fa381bf9..12cb556ad160 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -435,6 +435,7 @@ config TASKSTATS
435config TASK_DELAY_ACCT 435config TASK_DELAY_ACCT
436 bool "Enable per-task delay accounting" 436 bool "Enable per-task delay accounting"
437 depends on TASKSTATS 437 depends on TASKSTATS
438 select SCHED_INFO
438 help 439 help
439 Collect information on time spent by a task waiting for system 440 Collect information on time spent by a task waiting for system
440 resources like cpu, synchronous block I/O completion and swapping 441 resources like cpu, synchronous block I/O completion and swapping
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index c86935a7f1f8..abb8785ed1ba 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)
1975 set_task_cpu(p, cpu); 1975 set_task_cpu(p, cpu);
1976 raw_spin_unlock_irqrestore(&p->pi_lock, flags); 1976 raw_spin_unlock_irqrestore(&p->pi_lock, flags);
1977 1977
1978#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) 1978#ifdef CONFIG_SCHED_INFO
1979 if (likely(sched_info_on())) 1979 if (likely(sched_info_on()))
1980 memset(&p->sched_info, 0, sizeof(p->sched_info)); 1980 memset(&p->sched_info, 0, sizeof(p->sched_info));
1981#endif 1981#endif
diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h
index 077ebbd5e10f..b0fbc7632de5 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)
47# define schedstat_set(var, val) do { } while (0) 47# define schedstat_set(var, val) do { } while (0)
48#endif 48#endif
49 49
50#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) 50#ifdef CONFIG_SCHED_INFO
51static inline void sched_info_reset_dequeued(struct task_struct *t) 51static inline void sched_info_reset_dequeued(struct task_struct *t)
52{ 52{
53 t->sched_info.last_queued = 0; 53 t->sched_info.last_queued = 0;
@@ -156,7 +156,7 @@ sched_info_switch(struct rq *rq,
156#define sched_info_depart(rq, t) do { } while (0) 156#define sched_info_depart(rq, t) do { } while (0)
157#define sched_info_arrive(rq, next) do { } while (0) 157#define sched_info_arrive(rq, next) do { } while (0)
158#define sched_info_switch(rq, t, next) do { } while (0) 158#define sched_info_switch(rq, t, next) do { } while (0)
159#endif /* CONFIG_SCHEDSTATS || CONFIG_TASK_DELAY_ACCT */ 159#endif /* CONFIG_SCHED_INFO */
160 160
161/* 161/*
162 * The following are functions that support scheduler-internal time accounting. 162 * The following are functions that support scheduler-internal time accounting.
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index b908048f8d6a..e2894b23efb6 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -841,9 +841,14 @@ config SCHED_DEBUG
841 that can help debug the scheduler. The runtime overhead of this 841 that can help debug the scheduler. The runtime overhead of this
842 option is minimal. 842 option is minimal.
843 843
844config SCHED_INFO
845 bool
846 default n
847
844config SCHEDSTATS 848config SCHEDSTATS
845 bool "Collect scheduler statistics" 849 bool "Collect scheduler statistics"
846 depends on DEBUG_KERNEL && PROC_FS 850 depends on DEBUG_KERNEL && PROC_FS
851 select SCHED_INFO
847 help 852 help
848 If you say Y here, additional code will be inserted into the 853 If you say Y here, additional code will be inserted into the
849 scheduler and related routines to collect statistics about 854 scheduler and related routines to collect statistics about