Received: by 2002:a05:7208:3188:b0:7e:5202:c8b4 with SMTP id r8csp904906rbd; Fri, 23 Feb 2024 07:10:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUPl7xZPM6oRbX0BYXrCioHFzTVw74wwNzyINXvoei5WIpUVXlaRN0D1kjFUlzldFm7MSSYYWB3fhmVi2zBQ0QA759RmNSvB9nV46MsmA== X-Google-Smtp-Source: AGHT+IFgV3ToNRggvwjTDwrJQ1VGHiOJCEfXi1ktgCR+QxE2T4mkvyiORZOBdz0a+lDtP0ctKxm7 X-Received: by 2002:a17:902:fc4d:b0:1dc:69ab:7d68 with SMTP id me13-20020a170902fc4d00b001dc69ab7d68mr142916plb.1.1708701059206; Fri, 23 Feb 2024 07:10:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708701059; cv=pass; d=google.com; s=arc-20160816; b=n9jmC9URMcCbPNJvN/LBAUhFplvZDGfGj+9RjHiToCxjwZG+GKojEtC4J6CvGlUsxb R79e97GR02H5ISxL01z1PwArkYs0JwYCIsay255fwU11+UA4RPVAqosh7IlQcIC/Wdfe buVolyj1rokrkzl1gV11wpdP16NYCcbyf8sRt+JlPry3lR+4q2Qp92Jx3kQ8s4NczFN7 c2EGL7sNdmUgNPrXv9HA0tcwbbAE8iMN+nIKTHOc5cPivIAQN7Tkfab62WF3hRPEdDol c1OG5QQuyhPio/3aahD808y033PayaE/7kNJ6yBrvmhDSiz986WxKoiou9YTedOuxafb TCcg== 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=d58RgvIKA7XgjpVurnVrNffyQNbJgN7Zr1ki8kjLqmw=; fh=zQwkmEr4k4gfxfJxm2TKw1Yg6aZZbX5YCn4imrpFWMQ=; b=HW6Hk/WtkqAH7lhCn8SpQmTWZC66QawPoV1Btaeanp64Z+6gUU1gsqKPtijUpvI/bG +WHmZra4p0QuL/8BMzz11R9ZOq1U9kyJIe+YlBydKnIDX4ShudPSHFS1x/T2DBEfII33 58/XAMUxetr5Po152vBGXrh+AQ0nfB5eKfGbtmKWGqcw5Soq9M8KuXdgpub/Da8ezDjQ QGHcfqlp7VTiPJV8qEzU3mdNxpuHawR6M5vQaawWxssSH1aaHQX54iWTwz2+1OvReFJn h/X0uirCoYGvppBdecl9ECL874oYwxjVZ3w4lGBdaKiX0LJu8SOLKRLKQKGbCjW6SZ+L 3fJw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=BkyRro5G; 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-78575-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78575-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u8-20020a170902b28800b001db969c0f4asi9259902plr.533.2024.02.23.07.10.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 07:10:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78575-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=BkyRro5G; 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-78575-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78575-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id EAAC2B247D5 for ; Fri, 23 Feb 2024 15:08:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2CBB81ACC; Fri, 23 Feb 2024 15:08:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="BkyRro5G" 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 161D85FEE5 for ; Fri, 23 Feb 2024 15:08:26 +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=1708700908; cv=none; b=iIpP+7fBhy3bv7sGmweyEGWDheZHydTVtL94ksP2sML+RqFfGPm4aaK0zlkHYseIzYPOaxt1kU6Y56BR3wAcvCmMPPJnX0oN854VwfyNynKbMYMqup1xHGOs+z+cXgkxrFbWgcjh5GBwo3PpEmVs+PplZQpVM7PMF8oukKDRgbk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708700908; c=relaxed/simple; bh=Qh9iMx88MnURYVFfeyq46dQMYFOJYb0EQPZ+OBw+WzE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q15kt27mTcZH7sDx5Ub2MbVGrCIofrBUPZudQ3Bo446kwnv9FzOXMMcdpWihterojf56qsolQhetEHaaqQ9xNw9WxG0vNjG/MVNz1fUfEq7VVI0LQlWhhohzMpypW4Loo3P3gr+s0knEy6PHPeVtSbXlx+87/m0StLvUGX50jXA= 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=BkyRro5G; 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 41NF1J3w016142; Fri, 23 Feb 2024 15:07:49 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=d58RgvIKA7XgjpVurnVrNffyQNbJgN7Zr1ki8kjLqmw=; b=BkyRro5G2aV0Sq/xgbOOZVE5RjDtD0KUIS5V06mtSo63IB5yXTvvLJVAeC+5K1/GXZuB TI7sseXDGhsetxzaXbpTKnoDYM+hOOXVRRvdcZdNXKT6jvIFNZbqFjGaHwRlMIS98s/h 44h1/cf3gRwroKN2xFc/QhEWWHRD+HDAbdzrrufOLPdUNDGWMnZ8kgDSI2ZFpXXJimHY m3qfqhHIYcuE/MASuC3CwEMJlXKboz7c1kzxb7qSpW9n+Gd9arVyaJhKCJv1lBo8593H WfasNVc1aF3wp6/qN0iBI1sMn1K7eNEpDPCS0gv72FDoL2YoHl1MlAPbI7L/QKuhyeoA fA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wew9j8r9s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Feb 2024 15:07:48 +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 41NF1vix021470; Fri, 23 Feb 2024 15:07:48 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wew9j8r96-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Feb 2024 15:07:48 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 41NE3Pf0003606; Fri, 23 Feb 2024 15:07:47 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wb74u6c52-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Feb 2024 15:07:46 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41NF7fgI43778548 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Feb 2024 15:07:43 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 519B72004B; Fri, 23 Feb 2024 15:07:41 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 98BAC20040; Fri, 23 Feb 2024 15:07:38 +0000 (GMT) Received: from li-c1fdab4c-355a-11b2-a85c-ef242fe9efb4.ibm.com.com (unknown [9.43.125.115]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 23 Feb 2024 15:07:38 +0000 (GMT) From: Shrikanth Hegde To: mingo@kernel.org, peterz@infradead.org, vincent.guittot@linaro.org Cc: sshegde@linux.ibm.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 2/2] sched/fair: Use helper function to access rd->overutilized Date: Fri, 23 Feb 2024 20:37:07 +0530 Message-Id: <20240223150707.410417-3-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240223150707.410417-1-sshegde@linux.ibm.com> References: <20240223150707.410417-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: rJiHL_I9qOBGp4ncxnbQ_Q8z3mISCqwj X-Proofpoint-GUID: 7VBKvJ4J9Q3RwjXybdxeKwT9cLnf8_6e 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-23_01,2024-02-23_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 mlxscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=786 bulkscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402230110 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 9529d9ef2c5b..29a3481c55c9 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 update_rd_overutilized_status(struct root_domain *rd, int status) { @@ -6686,7 +6695,7 @@ static inline void check_update_overutilized_status(struct rq *rq) * if energy aware scheduler is being used */ if (sched_energy_enabled()) { - if (!READ_ONCE(rq->rd->overutilized) && cpu_overutilized(rq->cpu)) + if (!is_rd_overutilized(rq->rd) && cpu_overutilized(rq->cpu)) update_rd_overutilized_status(rq->rd, SG_OVERUTILIZED); } } @@ -6694,6 +6703,7 @@ static inline void check_update_overutilized_status(struct rq *rq) static inline void check_update_overutilized_status(struct rq *rq) { } static inline void update_rd_overutilized_status(struct root_domain *rd, bool status) { } +static inline int is_rd_overutilized(struct root_domain *rd) { } #endif /* Runqueue only has SCHED_IDLE tasks enqueued */ @@ -7969,7 +7979,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; /* @@ -10873,7 +10883,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