From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FCBB210F5D for ; Fri, 10 Jan 2025 15:14:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736522071; cv=none; b=r+CZDKKcPf4tCF/wjjcEqKQz7g/dpJPISxKoY/iUSGgHyKDZSNnLNFx89mtEVMAIZ8QN6UgbyGZO33ExqIG3Qmc6wwHwre3stlOCXphvLqJKX2BjyfFc6kkwdbxoNct7+i4Ec83Qgpv80jbvMTv915riVZRruol81INL0RObNew= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736522071; c=relaxed/simple; bh=M8nk+witn/Lc+ul62t0kJEA8Woa/8JUTcQlNiJZivbw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BSpzYhrCzgMm9QSFlzEZ/TNwHPadl0ZR1KIW8FyA2EX9LgSiFudIX0DOaeoQGqbFLo129ti07P8XG9pgxp7wquVjFXe9KYI+n8Q0PZOTvrE7CKFjl/+D/B+g3dVVYYdCqoQ6b9LEoF0zcU9M8Qs9oELYGy9eUrBvOlk/gzpozOw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=alzazELk; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="alzazELk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736522068; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LByXTykX4/v9kQLf8BKDCYvVK66TMfe/K4HBuLuARXg=; b=alzazELkoYoVrC4O1rV/l3cYgCAFLr9MpGTF7eeynpyJ6hXasiHviGvZeA8lQiekxWGEDO YAUgEMwr43ip2/N/hN+ZLYOe8VMce3wsbH8x1QrjxJ2WkFmShQl+Q2DiQgYzkPkpkdyEBp TH9khJHF3TBiVER8ZcRGayoNT/eM/JA= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-245-LhPidexTO0OSo4kvVklM_g-1; Fri, 10 Jan 2025 10:14:24 -0500 X-MC-Unique: LhPidexTO0OSo4kvVklM_g-1 X-Mimecast-MFC-AGG-ID: LhPidexTO0OSo4kvVklM_g Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 492411955DD4; Fri, 10 Jan 2025 15:14:23 +0000 (UTC) Received: from pauld.westford.csb (unknown [10.22.65.153]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 50EF719560AD; Fri, 10 Jan 2025 15:14:20 +0000 (UTC) Date: Fri, 10 Jan 2025 10:14:17 -0500 From: Phil Auld To: Vincent Guittot Cc: 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 Subject: Re: [PATCH] sched/fair: Encapsulate set custom slice in a __setparam_fair() function Message-ID: <20250110151417.GA6399@pauld.westford.csb> References: <20250110144656.484601-1-vincent.guittot@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250110144656.484601-1-vincent.guittot@linaro.org> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 On Fri, Jan 10, 2025 at 03:46:56PM +0100 Vincent Guittot wrote: > 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 LGTM. Reviewed-by: Phil Auld Cheers, Phil > --- > 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 > > #include > #include > @@ -51,6 +52,8 @@ > > #include > > +#include > + > #include "sched.h" > #include "stats.h" > #include "autogroup.h" > @@ -5050,6 +5053,26 @@ static inline void util_est_update(struct cfs_rq *cfs_rq, > trace_sched_util_est_se_tp(&p->se); > } > > +void __setparam_fair(struct task_struct *p, const struct sched_attr *attr) > +{ > + struct sched_entity *se = &p->se; > + unsigned int util_est; > + > + 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 inline unsigned long get_actual_cpu_capacity(int cpu) > { > unsigned long capacity = 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 > > #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))) > 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, > > 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)) { > -- > 2.43.0 > > --