Skip to content

Commit 2cf9ac4

Browse files
vingu-linaroPeter Zijlstra
authored andcommitted
sched/fair: Encapsulate set custom slice in a __setparam_fair() function
Similarly to dl, create a __setparam_fair() function to set parameters related to fair class and move it in the fair.c file. No functional changes expected Signed-off-by: Vincent Guittot <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Phil Auld <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5d808c7 commit 2cf9ac4

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

kernel/sched/fair.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <linux/sched/cputime.h>
3838
#include <linux/sched/isolation.h>
3939
#include <linux/sched/nohz.h>
40+
#include <linux/sched/prio.h>
4041

4142
#include <linux/cpuidle.h>
4243
#include <linux/interrupt.h>
@@ -51,6 +52,8 @@
5152

5253
#include <asm/switch_to.h>
5354

55+
#include <uapi/linux/sched/types.h>
56+
5457
#include "sched.h"
5558
#include "stats.h"
5659
#include "autogroup.h"
@@ -5258,6 +5261,22 @@ static inline void update_misfit_status(struct task_struct *p, struct rq *rq) {}
52585261

52595262
#endif /* CONFIG_SMP */
52605263

5264+
void __setparam_fair(struct task_struct *p, const struct sched_attr *attr)
5265+
{
5266+
struct sched_entity *se = &p->se;
5267+
5268+
p->static_prio = NICE_TO_PRIO(attr->sched_nice);
5269+
if (attr->sched_runtime) {
5270+
se->custom_slice = 1;
5271+
se->slice = clamp_t(u64, attr->sched_runtime,
5272+
NSEC_PER_MSEC/10, /* HZ=1000 * 10 */
5273+
NSEC_PER_MSEC*100); /* HZ=100 / 10 */
5274+
} else {
5275+
se->custom_slice = 0;
5276+
se->slice = sysctl_sched_base_slice;
5277+
}
5278+
}
5279+
52615280
static void
52625281
place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
52635282
{

kernel/sched/sched.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3500,6 +3500,8 @@ unsigned long scale_irq_capacity(unsigned long util, unsigned long irq, unsigned
35003500

35013501
#endif /* !CONFIG_HAVE_SCHED_AVG_IRQ */
35023502

3503+
extern void __setparam_fair(struct task_struct *p, const struct sched_attr *attr);
3504+
35033505
#if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
35043506

35053507
#define perf_domain_span(pd) (to_cpumask(((pd)->em_pd->cpus)))

kernel/sched/syscalls.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -300,20 +300,10 @@ static void __setscheduler_params(struct task_struct *p,
300300

301301
p->policy = policy;
302302

303-
if (dl_policy(policy)) {
303+
if (dl_policy(policy))
304304
__setparam_dl(p, attr);
305-
} else if (fair_policy(policy)) {
306-
p->static_prio = NICE_TO_PRIO(attr->sched_nice);
307-
if (attr->sched_runtime) {
308-
p->se.custom_slice = 1;
309-
p->se.slice = clamp_t(u64, attr->sched_runtime,
310-
NSEC_PER_MSEC/10, /* HZ=1000 * 10 */
311-
NSEC_PER_MSEC*100); /* HZ=100 / 10 */
312-
} else {
313-
p->se.custom_slice = 0;
314-
p->se.slice = sysctl_sched_base_slice;
315-
}
316-
}
305+
else if (fair_policy(policy))
306+
__setparam_fair(p, attr);
317307

318308
/* rt-policy tasks do not have a timerslack */
319309
if (rt_or_dl_task_policy(p)) {

0 commit comments

Comments
 (0)