aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-06-03 17:00:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-03 17:00:15 -0400
commitc84a1e32ee58fc1cc9d3fd42619b917cce67e30a (patch)
treed3e5bed273f747e7c9e399864219bea76f4c30ea /include
parent3d521f9151dacab566904d1f57dcb3e7080cdd8f (diff)
parent096aa33863a5e48de52d2ff30e0801b7487944f4 (diff)
Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into next
Pull scheduler updates from Ingo Molnar: "The main scheduling related changes in this cycle were: - various sched/numa updates, for better performance - tree wide cleanup of open coded nice levels - nohz fix related to rq->nr_running use - cpuidle changes and continued consolidation to improve the kernel/sched/idle.c high level idle scheduling logic. As part of this effort I pulled cpuidle driver changes from Rafael as well. - standardized idle polling amongst architectures - continued work on preparing better power/energy aware scheduling - sched/rt updates - misc fixlets and cleanups" * 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (49 commits) sched/numa: Decay ->wakee_flips instead of zeroing sched/numa: Update migrate_improves/degrades_locality() sched/numa: Allow task switch if load imbalance improves sched/rt: Fix 'struct sched_dl_entity' and dl_task_time() comments, to match the current upstream code sched: Consolidate open coded implementations of nice level frobbing into nice_to_rlimit() and rlimit_to_nice() sched: Initialize rq->age_stamp on processor start sched, nohz: Change rq->nr_running to always use wrappers sched: Fix the rq->next_balance logic in rebalance_domains() and idle_balance() sched: Use clamp() and clamp_val() to make sys_nice() more readable sched: Do not zero sg->cpumask and sg->sgp->power in build_sched_groups() sched/numa: Fix initialization of sched_domain_topology for NUMA sched: Call select_idle_sibling() when not affine_sd sched: Simplify return logic in sched_read_attr() sched: Simplify return logic in sched_copy_attr() sched: Fix exec_start/task_hot on migrated tasks arm64: Remove TIF_POLLING_NRFLAG metag: Remove TIF_POLLING_NRFLAG sched/idle: Make cpuidle_idle_call() void sched/idle: Reflow cpuidle_idle_call() sched/idle: Delay clearing the polling bit ...
Diffstat (limited to 'include')
-rw-r--r--include/linux/cpuidle.h7
-rw-r--r--include/linux/sched.h104
-rw-r--r--include/linux/sched/prio.h16
-rw-r--r--include/linux/thread_info.h14
-rw-r--r--include/linux/topology.h128
5 files changed, 88 insertions, 181 deletions
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index b0238cba440b..c51a436135c4 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -120,8 +120,6 @@ struct cpuidle_driver {
120#ifdef CONFIG_CPU_IDLE 120#ifdef CONFIG_CPU_IDLE
121extern void disable_cpuidle(void); 121extern void disable_cpuidle(void);
122 122
123extern int cpuidle_enabled(struct cpuidle_driver *drv,
124 struct cpuidle_device *dev);
125extern int cpuidle_select(struct cpuidle_driver *drv, 123extern int cpuidle_select(struct cpuidle_driver *drv,
126 struct cpuidle_device *dev); 124 struct cpuidle_device *dev);
127extern int cpuidle_enter(struct cpuidle_driver *drv, 125extern int cpuidle_enter(struct cpuidle_driver *drv,
@@ -145,13 +143,11 @@ extern void cpuidle_resume(void);
145extern int cpuidle_enable_device(struct cpuidle_device *dev); 143extern int cpuidle_enable_device(struct cpuidle_device *dev);
146extern void cpuidle_disable_device(struct cpuidle_device *dev); 144extern void cpuidle_disable_device(struct cpuidle_device *dev);
147extern int cpuidle_play_dead(void); 145extern int cpuidle_play_dead(void);
146extern void cpuidle_use_deepest_state(bool enable);
148 147
149extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev); 148extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev);
150#else 149#else
151static inline void disable_cpuidle(void) { } 150static inline void disable_cpuidle(void) { }
152static inline int cpuidle_enabled(struct cpuidle_driver *drv,
153 struct cpuidle_device *dev)
154{return -ENODEV; }
155static inline int cpuidle_select(struct cpuidle_driver *drv, 151static inline int cpuidle_select(struct cpuidle_driver *drv,
156 struct cpuidle_device *dev) 152 struct cpuidle_device *dev)
157{return -ENODEV; } 153{return -ENODEV; }
@@ -180,6 +176,7 @@ static inline int cpuidle_enable_device(struct cpuidle_device *dev)
180{return -ENODEV; } 176{return -ENODEV; }
181static inline void cpuidle_disable_device(struct cpuidle_device *dev) { } 177static inline void cpuidle_disable_device(struct cpuidle_device *dev) { }
182static inline int cpuidle_play_dead(void) {return -ENODEV; } 178static inline int cpuidle_play_dead(void) {return -ENODEV; }
179static inline void cpuidle_use_deepest_state(bool enable) {}
183static inline struct cpuidle_driver *cpuidle_get_cpu_driver( 180static inline struct cpuidle_driver *cpuidle_get_cpu_driver(
184 struct cpuidle_device *dev) {return NULL; } 181 struct cpuidle_device *dev) {return NULL; }
185#endif 182#endif
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 4dce5d844b74..70f67e4e6156 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -870,6 +870,7 @@ enum cpu_idle_type {
870#define SD_BALANCE_WAKE 0x0010 /* Balance on wakeup */ 870#define SD_BALANCE_WAKE 0x0010 /* Balance on wakeup */
871#define SD_WAKE_AFFINE 0x0020 /* Wake task to waking CPU */ 871#define SD_WAKE_AFFINE 0x0020 /* Wake task to waking CPU */
872#define SD_SHARE_CPUPOWER 0x0080 /* Domain members share cpu power */ 872#define SD_SHARE_CPUPOWER 0x0080 /* Domain members share cpu power */
873#define SD_SHARE_POWERDOMAIN 0x0100 /* Domain members share power domain */
873#define SD_SHARE_PKG_RESOURCES 0x0200 /* Domain members share cpu pkg resources */ 874#define SD_SHARE_PKG_RESOURCES 0x0200 /* Domain members share cpu pkg resources */
874#define SD_SERIALIZE 0x0400 /* Only a single load balancing instance */ 875#define SD_SERIALIZE 0x0400 /* Only a single load balancing instance */
875#define SD_ASYM_PACKING 0x0800 /* Place busy groups earlier in the domain */ 876#define SD_ASYM_PACKING 0x0800 /* Place busy groups earlier in the domain */
@@ -877,7 +878,26 @@ enum cpu_idle_type {
877#define SD_OVERLAP 0x2000 /* sched_domains of this level overlap */ 878#define SD_OVERLAP 0x2000 /* sched_domains of this level overlap */
878#define SD_NUMA 0x4000 /* cross-node balancing */ 879#define SD_NUMA 0x4000 /* cross-node balancing */
879 880
880extern int __weak arch_sd_sibiling_asym_packing(void); 881#ifdef CONFIG_SCHED_SMT
882static inline const int cpu_smt_flags(void)
883{
884 return SD_SHARE_CPUPOWER | SD_SHARE_PKG_RESOURCES;
885}
886#endif
887
888#ifdef CONFIG_SCHED_MC
889static inline const int cpu_core_flags(void)
890{
891 return SD_SHARE_PKG_RESOURCES;
892}
893#endif
894
895#ifdef CONFIG_NUMA
896static inline const int cpu_numa_flags(void)
897{
898 return SD_NUMA;
899}
900#endif
881 901
882struct sched_domain_attr { 902struct sched_domain_attr {
883 int relax_domain_level; 903 int relax_domain_level;
@@ -985,6 +1005,38 @@ void free_sched_domains(cpumask_var_t doms[], unsigned int ndoms);
985 1005
986bool cpus_share_cache(int this_cpu, int that_cpu); 1006bool cpus_share_cache(int this_cpu, int that_cpu);
987 1007
1008typedef const struct cpumask *(*sched_domain_mask_f)(int cpu);
1009typedef const int (*sched_domain_flags_f)(void);
1010
1011#define SDTL_OVERLAP 0x01
1012
1013struct sd_data {
1014 struct sched_domain **__percpu sd;
1015 struct sched_group **__percpu sg;
1016 struct sched_group_power **__percpu sgp;
1017};
1018
1019struct sched_domain_topology_level {
1020 sched_domain_mask_f mask;
1021 sched_domain_flags_f sd_flags;
1022 int flags;
1023 int numa_level;
1024 struct sd_data data;
1025#ifdef CONFIG_SCHED_DEBUG
1026 char *name;
1027#endif
1028};
1029
1030extern struct sched_domain_topology_level *sched_domain_topology;
1031
1032extern void set_sched_topology(struct sched_domain_topology_level *tl);
1033
1034#ifdef CONFIG_SCHED_DEBUG
1035# define SD_INIT_NAME(type) .name = #type
1036#else
1037# define SD_INIT_NAME(type)
1038#endif
1039
988#else /* CONFIG_SMP */ 1040#else /* CONFIG_SMP */
989 1041
990struct sched_domain_attr; 1042struct sched_domain_attr;
@@ -1123,8 +1175,8 @@ struct sched_dl_entity {
1123 1175
1124 /* 1176 /*
1125 * Original scheduling parameters. Copied here from sched_attr 1177 * Original scheduling parameters. Copied here from sched_attr
1126 * during sched_setscheduler2(), they will remain the same until 1178 * during sched_setattr(), they will remain the same until
1127 * the next sched_setscheduler2(). 1179 * the next sched_setattr().
1128 */ 1180 */
1129 u64 dl_runtime; /* maximum runtime for each instance */ 1181 u64 dl_runtime; /* maximum runtime for each instance */
1130 u64 dl_deadline; /* relative deadline of each instance */ 1182 u64 dl_deadline; /* relative deadline of each instance */
@@ -2723,51 +2775,9 @@ static inline int spin_needbreak(spinlock_t *lock)
2723 2775
2724/* 2776/*
2725 * Idle thread specific functions to determine the need_resched 2777 * Idle thread specific functions to determine the need_resched
2726 * polling state. We have two versions, one based on TS_POLLING in 2778 * polling state.
2727 * thread_info.status and one based on TIF_POLLING_NRFLAG in
2728 * thread_info.flags
2729 */ 2779 */
2730#ifdef TS_POLLING 2780#ifdef TIF_POLLING_NRFLAG
2731static inline int tsk_is_polling(struct task_struct *p)
2732{
2733 return task_thread_info(p)->status & TS_POLLING;
2734}
2735static inline void __current_set_polling(void)
2736{
2737 current_thread_info()->status |= TS_POLLING;
2738}
2739
2740static inline bool __must_check current_set_polling_and_test(void)
2741{
2742 __current_set_polling();
2743
2744 /*
2745 * Polling state must be visible before we test NEED_RESCHED,
2746 * paired by resched_task()
2747 */
2748 smp_mb();
2749
2750 return unlikely(tif_need_resched());
2751}
2752
2753static inline void __current_clr_polling(void)
2754{
2755 current_thread_info()->status &= ~TS_POLLING;
2756}
2757
2758static inline bool __must_check current_clr_polling_and_test(void)
2759{
2760 __current_clr_polling();
2761
2762 /*
2763 * Polling state must be visible before we test NEED_RESCHED,
2764 * paired by resched_task()
2765 */
2766 smp_mb();
2767
2768 return unlikely(tif_need_resched());
2769}
2770#elif defined(TIF_POLLING_NRFLAG)
2771static inline int tsk_is_polling(struct task_struct *p) 2781static inline int tsk_is_polling(struct task_struct *p)
2772{ 2782{
2773 return test_tsk_thread_flag(p, TIF_POLLING_NRFLAG); 2783 return test_tsk_thread_flag(p, TIF_POLLING_NRFLAG);
diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h
index ac322583c820..d9cf5a5762d9 100644
--- a/include/linux/sched/prio.h
+++ b/include/linux/sched/prio.h
@@ -41,4 +41,20 @@
41#define TASK_USER_PRIO(p) USER_PRIO((p)->static_prio) 41#define TASK_USER_PRIO(p) USER_PRIO((p)->static_prio)
42#define MAX_USER_PRIO (USER_PRIO(MAX_PRIO)) 42#define MAX_USER_PRIO (USER_PRIO(MAX_PRIO))
43 43
44/*
45 * Convert nice value [19,-20] to rlimit style value [1,40].
46 */
47static inline long nice_to_rlimit(long nice)
48{
49 return (MAX_NICE - nice + 1);
50}
51
52/*
53 * Convert rlimit style value [1,40] to nice value [-20, 19].
54 */
55static inline long rlimit_to_nice(long prio)
56{
57 return (MAX_NICE - prio + 1);
58}
59
44#endif /* _SCHED_PRIO_H */ 60#endif /* _SCHED_PRIO_H */
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index fddbe2023a5d..cb0cec94fda3 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -104,20 +104,6 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
104#define test_thread_flag(flag) \ 104#define test_thread_flag(flag) \
105 test_ti_thread_flag(current_thread_info(), flag) 105 test_ti_thread_flag(current_thread_info(), flag)
106 106
107static inline __deprecated void set_need_resched(void)
108{
109 /*
110 * Use of this function in deprecated.
111 *
112 * As of this writing there are only a few users in the DRM tree left
113 * all of which are wrong and can be removed without causing too much
114 * grief.
115 *
116 * The DRM people are aware and are working on removing the last few
117 * instances.
118 */
119}
120
121#define tif_need_resched() test_thread_flag(TIF_NEED_RESCHED) 107#define tif_need_resched() test_thread_flag(TIF_NEED_RESCHED)
122 108
123#if defined TIF_RESTORE_SIGMASK && !defined HAVE_SET_RESTORE_SIGMASK 109#if defined TIF_RESTORE_SIGMASK && !defined HAVE_SET_RESTORE_SIGMASK
diff --git a/include/linux/topology.h b/include/linux/topology.h
index 7062330a1329..973671ff9e7d 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -66,121 +66,6 @@ int arch_update_cpu_topology(void);
66#define PENALTY_FOR_NODE_WITH_CPUS (1) 66#define PENALTY_FOR_NODE_WITH_CPUS (1)
67#endif 67#endif
68 68
69/*
70 * Below are the 3 major initializers used in building sched_domains:
71 * SD_SIBLING_INIT, for SMT domains
72 * SD_CPU_INIT, for SMP domains
73 *
74 * Any architecture that cares to do any tuning to these values should do so
75 * by defining their own arch-specific initializer in include/asm/topology.h.
76 * A definition there will automagically override these default initializers
77 * and allow arch-specific performance tuning of sched_domains.
78 * (Only non-zero and non-null fields need be specified.)
79 */
80
81#ifdef CONFIG_SCHED_SMT
82/* MCD - Do we really need this? It is always on if CONFIG_SCHED_SMT is,
83 * so can't we drop this in favor of CONFIG_SCHED_SMT?
84 */
85#define ARCH_HAS_SCHED_WAKE_IDLE
86/* Common values for SMT siblings */
87#ifndef SD_SIBLING_INIT
88#define SD_SIBLING_INIT (struct sched_domain) { \
89 .min_interval = 1, \
90 .max_interval = 2, \
91 .busy_factor = 64, \
92 .imbalance_pct = 110, \
93 \
94 .flags = 1*SD_LOAD_BALANCE \
95 | 1*SD_BALANCE_NEWIDLE \
96 | 1*SD_BALANCE_EXEC \
97 | 1*SD_BALANCE_FORK \
98 | 0*SD_BALANCE_WAKE \
99 | 1*SD_WAKE_AFFINE \
100 | 1*SD_SHARE_CPUPOWER \
101 | 1*SD_SHARE_PKG_RESOURCES \
102 | 0*SD_SERIALIZE \
103 | 0*SD_PREFER_SIBLING \
104 | arch_sd_sibling_asym_packing() \
105 , \
106 .last_balance = jiffies, \
107 .balance_interval = 1, \
108 .smt_gain = 1178, /* 15% */ \
109 .max_newidle_lb_cost = 0, \
110 .next_decay_max_lb_cost = jiffies, \
111}
112#endif
113#endif /* CONFIG_SCHED_SMT */
114
115#ifdef CONFIG_SCHED_MC
116/* Common values for MC siblings. for now mostly derived from SD_CPU_INIT */
117#ifndef SD_MC_INIT
118#define SD_MC_INIT (struct sched_domain) { \
119 .min_interval = 1, \
120 .max_interval = 4, \
121 .busy_factor = 64, \
122 .imbalance_pct = 125, \
123 .cache_nice_tries = 1, \
124 .busy_idx = 2, \
125 .wake_idx = 0, \
126 .forkexec_idx = 0, \
127 \
128 .flags = 1*SD_LOAD_BALANCE \
129 | 1*SD_BALANCE_NEWIDLE \
130 | 1*SD_BALANCE_EXEC \
131 | 1*SD_BALANCE_FORK \
132 | 0*SD_BALANCE_WAKE \
133 | 1*SD_WAKE_AFFINE \
134 | 0*SD_SHARE_CPUPOWER \
135 | 1*SD_SHARE_PKG_RESOURCES \
136 | 0*SD_SERIALIZE \
137 , \
138 .last_balance = jiffies, \
139 .balance_interval = 1, \
140 .max_newidle_lb_cost = 0, \
141 .next_decay_max_lb_cost = jiffies, \
142}
143#endif
144#endif /* CONFIG_SCHED_MC */
145
146/* Common values for CPUs */
147#ifndef SD_CPU_INIT
148#define SD_CPU_INIT (struct sched_domain) { \
149 .min_interval = 1, \
150 .max_interval = 4, \
151 .busy_factor = 64, \
152 .imbalance_pct = 125, \
153 .cache_nice_tries = 1, \
154 .busy_idx = 2, \
155 .idle_idx = 1, \
156 .newidle_idx = 0, \
157 .wake_idx = 0, \
158 .forkexec_idx = 0, \
159 \
160 .flags = 1*SD_LOAD_BALANCE \
161 | 1*SD_BALANCE_NEWIDLE \
162 | 1*SD_BALANCE_EXEC \
163 | 1*SD_BALANCE_FORK \
164 | 0*SD_BALANCE_WAKE \
165 | 1*SD_WAKE_AFFINE \
166 | 0*SD_SHARE_CPUPOWER \
167 | 0*SD_SHARE_PKG_RESOURCES \
168 | 0*SD_SERIALIZE \
169 | 1*SD_PREFER_SIBLING \
170 , \
171 .last_balance = jiffies, \
172 .balance_interval = 1, \
173 .max_newidle_lb_cost = 0, \
174 .next_decay_max_lb_cost = jiffies, \
175}
176#endif
177
178#ifdef CONFIG_SCHED_BOOK
179#ifndef SD_BOOK_INIT
180#error Please define an appropriate SD_BOOK_INIT in include/asm/topology.h!!!
181#endif
182#endif /* CONFIG_SCHED_BOOK */
183
184#ifdef CONFIG_USE_PERCPU_NUMA_NODE_ID 69#ifdef CONFIG_USE_PERCPU_NUMA_NODE_ID
185DECLARE_PER_CPU(int, numa_node); 70DECLARE_PER_CPU(int, numa_node);
186 71
@@ -295,4 +180,17 @@ static inline int cpu_to_mem(int cpu)
295#define topology_core_cpumask(cpu) cpumask_of(cpu) 180#define topology_core_cpumask(cpu) cpumask_of(cpu)
296#endif 181#endif
297 182
183#ifdef CONFIG_SCHED_SMT
184static inline const struct cpumask *cpu_smt_mask(int cpu)
185{
186 return topology_thread_cpumask(cpu);
187}
188#endif
189
190static inline const struct cpumask *cpu_cpu_mask(int cpu)
191{
192 return cpumask_of_node(cpu_to_node(cpu));
193}
194
195
298#endif /* _LINUX_TOPOLOGY_H */ 196#endif /* _LINUX_TOPOLOGY_H */