Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3359102lqp; Tue, 26 Mar 2024 07:13:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWOh2a0ELLwDQm5d5vFH/h/hpTSsyTaE6xgyF3M1+dnI1JfJQnHdBtgJhpnoXu1Tj9TDDDim2yYcPLfi3jt+iombEnd7+ByQ2vqWnHr5A== X-Google-Smtp-Source: AGHT+IEMTlprTbwdzcBCmpjW2emzTMu/GxAD/3EqfsRat2RrHbOF/k0P9gsRujYRPsPWYcPdv5e4 X-Received: by 2002:a05:622a:1212:b0:431:4570:b2f3 with SMTP id y18-20020a05622a121200b004314570b2f3mr10634477qtx.42.1711462427299; Tue, 26 Mar 2024 07:13:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711462427; cv=pass; d=google.com; s=arc-20160816; b=WBNuKcK9JRUfHAGvjYMLzDvJVyKN9m8HxtqsYFnU8PzuqVH/nBGBgYiNPSxu+h9vQc OTAo478PgyUzisMyAvhvIxlouLxkciDahWtVzPALxS4vzUoYaOcFAPI6f8KtaM7RLKRQ 0jEV77aeu3MyYF2yNu6EhZXrpXFxjK/TQSoukA99NVUgnhWbQmYNhaxws6NuXqmWLBCa CgcMIADxbOMz30DZe2zCMrkeqEOKieR+90yzZq25iAH7TZWoouRpgj7JTMOmvtEf8aJD oNsi79i9GwirKQiDNvmAC4ZuZfYEqlRMrxK+xPgqzKzPJNztZbvHpVlC+74g0el4fZRH N2aQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=mSBOeRjNSlZVOdoSuzOxvESWRKYZQlmkHO76+F8yIFI=; fh=tAm2Hv3juOyGfZclaBdypoTNFGc1zppL4ArnhZqo7bE=; b=h71d54014GMlHfWuEy/Lz9Ek83WdTYnG8gVuq9WsAFBKhvd+VALmzkuqB3P6L/i4SS YLGTocPadYDIWQC0R+PlOHgtclGRxxCj8hr9cqbvM5vEjjcig7oXcdycxglyUr/gZT/h Ri1whI01zdETm3V+F+uwH+Gaa9KbQTc2gKxJkjoj3a/BpYfipYDolJKoBCrOhhtzH/zm hN9a9m/GUaQmxnpwhGv0ehsXOj6azFYFv6aD2KRKmDKI74om5+Xx0BGxQPqXIqfb3Czi AhM7fhVr//wKS3ghx6LVu4VaPC3H8C+c9F1Tp6oosr/OTm/YB9mehXbsia8W2WYFqF1g bLxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ngKfhZtd; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-119146-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119146-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r4-20020ac85c84000000b00430caff98e2si7503114qta.242.2024.03.26.07.13.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 07:13:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119146-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ngKfhZtd; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-119146-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119146-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D5A1B1C618C3 for ; Tue, 26 Mar 2024 14:13:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2FE0B12AACF; Tue, 26 Mar 2024 14:12:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ngKfhZtd" Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (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 798B4129E6C for ; Tue, 26 Mar 2024 14:12:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711462351; cv=none; b=TxnEuGfFQGTV7t4L0f32yV5gO8uHYjZF3Lb50k3Ha+h5JjwldrFHcMqF+pzL4KyTdJemZXLSz9/vqVxcp20SfQblhiSrN9c2BRqUTu7jl6NyWXVU4Inx/phGbzLV+i7HntiSwJd6RfglPQG09jUgmD5FanPemTNC8giq0xOANDs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711462351; c=relaxed/simple; bh=rqD+9oinJK3/MbfIo9oYM9IoKJ5n0iVPVmUSbQUjcPQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=hU5ObRtuFucuGPRfVRxNdI1A3GwCuWqTjsiFUcTAvUrFeFRpl1Kcb8U3LZrBGnP1KE62SxhJ8Y+IuUe4TQaTCtf8DoPG+TIOjMkAemYM7q4xOdfcSvhqzNlcZ07m+pKvCnCTdF3aRCLhSV33SB0qRW44XO1QpdbUOCYIZlf4jiQ= 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=ngKfhZtd; arc=none smtp.client-ip=209.85.215.172 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 Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so3983112a12.1 for ; Tue, 26 Mar 2024 07:12:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711462349; x=1712067149; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=mSBOeRjNSlZVOdoSuzOxvESWRKYZQlmkHO76+F8yIFI=; b=ngKfhZtdNx+tzUhzGz3XOmKc3Tb7EPQbPNzLyBISEGtbW2yr8RXzytfkyA3kIkr7Lo WfQwAHW9g+TuTWxOYZkzUNBvrHiUjufimgX00x1O4Se7BjS3w6oeKHSktzHrld5YPDEV Hn7jIeRW2geH18yZ+wG6jYViJ8VN4QkToxUYimdIOGsRy0/dnpoR/gmsfm+CtWRFLOJI fUM9Y6U/IPuj4YVTYh14L0PhfwBMLLuEhPOEFHAPg7OF9VEwCEbVOSz0h/YLeFne6RYq IZImvBW5ovGw1rsG0SZdysuzetaG22FU7yV8yWGwi7uSkouvPNhzncnc0XyAvbKdTkM+ rejA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711462349; x=1712067149; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mSBOeRjNSlZVOdoSuzOxvESWRKYZQlmkHO76+F8yIFI=; b=PmwIjdHq4bsTLk/ygNi1or/5EzVOMAiG92lIpiGGZYVgRkGWAIiFC+WtHPOt0QmVVW C02rcdRvhMioPMGA3AspdbHUM764SLBQOq/oxmVRUEq4DfS+CLXIVZjb+rHduLzzTdLY WBCjIq3vwO1opiB2smlXcAFR97m5ITo66HqP3kzT/9Fsxo00w9/E0W6fYZQJc/wC+s/d KpX1rnhA8p+XngCqyJYrrUHINkL56ehVc0xQ/+46T1WYgQrKikSLdEjhUQDx7MIP3JH/ x3GyVEuYnTMh4Ik32FgOGTxlVBhCuwSk1KYX2RzPsQqhd3dkal8KxNSgqZamn7Gwt/j7 rBPQ== X-Forwarded-Encrypted: i=1; AJvYcCVhNmAQEYoHjrmE34Xk3CZ50x88Xigv73+d1VuggrwSjHS6jB2LIM0AZwTIKj2DxJNw29xWk0pbiqKrWmQr/DqngO26MpJ7IGIq/8/f X-Gm-Message-State: AOJu0Yz7mH9AF4ekjp+JVACvUiCwhrb8Xb+LBdawJ9aOjTPElnFCTwaI 4I16zr0CbjtxG5Nl/pjwCytyCdrhxlM6OmPvFN28GAabcyCUn25Cox0Fs7il94rPv3saqvnEVjY oo0nzZWXuaO+SXAaAcBA7BnVKWdEqo0dqDKoFnA== X-Received: by 2002:a17:90b:109:b0:29c:5ba6:c518 with SMTP id p9-20020a17090b010900b0029c5ba6c518mr8867359pjz.6.1711462348807; Tue, 26 Mar 2024 07:12:28 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240307085725.444486-1-sshegde@linux.ibm.com> <20240307085725.444486-4-sshegde@linux.ibm.com> <3495922c-91cd-448f-8831-5ce8bab0eda4@linux.ibm.com> In-Reply-To: <3495922c-91cd-448f-8831-5ce8bab0eda4@linux.ibm.com> From: Vincent Guittot Date: Tue, 26 Mar 2024 15:12:17 +0100 Message-ID: Subject: Re: [PATCH v6 3/3] sched/fair: Combine EAS check with overutilized access To: Shrikanth Hegde Cc: Ingo Molnar , peterz@infradead.org, yu.c.chen@intel.com, dietmar.eggemann@arm.com, linux-kernel@vger.kernel.org, nysal@linux.ibm.com, aboorvad@linux.ibm.com, srikar@linux.ibm.com, vschneid@redhat.com, pierre.gondois@arm.com, qyousef@layalina.io Content-Type: text/plain; charset="UTF-8" On Tue, 26 Mar 2024 at 13:26, Shrikanth Hegde wrote: > > > > On 3/26/24 1:56 PM, Vincent Guittot wrote: > > On Tue, 26 Mar 2024 at 08:58, Ingo Molnar wrote: > >> > >> > >> * Shrikanth Hegde wrote: > >> > >>> /* > >>> - * Ensure that caller can do EAS. overutilized value > >>> - * make sense only if EAS is enabled > >>> + * overutilized value make sense only if EAS is enabled > >>> */ > >>> -static inline int is_rd_overutilized(struct root_domain *rd) > >>> +static inline int is_rd_not_overutilized(struct root_domain *rd) > >>> { > >>> - return READ_ONCE(rd->overutilized); > >>> + return sched_energy_enabled() && !READ_ONCE(rd->overutilized); > >>> } > >> > >> While adding the sched_energy_enabled() condition looks OK, the _not prefix > >> This is silly: putting logical operators into functions names is far less > >> readable than a !fn()... > >> > >>> - if (!is_rd_overutilized(rq->rd) && cpu_overutilized(rq->cpu)) > >>> + if (is_rd_not_overutilized(rq->rd) && cpu_overutilized(rq->cpu)) > >> > >> Especially since we already have cpu_overutilized(). It's far more coherent > >> to have the same basic attribute functions and put any negation into > >> *actual* logical operators. > > > > I was concerned by the || in this case that could defeat the purpose > > of sched_energy_enabled() but it will return early anyway > > > > > return !sched_energy_enabled() || READ_ONCE(rd->overutilized); > > I think this would work. > > > > >> > >> Thanks, > >> > >> Ingo > > > If EAS - false, then is_rd_overutilized -> would be true always and all users of it do !is_rd_overutilized(). so No operation. > If EAS - true, it reads rd->overutilized value. > > Does this look correct? yes looks good to me > ------------------------------------------------------------------------------------- > From 3adc0d58f87d8a2e96196a0f47bcd0d2afd057ae Mon Sep 17 00:00:00 2001 > From: Shrikanth Hegde > Date: Wed, 6 Mar 2024 03:58:58 -0500 > Subject: [PATCH v7 3/3] sched/fair: Combine EAS check with overutilized access > > Access to overutilized is always used with sched_energy_enabled in > the pattern: > > if (sched_energy_enabled && !overutilized) > do something > > So modify the helper function to return this pattern. This is more > readable code as it would say, do something when root domain is not > overutilized. This function always return true when EAS is disabled. > > No change in functionality intended. > > Suggested-by: Vincent Guittot > Signed-off-by: Shrikanth Hegde > --- > kernel/sched/fair.c | 20 +++++++------------- > 1 file changed, 7 insertions(+), 13 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 24a7530a7d3f..e222e3ad4cfe 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -6686,12 +6686,11 @@ static inline bool cpu_overutilized(int cpu) > } > > /* > - * Ensure that caller can do EAS. overutilized value > - * make sense only if EAS is enabled > + * overutilized value make sense only if EAS is enabled > */ > static inline int is_rd_overutilized(struct root_domain *rd) > { > - return READ_ONCE(rd->overutilized); > + return !sched_energy_enabled() || READ_ONCE(rd->overutilized); > } > > static inline void set_rd_overutilized_status(struct root_domain *rd, > @@ -6710,8 +6709,6 @@ static inline void check_update_overutilized_status(struct rq *rq) > * overutilized field is used for load balancing decisions only > * if energy aware scheduler is being used > */ > - if (!sched_energy_enabled()) > - return; > > if (!is_rd_overutilized(rq->rd) && cpu_overutilized(rq->cpu)) > set_rd_overutilized_status(rq->rd, SG_OVERUTILIZED); > @@ -7999,7 +7996,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) > > rcu_read_lock(); > pd = rcu_dereference(rd->pd); > - if (!pd || is_rd_overutilized(rd)) > + if (!pd) > goto unlock; > > /* > @@ -8202,7 +8199,7 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags) > cpumask_test_cpu(cpu, p->cpus_ptr)) > return cpu; > > - if (sched_energy_enabled()) { > + if (!is_rd_overutilized(this_rq()->rd)) { > new_cpu = find_energy_efficient_cpu(p, prev_cpu); > if (new_cpu >= 0) > return new_cpu; > @@ -10903,12 +10900,9 @@ static struct sched_group *sched_balance_find_src_group(struct lb_env *env) > if (busiest->group_type == group_misfit_task) > goto force_balance; > > - if (sched_energy_enabled()) { > - struct root_domain *rd = env->dst_rq->rd; > - > - if (rcu_dereference(rd->pd) && !is_rd_overutilized(rd)) > - goto out_balanced; > - } > + if (!is_rd_overutilized(env->dst_rq->rd) && > + rcu_dereference(env->dst_rq->rd->pd)) > + goto out_balanced; > > /* ASYM feature bypasses nice load balance check */ > if (busiest->group_type == group_asym_packing) > -- > 2.39.3