Skip to content

Commit

Permalink
kernel/time: move timer sysctls to its own file
Browse files Browse the repository at this point in the history
kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
dishes, this makes it very difficult to maintain.

To help with this maintenance let's start by moving sysctls to places
where they actually belong.  The proc sysctl maintainers do not want to
know what sysctl knobs you wish to add for your own piece of code, we
just care about the core logic.

So move the timer_migration sysctls to its own file.

Signed-off-by: tangmeng <tangmeng@uniontech.com>
  • Loading branch information
imtangmeng authored and intel-lab-lkp committed Jan 31, 2022
1 parent 35e13e9 commit c54967d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
4 changes: 0 additions & 4 deletions include/linux/timer.h
Expand Up @@ -198,10 +198,6 @@ extern enum hrtimer_restart it_real_fn(struct hrtimer *);

#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
struct ctl_table;

extern unsigned int sysctl_timer_migration;
int timer_migration_handler(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos);
#endif

unsigned long __round_jiffies(unsigned long j, int cpu);
Expand Down
11 changes: 0 additions & 11 deletions kernel/sysctl.c
Expand Up @@ -2656,17 +2656,6 @@ static struct ctl_table kern_table[] = {
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
{
.procname = "timer_migration",
.data = &sysctl_timer_migration,
.maxlen = sizeof(unsigned int),
.mode = 0644,
.proc_handler = timer_migration_handler,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
#endif
#ifdef CONFIG_BPF_SYSCALL
{
.procname = "unprivileged_bpf_disabled",
Expand Down
26 changes: 24 additions & 2 deletions kernel/time/timer.c
Expand Up @@ -44,6 +44,7 @@
#include <linux/slab.h>
#include <linux/compat.h>
#include <linux/random.h>
#include <linux/sysctl.h>

#include <linux/uaccess.h>
#include <asm/unistd.h>
Expand Down Expand Up @@ -223,7 +224,7 @@ static void timer_update_keys(struct work_struct *work);
static DECLARE_WORK(timer_update_work, timer_update_keys);

#ifdef CONFIG_SMP
unsigned int sysctl_timer_migration = 1;
static unsigned int sysctl_timer_migration = 1;

DEFINE_STATIC_KEY_FALSE(timers_migration_enabled);

Expand Down Expand Up @@ -251,7 +252,8 @@ void timers_update_nohz(void)
schedule_work(&timer_update_work);
}

int timer_migration_handler(struct ctl_table *table, int write,
#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
static int timer_migration_handler(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
int ret;
Expand All @@ -264,6 +266,26 @@ int timer_migration_handler(struct ctl_table *table, int write,
return ret;
}

static struct ctl_table timer_sysctl[] = {
{
.procname = "timer_migration",
.data = &sysctl_timer_migration,
.maxlen = sizeof(unsigned int),
.mode = 0644,
.proc_handler = timer_migration_handler,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
{}
};

static int __init timer_sysctl_init(void)
{
register_sysctl_init("kernel", timer_sysctl);
return 0;
}
__initcall(timer_sysctl_init);
#endif
static inline bool is_timers_nohz_active(void)
{
return static_branch_unlikely(&timers_nohz_active);
Expand Down

0 comments on commit c54967d

Please sign in to comment.