Received: by 2002:ab2:2997:0:b0:1ec:cbc4:63fb with SMTP id n23csp343677lqb; Thu, 29 Feb 2024 02:40:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVn+yVmTZ965DuPoU4lq/k2IaeXMvbuwKlylh29PIxaq1eIagf96+z2gVrhRuQpHNJGSjnuz7Az68em6xH7N8w9u28ojwMmKjxYn4o5KQ== X-Google-Smtp-Source: AGHT+IHh6mzTN3+mKPW72NOkJcqCNM2V7lEhWKKvYkmDgkXYsAdls6SldP5opmN/RTzZPpgSwDp4 X-Received: by 2002:a17:906:5952:b0:a44:1b9e:b977 with SMTP id g18-20020a170906595200b00a441b9eb977mr1225324ejr.19.1709203256516; Thu, 29 Feb 2024 02:40:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709203256; cv=pass; d=google.com; s=arc-20160816; b=PO4g6roli06HzNw17G80vhjzTbs0gMr89v5ub7nXzYmYk1NiwFDJWTvlixNzxWuMGT UgZMGEaDIfASVhOwnTi+Op/oP2Z+XV+/HNglqsP68V/SWPseWLL04HKr2ZyLxkhhRimT EBxvaI2vDhmx3/aYn7F3wYVXEG7GRr3T6fQW+uYigk4ddSfFG4GEpbtWeL72dM29yyEn wltt4XmSNW/CSO/St5bs0YTAeyiN7TYBwjbmVxOu3+n2AmcUjNMJLMoKD5a6RCT+rFSJ eA8UJfdhraowKwOz8YCT5jp9dzcLYEUc/4m9gw+gwERCfwEgosTFbC56fBQgdO/8JfvC 1oLg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=zV+9vBH6vsCvSgYAj6XucswUu11VRXhZKLGiY+vYcyQ=; fh=7NjeZ8ZmsvURI3QuLAnfz40XZBWrCCclaNdn06VPdo8=; b=RPIRzw/lsexyawSogXQgpbCVdhJL/iTb/AglgsN7CQHlCHdM7/MoO+dNHBG9YEM6jH mzrlczAhIiy+8QiTKmPimZq9cESkrY6X2JQ1MhG6X3/ABrGaMlpk1QY8HRkAEL8yzu5T F5jE2vsAWCT0dpog/oF6BbIAC98LuRpcKXrKdbU7qppTYvSHlz5TXf1Qy8XEJVaT7YeT QryBa5V7UEM+qoMt9fsuyeeoKnHk4jt9gd5bFxixH7yQbaD9WUTShEuwrNsJf48ZAqVG j5fsfOJrNQAuNstelLV3rGQyFC+qL2yZpqO1DhrCQHU7NA54P8zGe08qTFo/RK+slqTE 3XcQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=PefuQPm3; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-86565-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86565-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id rh2-20020a17090720e200b00a3f5cf0f179si454955ejb.169.2024.02.29.02.40.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 02:40:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86565-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=PefuQPm3; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-86565-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86565-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 13FCE1F28657 for ; Thu, 29 Feb 2024 10:40:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F22E17A704; Thu, 29 Feb 2024 10:40:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="PefuQPm3" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 3DCF47995E for ; Thu, 29 Feb 2024 10:40:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709203243; cv=none; b=gEfeA/fjaAz7Qg/aP8z8hkNa4jdKBk9NjqmvSDiwfW/W0udcPOpFbo3X7B4TTpQiCbKB4EsErBejUKmFIabpA/vTam8Hw8wWf2ZYF2PWXuIjWIsm8CH7Fxw61fA7ysFSVOd+lQizoGHGYTuGaIZpTRvfts0/nENnPLVpM9Y0P+4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709203243; c=relaxed/simple; bh=cjeOA8/3MZ9GSaia0NoWb8OwwjgJ0UgwMjyjw8jt2E4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rdjqG23j7udYrQM8gMmNTuMzTAXskOwqUtGY4SKaUOpbkQFMyQqOoxnAUljp8Fd5qzsjwoYHGWeeherB/mboEYUdLuz6Cg5NuR3sgumdgttV17vQ1aZrTcE/+UYEfFDCkkZJ9uIrm9cfaLQyJVPwetUholJDpj+MEy2mlvFDLIE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=PefuQPm3; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41TAQVbU006088; Thu, 29 Feb 2024 10:40:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=zV+9vBH6vsCvSgYAj6XucswUu11VRXhZKLGiY+vYcyQ=; b=PefuQPm3rPWq3V7iwUQUjef2QIZViwh40z/QMILGfw3dau21bLDsAQHUyZ4BTRESqakF dWSdsFva8sw/89JhRXN/p/mo04sZb97HYOmXOgerp+KbnjyDWLSIejWgtplK/w7fp7pW w3RLB4UDV7Srtv5Tlk02UtbK40p9s3nfmxP+TYbuTXg3bZMOjVI9su++4UsJTGqhr3fp hghg2VaQynYnZdS/eD/93O9OaJfEQN/gO1GCEuxr6VXoeTQKF5qLlCbPrgzp7YBioN6T dAWAOhVEfHlYym7OXY0l+Kkla17rX8+7ZaVRGcCxNbTaEWaZDxSYWJN9haRIvL+///pc sg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wjqp29kdt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Feb 2024 10:40:32 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 41TAQwCd009065; Thu, 29 Feb 2024 10:40:31 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wjqp29kda-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Feb 2024 10:40:31 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 41T8d4jj008189; Thu, 29 Feb 2024 10:40:30 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wfv9mmhhh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Feb 2024 10:40:30 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41TAePlW38142414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Feb 2024 10:40:27 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1DED720043; Thu, 29 Feb 2024 10:40:25 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8459D2004D; Thu, 29 Feb 2024 10:40:22 +0000 (GMT) Received: from li-c1fdab4c-355a-11b2-a85c-ef242fe9efb4.in.ibm.com (unknown [9.109.201.126]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 29 Feb 2024 10:40:22 +0000 (GMT) From: Shrikanth Hegde To: mingo@kernel.org, peterz@infradead.org, vincent.guittot@linaro.org Cc: sshegde@linux.ibm.com, yu.c.chen@intel.com, dietmar.eggemann@arm.com, linux-kernel@vger.kernel.org, nysal@linux.ibm.com, aboorvad@linux.ibm.com, srikar@linux.vnet.ibm.com, vschneid@redhat.com, pierre.gondois@arm.com, morten.rasmussen@arm.com, qyousef@layalina.io Subject: [PATCH v3 2/2] sched/fair: Use helper function to access rd->overutilized Date: Thu, 29 Feb 2024 16:10:10 +0530 Message-Id: <20240229104010.747411-3-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240229104010.747411-1-sshegde@linux.ibm.com> References: <20240229104010.747411-1-sshegde@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: C932j5r432NVo8UmXx04ltx1gLOY9XGw X-Proofpoint-ORIG-GUID: 2gRTWakppOBr9JJKC4aTAPAQwLes2hD1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-29_02,2024-02-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=805 phishscore=0 priorityscore=1501 suspectscore=0 mlxscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402290081 Overutilized field is accessed directly in multiple places. So it could use a helper function. That way one might be more informed that it needs to be used only in case of EAS. No change in functionality intended. Signed-off-by: Shrikanth Hegde --- kernel/sched/fair.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 1f7d62b7c26f..99b5ddf92924 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6670,6 +6670,15 @@ static inline bool cpu_overutilized(int cpu) return !util_fits_cpu(cpu_util_cfs(cpu), rq_util_min, rq_util_max, cpu); } +/* + * Ensure that caller can do EAS. overutilized value + * make sense only if EAS is enabled + */ +static inline int is_rd_overutilized(struct root_domain *rd) +{ + return READ_ONCE(rd->overutilized); +} + static inline void set_rd_overutilized_status(struct root_domain *rd, unsigned int status) { @@ -6686,13 +6695,14 @@ static inline void check_update_overutilized_status(struct rq *rq) if (!sched_energy_enabled()) return; - if (!READ_ONCE(rq->rd->overutilized) && cpu_overutilized(rq->cpu)) + if (!is_rd_overutilized(rq->rd) && cpu_overutilized(rq->cpu)) set_rd_overutilized_status(rq->rd, SG_OVERUTILIZED); } #else static inline void check_update_overutilized_status(struct rq *rq) { } static inline void set_rd_overutilized_status(struct root_domain *rd, unsigned int status) { } +static inline int is_rd_overutilized(struct root_domain *rd) { } #endif /* Runqueue only has SCHED_IDLE tasks enqueued */ @@ -7974,7 +7984,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) rcu_read_lock(); pd = rcu_dereference(rd->pd); - if (!pd || READ_ONCE(rd->overutilized)) + if (!pd || is_rd_overutilized(rd)) goto unlock; /* @@ -10859,7 +10869,7 @@ static struct sched_group *find_busiest_group(struct lb_env *env) if (sched_energy_enabled()) { struct root_domain *rd = env->dst_rq->rd; - if (rcu_dereference(rd->pd) && !READ_ONCE(rd->overutilized)) + if (rcu_dereference(rd->pd) && !is_rd_overutilized(rd)) goto out_balanced; } -- 2.39.3