From nobody Sun Feb 8 14:56:38 2026 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00BF6211473 for ; Fri, 10 Jan 2025 14:47:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736520424; cv=none; b=l9TKXFXpSP4/TkS4/fOYJbvt3KVSuRilrVrbhgYfWgG1n4TGDGKedOFb9bosIHiKkPFdaqrKl+wPSiKNgEE+n05rqqKGpEaxeoUNP54v30KNtgZgtkZUTQ51a75iUhWAHVx6S7BR9uREG9kTpB3cD60pwduO1y9H2up1KBjOlYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736520424; c=relaxed/simple; bh=4pX4LDArqvvykaDnEsdctG8R7901L8X2xBIrvdJ+5j8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=emFMia3MSBNV4iEvupver6w5QLo4ubs/icKMqpmWiekPzZhSnVnL2Dl2jHCx22ovmT6lch0BMlt5AJcUfHAQZtBdqmySYtDj9cCc5dvNOFWzL/9b/MQRzrFvDdtv3QnQaZIUl+das24TjjKCGYdXaTHRKDYy+joJi9FliNtbCfI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=TyIagzIH; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TyIagzIH" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-38637614567so1108598f8f.3 for ; Fri, 10 Jan 2025 06:47:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736520420; x=1737125220; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6dmBV/auP82f6hBm4EolXOpttlJRasyacpX+yDPVeCs=; b=TyIagzIH3MASBa43kWAtZUtg3I6g3e1J/GmvEHjkAc55TuxdmvQDTgvvl37tym0zcu KChkHh7Lv/48BSQQwNqxIMTYhCphmh6dA62v9REGM7D4zlZ54sgw4/IQTeI861c0Qgvj v7aJg4BsRnxuzB9rNe4g3kaSFvf+9juNPrNCzsW5zMWwx0gKpHDaoQ8c30JhAxsnUqVr OBLRjtL7cHvqXZdSpxcffxYfXf9OazDoVzP236q7EcI9vVik2MdoQaAiy+4aYfeNRQyX VTrw/dWW/2dNwdnYSi3quY4VY698EhLUOyX+gKNCTwOI2A8j1zZ3LIPJ7cPs4q5aApRE VDig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736520420; x=1737125220; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6dmBV/auP82f6hBm4EolXOpttlJRasyacpX+yDPVeCs=; b=f789I+WQwV3yA5qllJxwe3svMwQWi92E0ws6tI+L/aJfQn1R6veyp5H6OEST9cOhVc CqBRNJbih8F6Tck7iILdZHYXIlFczG1CCL5WYEoGCookYzDBIC3p+xOXgoLoluuNFtj0 iBRSD3/n3ymA5PvesgwnERlBTNQ9wAF9KyR2hNRe/J0F+HOxzwURko90lYzqKvKq3/ox DJLpCwnyr1V3Iijn7zWZOug9f1E6Y5ABVBFV+5MsayQ6QaBPB5VopLDk0m1z9XmGru3T wLU0Jaj5Lj+DdhTesMA4IlQ0murSHETVRbTMTnDi5PGAmD6MZrcGAOvV7nNwfFBKTJqg c/9Q== X-Forwarded-Encrypted: i=1; AJvYcCW7BCdERDAAC3R/SFoOEUPnzbQYSSQxSCd14nW5ITVBpEdz2Im5mLrk6lp0LMtfKe4+KuEjS745hTa3gkM=@vger.kernel.org X-Gm-Message-State: AOJu0YwbK4Wmw58xnxGbuGH+g5E/lv+o4T3pJK/DnLzuGrh0kAOyoCYE 80tS/3QxZZAwdGbDLFkI6JjWakeCeqiIKd+ah+jZ5UxUilFsbAmHZ4hGDcB4+lY= X-Gm-Gg: ASbGnctT87+K4kmJ6WNRIxwwUVvYtvIc71dv8T5LKJLjsQvh3qC+xCO9JN3fRf7ztZZ MOPAqfWdKu62wHO5ro7j9D6XNiH6fYvFUrHEc86lD2bCcC9Cb2Ito4DR3kywEcoFwmZNyAkL9FE qLGUKi4yiSpIXyheiU3af/wCVn815Qx+umoGPSutpcWNc/7b0QoVPhSy7jcHxbv+BoFG1bYdV37 zrgsKeePaHe/2v5BFFxPXOGwTA43H7hHrhVYuIL6obVoh3YYV4kRurnSt5XLkbf X-Google-Smtp-Source: AGHT+IFHnrXJIT7IS4Ktb5mBYFVRHfqLa1L7y0zmkt5BRYpWC1xjGiL0nrinnyIliAjJzK0UzsFGpw== X-Received: by 2002:a5d:47a6:0:b0:385:d7a7:ad60 with SMTP id ffacd0b85a97d-38a872f6a32mr9804715f8f.3.1736520418692; Fri, 10 Jan 2025 06:46:58 -0800 (PST) Received: from vingu-cube.. ([2a01:e0a:f:6020:cba5:ac16:21f:984f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c1dc6sm4734376f8f.96.2025.01.10.06.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 06:46:58 -0800 (PST) From: Vincent Guittot To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, linux-kernel@vger.kernel.org Cc: Vincent Guittot Subject: [PATCH] sched/fair: Encapsulate set custom slice in a __setparam_fair() function Date: Fri, 10 Jan 2025 15:46:56 +0100 Message-ID: <20250110144656.484601-1-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Phil Auld --- kernel/sched/fair.c | 23 +++++++++++++++++++++++ kernel/sched/sched.h | 2 ++ kernel/sched/syscalls.c | 16 +++------------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index b3418b5d484f..96c7ea6fb04a 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -37,6 +37,7 @@ #include #include #include +#include =20 #include #include @@ -51,6 +52,8 @@ =20 #include =20 +#include + #include "sched.h" #include "stats.h" #include "autogroup.h" @@ -5050,6 +5053,26 @@ static inline void util_est_update(struct cfs_rq *cf= s_rq, trace_sched_util_est_se_tp(&p->se); } =20 +void __setparam_fair(struct task_struct *p, const struct sched_attr *attr) +{ + struct sched_entity *se =3D &p->se; + unsigned int util_est; + + p->static_prio =3D NICE_TO_PRIO(attr->sched_nice); + if (attr->sched_runtime) { + se->custom_slice =3D 1; + se->slice =3D clamp_t(u64, attr->sched_runtime, + NSEC_PER_MSEC/10, /* HZ=3D1000 * 10 */ + NSEC_PER_MSEC*100); /* HZ=3D100 / 10 */ + } else { + se->custom_slice =3D 0; + se->slice =3D sysctl_sched_base_slice; + } + + +} + + static inline unsigned long get_actual_cpu_capacity(int cpu) { unsigned long capacity =3D arch_scale_cpu_capacity(cpu); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index aef716c41edb..300db6fe53eb 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3500,6 +3500,8 @@ unsigned long scale_irq_capacity(unsigned long util, = unsigned long irq, unsigned =20 #endif /* !CONFIG_HAVE_SCHED_AVG_IRQ */ =20 +extern void __setparam_fair(struct task_struct *p, const struct sched_attr= *attr); + #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) =20 #define perf_domain_span(pd) (to_cpumask(((pd)->em_pd->cpus))) diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c index ff0e5ab4e37c..286eb72f44ae 100644 --- a/kernel/sched/syscalls.c +++ b/kernel/sched/syscalls.c @@ -300,20 +300,10 @@ static void __setscheduler_params(struct task_struct = *p, =20 p->policy =3D policy; =20 - if (dl_policy(policy)) { + if (dl_policy(policy)) __setparam_dl(p, attr); - } else if (fair_policy(policy)) { - p->static_prio =3D NICE_TO_PRIO(attr->sched_nice); - if (attr->sched_runtime) { - p->se.custom_slice =3D 1; - p->se.slice =3D clamp_t(u64, attr->sched_runtime, - NSEC_PER_MSEC/10, /* HZ=3D1000 * 10 */ - NSEC_PER_MSEC*100); /* HZ=3D100 / 10 */ - } else { - p->se.custom_slice =3D 0; - p->se.slice =3D sysctl_sched_base_slice; - } - } + else if (fair_policy(policy)) + __setparam_fair(p, attr); =20 /* rt-policy tasks do not have a timerslack */ if (rt_or_dl_task_policy(p)) { --=20 2.43.0