Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp1207514rbe; Fri, 1 Mar 2024 07:18:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVEHoP9iyGjSmgRUFCDEgNlHtBfSC2U4rV/aDcidUAKCFpwhKpEAfwHTgoliWLh2TBe9KCAO354oVqu57AumcW9s4DF69+YoekBOn6bAA== X-Google-Smtp-Source: AGHT+IEs+LK1K/r2wSZgfdTzw8La7s/HrykDLKs24D2nKxeLS/CnbwIOcey7o+IoC512PgfypN5s X-Received: by 2002:a05:620a:575a:b0:787:ff02:1056 with SMTP id wj26-20020a05620a575a00b00787ff021056mr1872590qkn.2.1709306330546; Fri, 01 Mar 2024 07:18:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709306330; cv=pass; d=google.com; s=arc-20160816; b=jm9RXAQypoJYuhFX9dUx+926RdCj2A7cTVzySDObP+QrZ6gbNA1SV8om9cn846b/ft E78QMI2tnd1V7vd1BrEfKY4LLpYnmnze98FoYhsXljUtMzbVH7hWdWq9G3B4dsqt5qCT mQXs1PI+be0AptW/UMA/dbqmca2jSi7h019uYpDB0RiedOxs0Zkgw7ixdZiW0DyW1Yrs IKCIrge21nbATTu+k1/v1FDO9S7xbxLSLRVuzEI7Y5l/U8Dybg2w+1tGIBbD9zBtNs2s K+NmGM1TyYS3kc1T8osULoZLNRvVF7FSok2D86b/PLiH95b+/3P8tniJfn66sSodvLGO 9dNQ== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88613-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id p9-20020a05620a056900b00787ebcfdf71si3713827qkp.1.2024.03.01.07.18.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 07:18:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88613-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=@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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88613-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3FED21C22CC0 for ; Fri, 1 Mar 2024 15:18:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7184F6E607; Fri, 1 Mar 2024 15:18:27 +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 ; 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 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: List-Subscribe: List-Unsubscribe: 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 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 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