diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-03-10 14:44:47 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-03-10 14:44:47 -0500 |
commit | adaf9fcd136970e480d7ca834c0cf25ce922ea74 (patch) | |
tree | 36183592da27e413b79f60705132ed84dd34006e /kernel/sched/sched.h | |
parent | 08f511fd41c3afe303eb9b41bff0570f7c1b6937 (diff) |
cpufreq: Move scheduler-related code to the sched directory
Create cpufreq.c under kernel/sched/ and move the cpufreq code
related to the scheduler to that file and to sched.h.
Redefine cpufreq_update_util() as a static inline function to avoid
function calls at its call sites in the scheduler code (as suggested
by Peter Zijlstra).
Also move the definition of struct update_util_data and declaration
of cpufreq_set_update_util_data() from include/linux/cpufreq.h to
include/linux/sched.h.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Diffstat (limited to 'kernel/sched/sched.h')
-rw-r--r-- | kernel/sched/sched.h | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index f042190c8002..faf7e2758dd0 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h | |||
@@ -9,7 +9,6 @@ | |||
9 | #include <linux/irq_work.h> | 9 | #include <linux/irq_work.h> |
10 | #include <linux/tick.h> | 10 | #include <linux/tick.h> |
11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
12 | #include <linux/cpufreq.h> | ||
13 | 12 | ||
14 | #include "cpupri.h" | 13 | #include "cpupri.h" |
15 | #include "cpudeadline.h" | 14 | #include "cpudeadline.h" |
@@ -1739,3 +1738,51 @@ static inline u64 irq_time_read(int cpu) | |||
1739 | } | 1738 | } |
1740 | #endif /* CONFIG_64BIT */ | 1739 | #endif /* CONFIG_64BIT */ |
1741 | #endif /* CONFIG_IRQ_TIME_ACCOUNTING */ | 1740 | #endif /* CONFIG_IRQ_TIME_ACCOUNTING */ |
1741 | |||
1742 | #ifdef CONFIG_CPU_FREQ | ||
1743 | DECLARE_PER_CPU(struct update_util_data *, cpufreq_update_util_data); | ||
1744 | |||
1745 | /** | ||
1746 | * cpufreq_update_util - Take a note about CPU utilization changes. | ||
1747 | * @time: Current time. | ||
1748 | * @util: Current utilization. | ||
1749 | * @max: Utilization ceiling. | ||
1750 | * | ||
1751 | * This function is called by the scheduler on every invocation of | ||
1752 | * update_load_avg() on the CPU whose utilization is being updated. | ||
1753 | * | ||
1754 | * It can only be called from RCU-sched read-side critical sections. | ||
1755 | */ | ||
1756 | static inline void cpufreq_update_util(u64 time, unsigned long util, unsigned long max) | ||
1757 | { | ||
1758 | struct update_util_data *data; | ||
1759 | |||
1760 | data = rcu_dereference_sched(*this_cpu_ptr(&cpufreq_update_util_data)); | ||
1761 | if (data) | ||
1762 | data->func(data, time, util, max); | ||
1763 | } | ||
1764 | |||
1765 | /** | ||
1766 | * cpufreq_trigger_update - Trigger CPU performance state evaluation if needed. | ||
1767 | * @time: Current time. | ||
1768 | * | ||
1769 | * The way cpufreq is currently arranged requires it to evaluate the CPU | ||
1770 | * performance state (frequency/voltage) on a regular basis to prevent it from | ||
1771 | * being stuck in a completely inadequate performance level for too long. | ||
1772 | * That is not guaranteed to happen if the updates are only triggered from CFS, | ||
1773 | * though, because they may not be coming in if RT or deadline tasks are active | ||
1774 | * all the time (or there are RT and DL tasks only). | ||
1775 | * | ||
1776 | * As a workaround for that issue, this function is called by the RT and DL | ||
1777 | * sched classes to trigger extra cpufreq updates to prevent it from stalling, | ||
1778 | * but that really is a band-aid. Going forward it should be replaced with | ||
1779 | * solutions targeted more specifically at RT and DL tasks. | ||
1780 | */ | ||
1781 | static inline void cpufreq_trigger_update(u64 time) | ||
1782 | { | ||
1783 | cpufreq_update_util(time, ULONG_MAX, 0); | ||
1784 | } | ||
1785 | #else | ||
1786 | static inline void cpufreq_update_util(u64 time, unsigned long util, unsigned long max) {} | ||
1787 | static inline void cpufreq_trigger_update(u64 time) {} | ||
1788 | #endif /* CONFIG_CPU_FREQ */ | ||