Skip to content

Commit d9ab0e6

Browse files
nizhenthmcgrof
authored andcommitted
sched: Move rt_period/runtime sysctls to rt.c
move rt_period/runtime sysctls to rt.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 f5ef06d commit d9ab0e6

6 files changed

Lines changed: 48 additions & 39 deletions

File tree

include/linux/sched/sysctl.h

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

34-
/*
35-
* control realtime throttling:
36-
*
37-
* /proc/sys/kernel/sched_rt_period_us
38-
* /proc/sys/kernel/sched_rt_runtime_us
39-
*/
40-
extern unsigned int sysctl_sched_rt_period;
41-
extern int sysctl_sched_rt_runtime;
42-
4334
extern unsigned int sysctl_sched_dl_period_max;
4435
extern unsigned int sysctl_sched_dl_period_min;
4536

@@ -58,8 +49,6 @@ extern int sched_rr_timeslice;
5849

5950
int sched_rr_handler(struct ctl_table *table, int write, void *buffer,
6051
size_t *lenp, loff_t *ppos);
61-
int sched_rt_handler(struct ctl_table *table, int write, void *buffer,
62-
size_t *lenp, loff_t *ppos);
6352
int sysctl_sched_uclamp_handler(struct ctl_table *table, int write,
6453
void *buffer, size_t *lenp, loff_t *ppos);
6554
int sysctl_numa_balancing(struct ctl_table *table, int write, void *buffer,

kernel/rcu/rcu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#define RCU_SEQ_CTR_SHIFT 2
2424
#define RCU_SEQ_STATE_MASK ((1 << RCU_SEQ_CTR_SHIFT) - 1)
2525

26+
extern int sysctl_sched_rt_runtime;
27+
2628
/*
2729
* Return the counter portion of a sequence number previously returned
2830
* by rcu_seq_snap() or rcu_seq_current().

kernel/sched/core.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,6 @@ const_debug unsigned int sysctl_sched_nr_migrate = 8;
145145
const_debug unsigned int sysctl_sched_nr_migrate = 32;
146146
#endif
147147

148-
/*
149-
* period over which we measure -rt task CPU usage in us.
150-
* default: 1s
151-
*/
152-
unsigned int sysctl_sched_rt_period = 1000000;
153-
154148
__read_mostly int scheduler_running;
155149

156150
#ifdef CONFIG_SCHED_CORE
@@ -444,13 +438,6 @@ sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags) { }
444438

445439
#endif /* CONFIG_SCHED_CORE */
446440

447-
/*
448-
* part of the period that we allow rt tasks to run in us.
449-
* default: 0.95s
450-
*/
451-
int sysctl_sched_rt_runtime = 950000;
452-
453-
454441
/*
455442
* Serialization rules:
456443
*

kernel/sched/rt.c

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,47 @@ static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun);
1313

1414
struct rt_bandwidth def_rt_bandwidth;
1515

16+
/*
17+
* period over which we measure -rt task CPU usage in us.
18+
* default: 1s
19+
*/
20+
unsigned int sysctl_sched_rt_period = 1000000;
21+
22+
/*
23+
* part of the period that we allow rt tasks to run in us.
24+
* default: 0.95s
25+
*/
26+
int sysctl_sched_rt_runtime = 950000;
27+
28+
static int sched_rt_handler(struct ctl_table *table, int write, void *buffer,
29+
size_t *lenp, loff_t *ppos);
30+
#ifdef CONFIG_SYSCTL
31+
static struct ctl_table sched_rt_sysctls[] = {
32+
{
33+
.procname = "sched_rt_period_us",
34+
.data = &sysctl_sched_rt_period,
35+
.maxlen = sizeof(unsigned int),
36+
.mode = 0644,
37+
.proc_handler = sched_rt_handler,
38+
},
39+
{
40+
.procname = "sched_rt_runtime_us",
41+
.data = &sysctl_sched_rt_runtime,
42+
.maxlen = sizeof(int),
43+
.mode = 0644,
44+
.proc_handler = sched_rt_handler,
45+
},
46+
{}
47+
};
48+
49+
static int __init sched_rt_sysctl_init(void)
50+
{
51+
register_sysctl_init("kernel", sched_rt_sysctls);
52+
return 0;
53+
}
54+
late_initcall(sched_rt_sysctl_init);
55+
#endif
56+
1657
static enum hrtimer_restart sched_rt_period_timer(struct hrtimer *timer)
1758
{
1859
struct rt_bandwidth *rt_b =
@@ -2925,7 +2966,7 @@ static void sched_rt_do_global(void)
29252966
raw_spin_unlock_irqrestore(&def_rt_bandwidth.rt_runtime_lock, flags);
29262967
}
29272968

2928-
int sched_rt_handler(struct ctl_table *table, int write, void *buffer,
2969+
static int sched_rt_handler(struct ctl_table *table, int write, void *buffer,
29292970
size_t *lenp, loff_t *ppos)
29302971
{
29312972
int old_period, old_runtime;

kernel/sched/sched.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ extern void calc_global_load_tick(struct rq *this_rq);
114114
extern long calc_load_fold_active(struct rq *this_rq, long adjust);
115115

116116
extern void call_trace_sched_update_nr_running(struct rq *rq, int count);
117+
118+
extern unsigned int sysctl_sched_rt_period;
119+
extern int sysctl_sched_rt_runtime;
120+
117121
/*
118122
* Helpers for converting nanosecond timing to jiffy resolution
119123
*/

kernel/sysctl.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,20 +1681,6 @@ static struct ctl_table kern_table[] = {
16811681
.extra2 = SYSCTL_FOUR,
16821682
},
16831683
#endif /* CONFIG_NUMA_BALANCING */
1684-
{
1685-
.procname = "sched_rt_period_us",
1686-
.data = &sysctl_sched_rt_period,
1687-
.maxlen = sizeof(unsigned int),
1688-
.mode = 0644,
1689-
.proc_handler = sched_rt_handler,
1690-
},
1691-
{
1692-
.procname = "sched_rt_runtime_us",
1693-
.data = &sysctl_sched_rt_runtime,
1694-
.maxlen = sizeof(int),
1695-
.mode = 0644,
1696-
.proc_handler = sched_rt_handler,
1697-
},
16981684
{
16991685
.procname = "sched_deadline_period_max_us",
17001686
.data = &sysctl_sched_dl_period_max,

0 commit comments

Comments
 (0)