aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorVaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>2008-12-18 12:56:02 -0500
committerIngo Molnar <mingo@elte.hu>2008-12-19 03:21:45 -0500
commit716707b29906e1d8d190defe3d646610b097a861 (patch)
tree02ddc0300b74d19bc93cc00d033b72e3e279dbf7 /include
parent3b11ce7f542e415c90267b4482d4611410b468e6 (diff)
sched: convert BALANCE_FOR_xx_POWER to inline functions
Impact: cleanup BALANCE_FOR_MC_POWER and similar macros defined in sched.h are not constants and have various condition checks and significant amount of code that is not suitable to be contain in a macro. Also there could be side effects on the expressions passed to some of them like test_sd_parent(). This patch converts all complex macros related to power savings balance to inline functions. Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include')
-rw-r--r--include/linux/sched.h33
-rw-r--r--include/linux/topology.h4
2 files changed, 26 insertions, 11 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 4240f6bfa812..1210fb0e45ff 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -763,15 +763,23 @@ enum cpu_idle_type {
763#define SD_SERIALIZE 1024 /* Only a single load balancing instance */ 763#define SD_SERIALIZE 1024 /* Only a single load balancing instance */
764#define SD_WAKE_IDLE_FAR 2048 /* Gain latency sacrificing cache hit */ 764#define SD_WAKE_IDLE_FAR 2048 /* Gain latency sacrificing cache hit */
765 765
766#define BALANCE_FOR_MC_POWER \ 766extern int sched_mc_power_savings, sched_smt_power_savings;
767 (sched_smt_power_savings ? SD_POWERSAVINGS_BALANCE : 0) 767
768static inline int sd_balance_for_mc_power(void)
769{
770 if (sched_smt_power_savings)
771 return SD_POWERSAVINGS_BALANCE;
768 772
769#define BALANCE_FOR_PKG_POWER \ 773 return 0;
770 ((sched_mc_power_savings || sched_smt_power_savings) ? \ 774}
771 SD_POWERSAVINGS_BALANCE : 0)
772 775
773#define test_sd_parent(sd, flag) ((sd->parent && \ 776static inline int sd_balance_for_package_power(void)
774 (sd->parent->flags & flag)) ? 1 : 0) 777{
778 if (sched_mc_power_savings | sched_smt_power_savings)
779 return SD_POWERSAVINGS_BALANCE;
780
781 return 0;
782}
775 783
776 784
777struct sched_group { 785struct sched_group {
@@ -1399,6 +1407,15 @@ struct task_struct {
1399#endif 1407#endif
1400}; 1408};
1401 1409
1410/* Test a flag in parent sched domain */
1411static inline int test_sd_parent(struct sched_domain *sd, int flag)
1412{
1413 if (sd->parent && (sd->parent->flags & flag))
1414 return 1;
1415
1416 return 0;
1417}
1418
1402/* 1419/*
1403 * Priority of a process goes from 0..MAX_PRIO-1, valid RT 1420 * Priority of a process goes from 0..MAX_PRIO-1, valid RT
1404 * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH 1421 * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
@@ -2256,8 +2273,6 @@ __trace_special(void *__tr, void *__data,
2256extern long sched_setaffinity(pid_t pid, const struct cpumask *new_mask); 2273extern long sched_setaffinity(pid_t pid, const struct cpumask *new_mask);
2257extern long sched_getaffinity(pid_t pid, struct cpumask *mask); 2274extern long sched_getaffinity(pid_t pid, struct cpumask *mask);
2258 2275
2259extern int sched_mc_power_savings, sched_smt_power_savings;
2260
2261extern void normalize_rt_tasks(void); 2276extern void normalize_rt_tasks(void);
2262 2277
2263#ifdef CONFIG_GROUP_SCHED 2278#ifdef CONFIG_GROUP_SCHED
diff --git a/include/linux/topology.h b/include/linux/topology.h
index 0c5b5ac36d8e..0ce7c0dac06c 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -125,7 +125,7 @@ int arch_update_cpu_topology(void);
125 | SD_WAKE_AFFINE \ 125 | SD_WAKE_AFFINE \
126 | SD_WAKE_BALANCE \ 126 | SD_WAKE_BALANCE \
127 | SD_SHARE_PKG_RESOURCES\ 127 | SD_SHARE_PKG_RESOURCES\
128 | BALANCE_FOR_MC_POWER, \ 128 | sd_balance_for_mc_power(),\
129 .last_balance = jiffies, \ 129 .last_balance = jiffies, \
130 .balance_interval = 1, \ 130 .balance_interval = 1, \
131} 131}
@@ -150,7 +150,7 @@ int arch_update_cpu_topology(void);
150 | SD_BALANCE_FORK \ 150 | SD_BALANCE_FORK \
151 | SD_WAKE_AFFINE \ 151 | SD_WAKE_AFFINE \
152 | SD_WAKE_BALANCE \ 152 | SD_WAKE_BALANCE \
153 | BALANCE_FOR_PKG_POWER,\ 153 | sd_balance_for_package_power(),\
154 .last_balance = jiffies, \ 154 .last_balance = jiffies, \
155 .balance_interval = 1, \ 155 .balance_interval = 1, \
156} 156}