anolis: sched: introduce sysctl_sched_acpu_enabled
ANBZ: #6729 In order to be able to dynamically turn on and off acpu accounting, we introduce sysctl_sched_acpu_enabled, instead of default on. Signed-off-by: Cruz Zhao <CruzZhao@linux.alibaba.com> Reviewed-by: Guixin Liu <kanie@linux.alibaba.com> Link: https://gitee.com/anolis/cloud-kernel/pulls/2260
This commit is contained in:
parent
b8c642c811
commit
78300c148f
|
@ -2351,10 +2351,4 @@ static inline void sched_core_fork(struct task_struct *p) { }
|
|||
static inline int sched_core_idle_cpu(int cpu) { return idle_cpu(cpu); }
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCHED_ACPU
|
||||
extern void acpu_enable(void);
|
||||
#else
|
||||
static inline void acpu_enable(void) { }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -120,4 +120,10 @@ int sched_energy_aware_handler(struct ctl_table *table, int write,
|
|||
void *buffer, size_t *lenp, loff_t *ppos);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCHED_ACPU
|
||||
extern unsigned int sysctl_sched_acpu_enabled;
|
||||
extern int sched_acpu_enable_handler(struct ctl_table *table, int write,
|
||||
void __user *buffer, size_t *lenp,
|
||||
loff_t *ppos);
|
||||
#endif
|
||||
#endif /* _LINUX_SCHED_SYSCTL_H */
|
||||
|
|
|
@ -79,6 +79,7 @@ unsigned int sysctl_sched_cfs_bw_burst_enabled = 1;
|
|||
|
||||
#ifdef CONFIG_SCHED_ACPU
|
||||
DEFINE_STATIC_KEY_FALSE(acpu_enabled);
|
||||
unsigned int sysctl_sched_acpu_enabled;
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -3918,7 +3919,7 @@ fire_sched_out_preempt_notifiers(struct task_struct *curr,
|
|||
#endif /* CONFIG_PREEMPT_NOTIFIERS */
|
||||
|
||||
#ifdef CONFIG_SCHED_ACPU
|
||||
void acpu_enable(void)
|
||||
static void acpu_enable(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -3931,6 +3932,35 @@ void acpu_enable(void)
|
|||
static_branch_enable(&acpu_enabled);
|
||||
}
|
||||
|
||||
static void acpu_disable(void)
|
||||
{
|
||||
static_branch_disable(&acpu_enabled);
|
||||
}
|
||||
|
||||
int sched_acpu_enable_handler(struct ctl_table *table, int write, void __user *buffer,
|
||||
size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
int ret;
|
||||
unsigned int old, new;
|
||||
|
||||
if (!write) {
|
||||
ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
|
||||
return ret;
|
||||
}
|
||||
|
||||
old = sysctl_sched_acpu_enabled;
|
||||
ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
|
||||
new = sysctl_sched_acpu_enabled;
|
||||
if (!ret && write && (old != new)) {
|
||||
if (new)
|
||||
acpu_enable();
|
||||
else
|
||||
acpu_disable();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void update_acpu(struct rq *rq, struct task_struct *prev, struct task_struct *next)
|
||||
{
|
||||
const int cpu = cpu_of(rq);
|
||||
|
|
|
@ -73,7 +73,6 @@ void __init idle_threads_init(void)
|
|||
if (cpu != boot_cpu)
|
||||
idle_init(cpu);
|
||||
}
|
||||
acpu_enable();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2047,6 +2047,17 @@ static struct ctl_table kern_table[] = {
|
|||
.extra2 = SYSCTL_ONE,
|
||||
},
|
||||
#endif
|
||||
#ifdef CONFIG_SCHED_ACPU
|
||||
{
|
||||
.procname = "sched_acpu",
|
||||
.data = &sysctl_sched_acpu_enabled,
|
||||
.maxlen = sizeof(unsigned int),
|
||||
.mode = 0644,
|
||||
.proc_handler = sched_acpu_enable_handler,
|
||||
.extra1 = SYSCTL_ZERO,
|
||||
.extra2 = SYSCTL_ONE,
|
||||
},
|
||||
#endif /* CONFIG_SCHED_ACPU*/
|
||||
#ifdef CONFIG_PROVE_LOCKING
|
||||
{
|
||||
.procname = "prove_locking",
|
||||
|
|
Loading…
Reference in New Issue