]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched/fair: Encapsulate set custom slice in a __setparam_fair() function
authorVincent Guittot <vincent.guittot@linaro.org>
Sat, 11 Jan 2025 09:14:09 +0000 (10:14 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 13 Jan 2025 13:10:22 +0000 (14:10 +0100)
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 <vincent.guittot@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Phil Auld <pauld@redhat.com>
Link: https://lore.kernel.org/r/20250110144656.484601-1-vincent.guittot@linaro.org
kernel/sched/fair.c
kernel/sched/sched.h
kernel/sched/syscalls.c

index b3418b5d484f8b8479b618bae1e7ba09c88cd57b..7ec25874a819fc75ffdd9bef31257e4004053063 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/sched/cputime.h>
 #include <linux/sched/isolation.h>
 #include <linux/sched/nohz.h>
+#include <linux/sched/prio.h>
 
 #include <linux/cpuidle.h>
 #include <linux/interrupt.h>
@@ -51,6 +52,8 @@
 
 #include <asm/switch_to.h>
 
+#include <uapi/linux/sched/types.h>
+
 #include "sched.h"
 #include "stats.h"
 #include "autogroup.h"
@@ -5258,6 +5261,22 @@ static inline void update_misfit_status(struct task_struct *p, struct rq *rq) {}
 
 #endif /* CONFIG_SMP */
 
+void __setparam_fair(struct task_struct *p, const struct sched_attr *attr)
+{
+       struct sched_entity *se = &p->se;
+
+       p->static_prio = NICE_TO_PRIO(attr->sched_nice);
+       if (attr->sched_runtime) {
+               se->custom_slice = 1;
+               se->slice = clamp_t(u64, attr->sched_runtime,
+                                     NSEC_PER_MSEC/10,   /* HZ=1000 * 10 */
+                                     NSEC_PER_MSEC*100); /* HZ=100  / 10 */
+       } else {
+               se->custom_slice = 0;
+               se->slice = sysctl_sched_base_slice;
+       }
+}
+
 static void
 place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
 {
index aef716c41edba8a6ec7d88db121fe0a9934b5264..300db6fe53eb1119519ff133c8550723d0f6431d 100644 (file)
@@ -3500,6 +3500,8 @@ unsigned long scale_irq_capacity(unsigned long util, unsigned long irq, unsigned
 
 #endif /* !CONFIG_HAVE_SCHED_AVG_IRQ */
 
+extern void __setparam_fair(struct task_struct *p, const struct sched_attr *attr);
+
 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
 
 #define perf_domain_span(pd) (to_cpumask(((pd)->em_pd->cpus)))
index 943406c4ee8650d2992fabdba888d27a9f6836c2..149e2c8036d36199b48009808a38d3345656b7ea 100644 (file)
@@ -300,20 +300,10 @@ static void __setscheduler_params(struct task_struct *p,
 
        p->policy = policy;
 
-       if (dl_policy(policy)) {
+       if (dl_policy(policy))
                __setparam_dl(p, attr);
-       } else if (fair_policy(policy)) {
-               p->static_prio = NICE_TO_PRIO(attr->sched_nice);
-               if (attr->sched_runtime) {
-                       p->se.custom_slice = 1;
-                       p->se.slice = clamp_t(u64, attr->sched_runtime,
-                                             NSEC_PER_MSEC/10,   /* HZ=1000 * 10 */
-                                             NSEC_PER_MSEC*100); /* HZ=100  / 10 */
-               } else {
-                       p->se.custom_slice = 0;
-                       p->se.slice = sysctl_sched_base_slice;
-               }
-       }
+       else if (fair_policy(policy))
+               __setparam_fair(p, attr);
 
        /* rt-policy tasks do not have a timerslack */
        if (rt_or_dl_task_policy(p)) {