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.

timers: Move timer sysctl into the timer code

This is part of the effort to reduce kernel/sysctl.c to only contain the
core logic.

Signed-off-by: tangmeng <tangmeng@uniontech.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20220215065019.7520-1-tangmeng@uniontech.com

authored by

tangmeng and committed by
Thomas Gleixner
efaa0227 2966a991

+38 -34
-8
include/linux/timer.h
··· 196 196 struct hrtimer; 197 197 extern enum hrtimer_restart it_real_fn(struct hrtimer *); 198 198 199 - #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) 200 - struct ctl_table; 201 - 202 - extern unsigned int sysctl_timer_migration; 203 - int timer_migration_handler(struct ctl_table *table, int write, 204 - void *buffer, size_t *lenp, loff_t *ppos); 205 - #endif 206 - 207 199 unsigned long __round_jiffies(unsigned long j, int cpu); 208 200 unsigned long __round_jiffies_relative(unsigned long j, int cpu); 209 201 unsigned long round_jiffies(unsigned long j);
-11
kernel/sysctl.c
··· 2288 2288 .extra1 = SYSCTL_ZERO, 2289 2289 .extra2 = SYSCTL_ONE, 2290 2290 }, 2291 - #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) 2292 - { 2293 - .procname = "timer_migration", 2294 - .data = &sysctl_timer_migration, 2295 - .maxlen = sizeof(unsigned int), 2296 - .mode = 0644, 2297 - .proc_handler = timer_migration_handler, 2298 - .extra1 = SYSCTL_ZERO, 2299 - .extra2 = SYSCTL_ONE, 2300 - }, 2301 - #endif 2302 2291 #ifdef CONFIG_BPF_SYSCALL 2303 2292 { 2304 2293 .procname = "unprivileged_bpf_disabled",
+38 -15
kernel/time/timer.c
··· 44 44 #include <linux/slab.h> 45 45 #include <linux/compat.h> 46 46 #include <linux/random.h> 47 + #include <linux/sysctl.h> 47 48 48 49 #include <linux/uaccess.h> 49 50 #include <asm/unistd.h> ··· 224 223 static DECLARE_WORK(timer_update_work, timer_update_keys); 225 224 226 225 #ifdef CONFIG_SMP 227 - unsigned int sysctl_timer_migration = 1; 226 + static unsigned int sysctl_timer_migration = 1; 228 227 229 228 DEFINE_STATIC_KEY_FALSE(timers_migration_enabled); 230 229 ··· 235 234 else 236 235 static_branch_disable(&timers_migration_enabled); 237 236 } 238 - #else 237 + 238 + #ifdef CONFIG_SYSCTL 239 + static int timer_migration_handler(struct ctl_table *table, int write, 240 + void *buffer, size_t *lenp, loff_t *ppos) 241 + { 242 + int ret; 243 + 244 + mutex_lock(&timer_keys_mutex); 245 + ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 246 + if (!ret && write) 247 + timers_update_migration(); 248 + mutex_unlock(&timer_keys_mutex); 249 + return ret; 250 + } 251 + 252 + static struct ctl_table timer_sysctl[] = { 253 + { 254 + .procname = "timer_migration", 255 + .data = &sysctl_timer_migration, 256 + .maxlen = sizeof(unsigned int), 257 + .mode = 0644, 258 + .proc_handler = timer_migration_handler, 259 + .extra1 = SYSCTL_ZERO, 260 + .extra2 = SYSCTL_ONE, 261 + }, 262 + {} 263 + }; 264 + 265 + static int __init timer_sysctl_init(void) 266 + { 267 + register_sysctl("kernel", timer_sysctl); 268 + return 0; 269 + } 270 + device_initcall(timer_sysctl_init); 271 + #endif /* CONFIG_SYSCTL */ 272 + #else /* CONFIG_SMP */ 239 273 static inline void timers_update_migration(void) { } 240 274 #endif /* !CONFIG_SMP */ 241 275 ··· 285 249 void timers_update_nohz(void) 286 250 { 287 251 schedule_work(&timer_update_work); 288 - } 289 - 290 - int timer_migration_handler(struct ctl_table *table, int write, 291 - void *buffer, size_t *lenp, loff_t *ppos) 292 - { 293 - int ret; 294 - 295 - mutex_lock(&timer_keys_mutex); 296 - ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 297 - if (!ret && write) 298 - timers_update_migration(); 299 - mutex_unlock(&timer_keys_mutex); 300 - return ret; 301 252 } 302 253 303 254 static inline bool is_timers_nohz_active(void)