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>
@@ -223,7 +224,7 @@ static void timer_update_keys(struct work_struct *work);
223
224
static DECLARE_WORK (timer_update_work , timer_update_keys ) ;
224
225
225
226
#ifdef CONFIG_SMP
226
- unsigned int sysctl_timer_migration = 1 ;
227
+ static unsigned int sysctl_timer_migration = 1 ;
227
228
228
229
DEFINE_STATIC_KEY_FALSE (timers_migration_enabled );
229
230
@@ -234,7 +235,42 @@ static void timers_update_migration(void)
234
235
else
235
236
static_branch_disable (& timers_migration_enabled );
236
237
}
237
- #else
238
+
239
+ #ifdef CONFIG_SYSCTL
240
+ static int timer_migration_handler (struct ctl_table * table , int write ,
241
+ void * buffer , size_t * lenp , loff_t * ppos )
242
+ {
243
+ int ret ;
244
+
245
+ mutex_lock (& timer_keys_mutex );
246
+ ret = proc_dointvec_minmax (table , write , buffer , lenp , ppos );
247
+ if (!ret && write )
248
+ timers_update_migration ();
249
+ mutex_unlock (& timer_keys_mutex );
250
+ return ret ;
251
+ }
252
+
253
+ static struct ctl_table timer_sysctl [] = {
254
+ {
255
+ .procname = "timer_migration" ,
256
+ .data = & sysctl_timer_migration ,
257
+ .maxlen = sizeof (unsigned int ),
258
+ .mode = 0644 ,
259
+ .proc_handler = timer_migration_handler ,
260
+ .extra1 = SYSCTL_ZERO ,
261
+ .extra2 = SYSCTL_ONE ,
262
+ },
263
+ {}
264
+ };
265
+
266
+ static int __init timer_sysctl_init (void )
267
+ {
268
+ register_sysctl ("kernel" , timer_sysctl );
269
+ return 0 ;
270
+ }
271
+ device_initcall (timer_sysctl_init );
272
+ #endif /* CONFIG_SYSCTL */
273
+ #else /* CONFIG_SMP */
238
274
static inline void timers_update_migration (void ) { }
239
275
#endif /* !CONFIG_SMP */
240
276
@@ -251,19 +287,6 @@ void timers_update_nohz(void)
251
287
schedule_work (& timer_update_work );
252
288
}
253
289
254
- int timer_migration_handler (struct ctl_table * table , int write ,
255
- void * buffer , size_t * lenp , loff_t * ppos )
256
- {
257
- int ret ;
258
-
259
- mutex_lock (& timer_keys_mutex );
260
- ret = proc_dointvec_minmax (table , write , buffer , lenp , ppos );
261
- if (!ret && write )
262
- timers_update_migration ();
263
- mutex_unlock (& timer_keys_mutex );
264
- return ret ;
265
- }
266
-
267
290
static inline bool is_timers_nohz_active (void )
268
291
{
269
292
return static_branch_unlikely (& timers_nohz_active );
0 commit comments