Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cpufreq: ondemand: Simplify idle cputime granularity test

cpufreq calls get_cpu_idle_time_us() just to know if idle cputime
accounting has a nanoseconds granularity.

Use the appropriate indicator instead to make that deduction.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://patch.msgid.link/aXozx0PXutnm8ECX@localhost.localdomain
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Frederic Weisbecker and committed by
Rafael J. Wysocki
a554a25e cc764d3b

+12 -11
+1 -6
drivers/cpufreq/cpufreq_ondemand.c
··· 334 334 static int od_init(struct dbs_data *dbs_data) 335 335 { 336 336 struct od_dbs_tuners *tuners; 337 - u64 idle_time; 338 - int cpu; 339 337 340 338 tuners = kzalloc(sizeof(*tuners), GFP_KERNEL); 341 339 if (!tuners) 342 340 return -ENOMEM; 343 341 344 - cpu = get_cpu(); 345 - idle_time = get_cpu_idle_time_us(cpu, NULL); 346 - put_cpu(); 347 - if (idle_time != -1ULL) { 342 + if (tick_nohz_is_active()) { 348 343 /* Idle micro accounting is supported. Use finer thresholds */ 349 344 dbs_data->up_threshold = MICRO_FREQUENCY_UP_THRESHOLD; 350 345 } else {
+2
include/linux/tick.h
··· 126 126 127 127 #ifdef CONFIG_NO_HZ_COMMON 128 128 extern bool tick_nohz_enabled; 129 + extern bool tick_nohz_is_active(void); 129 130 extern bool tick_nohz_tick_stopped(void); 130 131 extern bool tick_nohz_tick_stopped_cpu(int cpu); 131 132 extern void tick_nohz_idle_stop_tick(void); ··· 143 142 extern u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time); 144 143 #else /* !CONFIG_NO_HZ_COMMON */ 145 144 #define tick_nohz_enabled (0) 145 + static inline bool tick_nohz_is_active(void) { return false; } 146 146 static inline int tick_nohz_tick_stopped(void) { return 0; } 147 147 static inline int tick_nohz_tick_stopped_cpu(int cpu) { return 0; } 148 148 static inline void tick_nohz_idle_stop_tick(void) { }
+1 -1
kernel/time/hrtimer.c
··· 943 943 cpumask_var_t mask; 944 944 int cpu; 945 945 946 - if (!hrtimer_hres_active(cpu_base) && !tick_nohz_active) 946 + if (!hrtimer_hres_active(cpu_base) && !tick_nohz_is_active()) 947 947 goto out_timerfd; 948 948 949 949 if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) {
-2
kernel/time/tick-internal.h
··· 156 156 #endif 157 157 158 158 #ifdef CONFIG_NO_HZ_COMMON 159 - extern unsigned long tick_nohz_active; 160 159 extern void timers_update_nohz(void); 161 160 extern u64 get_jiffies_update(unsigned long *basej); 162 161 # ifdef CONFIG_SMP ··· 170 171 # endif 171 172 #else /* CONFIG_NO_HZ_COMMON */ 172 173 static inline void timers_update_nohz(void) { } 173 - #define tick_nohz_active (0) 174 174 #endif 175 175 176 176 DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
+7 -1
kernel/time/tick-sched.c
··· 693 693 * NO HZ enabled ? 694 694 */ 695 695 bool tick_nohz_enabled __read_mostly = true; 696 - unsigned long tick_nohz_active __read_mostly; 696 + static unsigned long tick_nohz_active __read_mostly; 697 697 /* 698 698 * Enable / Disable tickless mode 699 699 */ ··· 703 703 } 704 704 705 705 __setup("nohz=", setup_tick_nohz); 706 + 707 + bool tick_nohz_is_active(void) 708 + { 709 + return tick_nohz_active; 710 + } 711 + EXPORT_SYMBOL_GPL(tick_nohz_is_active); 706 712 707 713 bool tick_nohz_tick_stopped(void) 708 714 {
+1 -1
kernel/time/timer.c
··· 281 281 282 282 static void timers_update_migration(void) 283 283 { 284 - if (sysctl_timer_migration && tick_nohz_active) 284 + if (sysctl_timer_migration && tick_nohz_is_active()) 285 285 static_branch_enable(&timers_migration_enabled); 286 286 else 287 287 static_branch_disable(&timers_migration_enabled);