Skip to content

Commit 3267e01

Browse files
nizhenthmcgrof
authored andcommitted
sched: Move uclamp_util sysctls to core.c
move uclamp_util sysctls to core.c and use the new register_sysctl_init() to register the sysctl interface. Signed-off-by: Zhen Ni <nizhen@uniontech.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
1 parent 28f152c commit 3267e01

3 files changed

Lines changed: 37 additions & 42 deletions

File tree

include/linux/sched/sysctl.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,10 @@ extern int sysctl_numa_balancing_mode;
3131
#define sysctl_numa_balancing_mode 0
3232
#endif
3333

34-
#ifdef CONFIG_UCLAMP_TASK
35-
extern unsigned int sysctl_sched_uclamp_util_min;
36-
extern unsigned int sysctl_sched_uclamp_util_max;
37-
extern unsigned int sysctl_sched_uclamp_util_min_rt_default;
38-
#endif
39-
4034
#ifdef CONFIG_CFS_BANDWIDTH
4135
extern unsigned int sysctl_sched_cfs_bandwidth_slice;
4236
#endif
4337

44-
int sysctl_sched_uclamp_handler(struct ctl_table *table, int write,
45-
void *buffer, size_t *lenp, loff_t *ppos);
4638
int sysctl_numa_balancing(struct ctl_table *table, int write, void *buffer,
4739
size_t *lenp, loff_t *ppos);
4840

kernel/sched/core.c

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,10 +1306,10 @@ static void set_load_weight(struct task_struct *p, bool update_load)
13061306
static DEFINE_MUTEX(uclamp_mutex);
13071307

13081308
/* Max allowed minimum utilization */
1309-
unsigned int sysctl_sched_uclamp_util_min = SCHED_CAPACITY_SCALE;
1309+
static unsigned int sysctl_sched_uclamp_util_min = SCHED_CAPACITY_SCALE;
13101310

13111311
/* Max allowed maximum utilization */
1312-
unsigned int sysctl_sched_uclamp_util_max = SCHED_CAPACITY_SCALE;
1312+
static unsigned int sysctl_sched_uclamp_util_max = SCHED_CAPACITY_SCALE;
13131313

13141314
/*
13151315
* By default RT tasks run at the maximum performance point/capacity of the
@@ -1326,7 +1326,7 @@ unsigned int sysctl_sched_uclamp_util_max = SCHED_CAPACITY_SCALE;
13261326
* This knob will not override the system default sched_util_clamp_min defined
13271327
* above.
13281328
*/
1329-
unsigned int sysctl_sched_uclamp_util_min_rt_default = SCHED_CAPACITY_SCALE;
1329+
static unsigned int sysctl_sched_uclamp_util_min_rt_default = SCHED_CAPACITY_SCALE;
13301330

13311331
/* All clamps are required to be less or equal than these values */
13321332
static struct uclamp_se uclamp_default[UCLAMP_CNT];
@@ -1779,7 +1779,7 @@ static void uclamp_update_root_tg(void)
17791779
static void uclamp_update_root_tg(void) { }
17801780
#endif
17811781

1782-
int sysctl_sched_uclamp_handler(struct ctl_table *table, int write,
1782+
static int sysctl_sched_uclamp_handler(struct ctl_table *table, int write,
17831783
void *buffer, size_t *lenp, loff_t *ppos)
17841784
{
17851785
bool update_root_tg = false;
@@ -4436,8 +4436,12 @@ static int sysctl_schedstats(struct ctl_table *table, int write, void *buffer,
44364436
set_schedstats(state);
44374437
return err;
44384438
}
4439+
#endif /* CONFIG_PROC_SYSCTL */
4440+
#endif /* CONFIG_SCHEDSTATS */
44394441

4440-
static struct ctl_table sched_schedstats_sysctls[] = {
4442+
#ifdef CONFIG_SYSCTL
4443+
static struct ctl_table sched_core_sysctls[] = {
4444+
#ifdef CONFIG_SCHEDSTATS
44414445
{
44424446
.procname = "sched_schedstats",
44434447
.data = NULL,
@@ -4447,17 +4451,39 @@ static struct ctl_table sched_schedstats_sysctls[] = {
44474451
.extra1 = SYSCTL_ZERO,
44484452
.extra2 = SYSCTL_ONE,
44494453
},
4454+
#endif /* CONFIG_SCHEDSTATS */
4455+
#ifdef CONFIG_UCLAMP_TASK
4456+
{
4457+
.procname = "sched_util_clamp_min",
4458+
.data = &sysctl_sched_uclamp_util_min,
4459+
.maxlen = sizeof(unsigned int),
4460+
.mode = 0644,
4461+
.proc_handler = sysctl_sched_uclamp_handler,
4462+
},
4463+
{
4464+
.procname = "sched_util_clamp_max",
4465+
.data = &sysctl_sched_uclamp_util_max,
4466+
.maxlen = sizeof(unsigned int),
4467+
.mode = 0644,
4468+
.proc_handler = sysctl_sched_uclamp_handler,
4469+
},
4470+
{
4471+
.procname = "sched_util_clamp_min_rt_default",
4472+
.data = &sysctl_sched_uclamp_util_min_rt_default,
4473+
.maxlen = sizeof(unsigned int),
4474+
.mode = 0644,
4475+
.proc_handler = sysctl_sched_uclamp_handler,
4476+
},
4477+
#endif /* CONFIG_UCLAMP_TASK */
44504478
{}
44514479
};
4452-
4453-
static int __init sched_schedstats_sysctl_init(void)
4480+
static int __init sched_core_sysctl_init(void)
44544481
{
4455-
register_sysctl_init("kernel", sched_schedstats_sysctls);
4482+
register_sysctl_init("kernel", sched_core_sysctls);
44564483
return 0;
44574484
}
4458-
late_initcall(sched_schedstats_sysctl_init);
4459-
#endif /* CONFIG_PROC_SYSCTL */
4460-
#endif /* CONFIG_SCHEDSTATS */
4485+
late_initcall(sched_core_sysctl_init);
4486+
#endif /* CONFIG_SYSCTL */
44614487

44624488
/*
44634489
* fork()/clone()-time setup:

kernel/sysctl.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,29 +1681,6 @@ static struct ctl_table kern_table[] = {
16811681
.extra2 = SYSCTL_FOUR,
16821682
},
16831683
#endif /* CONFIG_NUMA_BALANCING */
1684-
#ifdef CONFIG_UCLAMP_TASK
1685-
{
1686-
.procname = "sched_util_clamp_min",
1687-
.data = &sysctl_sched_uclamp_util_min,
1688-
.maxlen = sizeof(unsigned int),
1689-
.mode = 0644,
1690-
.proc_handler = sysctl_sched_uclamp_handler,
1691-
},
1692-
{
1693-
.procname = "sched_util_clamp_max",
1694-
.data = &sysctl_sched_uclamp_util_max,
1695-
.maxlen = sizeof(unsigned int),
1696-
.mode = 0644,
1697-
.proc_handler = sysctl_sched_uclamp_handler,
1698-
},
1699-
{
1700-
.procname = "sched_util_clamp_min_rt_default",
1701-
.data = &sysctl_sched_uclamp_util_min_rt_default,
1702-
.maxlen = sizeof(unsigned int),
1703-
.mode = 0644,
1704-
.proc_handler = sysctl_sched_uclamp_handler,
1705-
},
1706-
#endif
17071684
#ifdef CONFIG_CFS_BANDWIDTH
17081685
{
17091686
.procname = "sched_cfs_bandwidth_slice_us",

0 commit comments

Comments
 (0)