Message ID | 20240301151725.874604-3-sshegde@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-88613-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp1149238dyb; Fri, 1 Mar 2024 07:19:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCViG1TqBrMdFp/hvojK4v/MUAvkzw7VzJV2NHR87c+P2VUGNyjDBXXmBS7yZWzntBt4B0g8AU4oHLwV09/5EZfDim2Hzg== X-Google-Smtp-Source: AGHT+IE4R5NBC2TY3ZI/X3OQe48vY1GTmJrIAPWqZ0PszeVRSxKC8JWk5FqpPi2WWPQ/EXfWtMxN X-Received: by 2002:aa7:d9d2:0:b0:566:cde6:3ee4 with SMTP id v18-20020aa7d9d2000000b00566cde63ee4mr1422541eds.24.1709306342923; Fri, 01 Mar 2024 07:19:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709306342; cv=pass; d=google.com; s=arc-20160816; b=b7LdHwDHlJ9xFqC2aTxhO9KvgkpaEbxWklAQpp63q9g1LKiMIvyGAmc7xlv727qGIU mkfIkGu1MZNDUPeOe6A2dVFhD1U2bugaAO9hnYZFAYJzucOB9VQq4Ah6betO+7wNJDeA ybsvMtpJqy05xLy2vOtokH/M07/JhW90YT1khPwFBJBkTcXlJYQZYIFPEev3v3ZKjlV/ xSJMUUgo4ro+pVgacBUuWyDJ03A9y8L97x7yonyngwTWnKMn9ulzjIoqwNVYnnHtVQKh vU8Lr47ZsONmyFqSYpAPJrYk5C4r7Duf6mgbIAh9yYaoAUqnzzCo02yj9pcYLw42QRvu mHJg== 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=ZKvArzhNe7ZFn1OPm5+2YBGXQFLX2h9iVzOhDC9zsG0=; fh=vjnxu6btb5gYs4jFOPDgeX45Pt0noh9LgKUgmif34F8=; b=YOuoBptUKMdPufqI2xkNpO9xTFJopLV0j3AcVNzeb6DYb85tAuARTW+U3ZenpHwg1V vMsySi+03MFoa8LMoviaACIRBDyw0bVnxwqfWSUwD95j7OEPxHSrUNG45mXKnLnUwIJP 7ZFmfysrigCQWXHK/WXk+o20ICqkxKE0en6KTmdaOKI77kvKnh/0YVaqL6z1bgEL6Hhr J0wVVpQFNLo4MtjOh1DMLt6hGEj5Fgj0OBIKnuPFivZedrxo8o0prQlrlilMjI0KgXfL mISa57otVAzRhEokG691JDyieutnjQxxzQWbQ95ErKb/j4oBIDhXz7/q62YcTbKKC+Q6 1ywQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="dN3f/U8v"; 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-88613-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88613-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y10-20020a056402440a00b005664cbe04d4si1530816eda.309.2024.03.01.07.19.02 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 07:19:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88613-ouuuleilei=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="dN3f/U8v"; 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-88613-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88613-ouuuleilei=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 5FD8A1F271F4 for <ouuuleilei@gmail.com>; Fri, 1 Mar 2024 15:19:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74A7570ADB; Fri, 1 Mar 2024 15:18:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="dN3f/U8v" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 16C6D67E8E for <linux-kernel@vger.kernel.org>; Fri, 1 Mar 2024 15:18:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709306306; cv=none; b=a/RTxbC3yVFIWydBZ5djodM1L42ERahGDUTm7Jai1MZbE7NURd0QExhKQT2n2pzd/Dcv8bP1NiTVBbVbUb6GrvnhsQ/Llh1wCK/4Qg93cJfxtZDSVFK4+BT3VIgGjarJbOiMI7/fdOLMdGMJWMSA7ly6237yRTbaGXzmg6ugxyU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709306306; c=relaxed/simple; bh=jt+JFfSHfHUQOM9ggg4OpOmchKW/BPOrXWMwdjqv1To=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TvwcNRZLO2g4VOD/o6DKNDfTT1zAsrgEZxyOCTFp37tu0GOoaGMP3hf3xCbZ6nhSEhYiN/alhSDUt7a9eu7qcTHrP4dx7wxtORf4fM0xT0oPByGpZTFaOU45o7Y0PnVADf6b4gvkyKWLyVRD2nn+Fgh0UU3HdOQOOhk3rMtKRAg= 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=dN3f/U8v; arc=none smtp.client-ip=148.163.156.1 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 (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 421F2ich009667; Fri, 1 Mar 2024 15:18:09 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=ZKvArzhNe7ZFn1OPm5+2YBGXQFLX2h9iVzOhDC9zsG0=; b=dN3f/U8v0R+CKLTf6MoxM6LHi3q9ugmwWs/MbFryYhPiUimSkUxVjfxHl0ID54B9lKHr sCn5H+oee8zD4DT228lmiOEk8vxcbwtVktNiJQIBQSi0EamaWkAt8sehLacQFEuHWJlr FqVJyHqb3udVYr/QCdJAzhJP4VM/SeGAmnqSLKFjS5/olYYsUQ9twZJ5pRUIgvdl6xIC LhDxDlZB/0xa2hpd/uvdLT24F132US9Uwc7t9KmtBEhC29aVfcXMBLooqTsM4ma8xfmB PRMDY4ggoWO+B348OsODDQ7Wg+cZcc2VUr7mKd/kQli4YjSXxC/SnJZqmOvnbkB7Zqgp rw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wkhaf8d63-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Mar 2024 15:18:08 +0000 Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 421F4QtJ016839; Fri, 1 Mar 2024 15:18:07 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wkhaf8d5g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Mar 2024 15:18:07 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 421E2T6k012348; Fri, 1 Mar 2024 15:18:06 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wfwg2vpw7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Mar 2024 15:18:06 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 421FI0Yt63832476 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Mar 2024 15:18:02 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BBEB720043; Fri, 1 Mar 2024 15:18:00 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C9EDE20040; Fri, 1 Mar 2024 15:17:56 +0000 (GMT) Received: from li-c1fdab4c-355a-11b2-a85c-ef242fe9efb4.ibm.com.com (unknown [9.43.108.184]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 1 Mar 2024 15:17:56 +0000 (GMT) From: Shrikanth Hegde <sshegde@linux.ibm.com> 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.ibm.com, vschneid@redhat.com, pierre.gondois@arm.com, morten.rasmussen@arm.com, qyousef@layalina.io Subject: [PATCH v4 2/2] sched/fair: Use helper function to access rd->overutilized Date: Fri, 1 Mar 2024 20:47:25 +0530 Message-Id: <20240301151725.874604-3-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240301151725.874604-1-sshegde@linux.ibm.com> References: <20240301151725.874604-1-sshegde@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: mFto1n2-DVLWy95vQsBBr-WooEgaK65G X-Proofpoint-GUID: nlWlmMTpAo4Wwm-XrCQnolwgm3u9XPgJ 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-03-01_14,2024-03-01_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 adultscore=0 mlxlogscore=826 lowpriorityscore=0 impostorscore=0 clxscore=1015 suspectscore=0 mlxscore=0 priorityscore=1501 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403010127 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792337607357509582 X-GMAIL-MSGID: 1792337607357509582 |
Series |
sched/fair: Limit access to overutilized
|
|
Commit Message
Shrikanth Hegde
March 1, 2024, 3:17 p.m. UTC
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 <sshegde@linux.ibm.com>
---
kernel/sched/fair.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
--
2.39.3
Comments
On 03/01/24 20:47, Shrikanth Hegde wrote: > 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 <sshegde@linux.ibm.com> Can we do the same for rd->overload too? A set_rd_overload_status() would be a nice addition too. Anyway. Reviewed-by: Qais Yousef <qyousef@layalina.io> Thanks! -- Qais Yousef > --- > 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 a71f8a1506e4..650909a648d0 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 >
On 3/4/24 12:24 AM, Qais Yousef wrote: > On 03/01/24 20:47, Shrikanth Hegde wrote: >> 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 <sshegde@linux.ibm.com> > > Can we do the same for rd->overload too? A set_rd_overload_status() would be > a nice addition too. Anyway. We have some more experiments going around overload. For example, currently it is writing sg_status & SG_OVERLOAD without checking if it has changed first. On large systems that are not overloaded, that may help by reducing the bus traffic. I will pick up this after we have some more data on the above. > > Reviewed-by: Qais Yousef <qyousef@layalina.io> > Thank you. > > Thanks!
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index a71f8a1506e4..650909a648d0 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; }