From 877bc05081eb9925290721d32fa0bedcc2e932a1 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Thu, 28 Jul 2016 17:42:36 +0100 Subject: [PATCH] sched/{fair,tune}: simplify fair.c code The usage of conditional compiled code is discouraged in fair.c. This patch clean up a bit fair.c by moving schedtune_{cpu.task}_boost definitions into tune.h. Signed-off-by: Patrick Bellasi --- kernel/sched/fair.c | 21 +++------------------ kernel/sched/tune.h | 6 ++++++ 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index a3e6fa63be4d..9c717c3be75d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5098,18 +5098,13 @@ normalize_energy(int energy_diff) static inline int energy_diff(struct energy_env *eenv) { - unsigned int boost; + int boost = schedtune_task_boost(eenv->task); int nrg_delta; /* Conpute "absolute" energy diff */ __energy_diff(eenv); /* Return energy diff when boost margin is 0 */ -#ifdef CONFIG_CGROUP_SCHEDTUNE - boost = schedtune_task_boost(eenv->task); -#else - boost = get_sysctl_sched_cfs_boost(); -#endif if (boost == 0) return eenv->nrg.diff; @@ -5313,13 +5308,8 @@ schedtune_margin(unsigned long signal, long boost) static inline int schedtune_cpu_margin(unsigned long util, int cpu) { - int boost; + int boost = schedtune_cpu_boost(cpu); -#ifdef CONFIG_CGROUP_SCHEDTUNE - boost = schedtune_cpu_boost(cpu); -#else - boost = get_sysctl_sched_cfs_boost(); -#endif if (boost == 0) return 0; @@ -5329,15 +5319,10 @@ schedtune_cpu_margin(unsigned long util, int cpu) static inline long schedtune_task_margin(struct task_struct *task) { - int boost; + int boost = schedtune_task_boost(task); unsigned long util; long margin; -#ifdef CONFIG_CGROUP_SCHEDTUNE - boost = schedtune_task_boost(task); -#else - boost = get_sysctl_sched_cfs_boost(); -#endif if (boost == 0) return 0; diff --git a/kernel/sched/tune.h b/kernel/sched/tune.h index 7d2aa7951554..99637758a8af 100644 --- a/kernel/sched/tune.h +++ b/kernel/sched/tune.h @@ -22,6 +22,9 @@ void schedtune_dequeue_task(struct task_struct *p, int cpu); #else /* CONFIG_CGROUP_SCHEDTUNE */ +#define schedtune_cpu_boost(cpu) get_sysctl_sched_cfs_boost() +#define schedtune_task_boost(tsk) get_sysctl_sched_cfs_boost() + #define schedtune_enqueue_task(task, cpu) do { } while (0) #define schedtune_dequeue_task(task, cpu) do { } while (0) @@ -33,6 +36,9 @@ int schedtune_accept_deltas(int nrg_delta, int cap_delta, #else /* CONFIG_SCHED_TUNE */ +#define schedtune_cpu_boost(cpu) 0 +#define schedtune_task_boost(tsk) 0 + #define schedtune_enqueue_task(task, cpu) do { } while (0) #define schedtune_dequeue_task(task, cpu) do { } while (0) -- 2.34.1