From patchwork Fri Feb 23 15:07:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shrikanth Hegde X-Patchwork-Id: 205454 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp644037dyb; Fri, 23 Feb 2024 07:08:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX6U+BRhqrP464fMtnsq4ATwBJuSaOTcP5zLmfoTju1jYBur8RzH0xrpPqc3OP2pcVdhnAVeD2fhdX4KaeHA6ufmkhVcQ== X-Google-Smtp-Source: AGHT+IFbXmjxv0KQ2aY9NrdircdfxzLsHaLWKo+ot/AG+2ttysAGwNpL2wocJAw8lYl4yg9HTIT4 X-Received: by 2002:a25:bad0:0:b0:dcc:e854:d453 with SMTP id a16-20020a25bad0000000b00dcce854d453mr65926ybk.1.1708700924475; Fri, 23 Feb 2024 07:08:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708700924; cv=pass; d=google.com; s=arc-20160816; b=OwrKMRDylW8zIhsPmhGis6PLMkegxO0karfUSRSTFR4kPnCXU4Xv3lardkCunwAV0D bzdPrdAFJwvzl3XGsYvMXdMDWHPpm3yG778n4nFH5DRxIYEuS58S8xXo1OeU1UrMoUkm KdLSBQg9BrX5SI+8CF/zW1s8rhBVDb/oKcDuthAGDPyTPmkMVOkmFrPAyG8P8OvuTdff UBUPNmpRPhJDOv5kDwwlKzV8coJ+tG7x3QdszkL9t0UlxSPFrCQo57wwS2FCfq0v8mOb qVOvsyAV4KBEHjmGwlH1BbyAEArJRscF8vDtXITSWiYUmKK7263TQwM96PB46mmBFaaF hiDA== 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=+Rgu1HCWPbClxoqHwxH9oS5K5pDAyvJB9bP93pSTws0=; fh=zQwkmEr4k4gfxfJxm2TKw1Yg6aZZbX5YCn4imrpFWMQ=; b=J+T0flcar7nW/sShEVpbUESuQ/Ty/1qxfAjkwDKa0vagvXb2tpYcT1EH2Jm4fEwV6I +4S3OAFHwsU3Udh9WR0iFfwQTl0/+XzkLaVhx/4x42cnJBqQTTg7egk0UJE+/FYBtHRi B4wE46GR3j1PllUkxbt+ExXqU09Nys+CeU5ZlyXi2LDwDa9Dxzdn1noiqJu/xQGo19wR Xye6pmXyRoEG0e2IDlIwAzn146TIPCbFT7zT1dvpzjcXC1rKz6GbmaWhJmZ5u6K+xzq5 zoU7ao8v7SUQ8lch6wv1Nr1azlh0bKPcVjMwDpuaSjQCBDlwwGDt4ERtY7hXFIX1tQQh gDPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=CVsWHFzm; 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-78574-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78574-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g19-20020a25ae53000000b00dcdaefb3816si6094012ybe.29.2024.02.23.07.08.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 07:08:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78574-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=CVsWHFzm; 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-78574-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78574-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 361A41C22EF5 for ; Fri, 23 Feb 2024 15:08:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2788A8288D; Fri, 23 Feb 2024 15:08:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="CVsWHFzm" 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 C8A7D29AF for ; Fri, 23 Feb 2024 15:08:07 +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=1708700889; cv=none; b=CM3LqP07E3gbLnyYjLXjGfw30ppWhqI+QGXO3B1sNxF/crEPt+8/hmyihTq+9EsPyeB4wtGA/wxcuirDgRcj4sNuKVqis4uYsdY/P1WHA65/ji12faVuSOQ8j80m/TD1lkCtBX3m/He6ENRDuczm0mEadk/3XZg3Ty5K9pr4Q+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708700889; c=relaxed/simple; bh=Sov6ZXkWtBkWruu+5JsAXVtkAInsivzIlIrWhB/fdK4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Y35Y/rFAapnNr49StSCCGzqaHh+TbM8is6zeQODsuHk4nVkFvapMvJ2VlrSkK2fH5OvoCg/tuTEEJhEStvqOKV74ruWVFkayMERxDnxgBJN9AK8Y7UWg6GgNY/qnwHIL8nH91wwOLk+BXknSpdt6YdlLvxA2twYKlLUZCk9hYDw= 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=CVsWHFzm; 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 (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41NEgamg017903; Fri, 23 Feb 2024 15:07:44 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=+Rgu1HCWPbClxoqHwxH9oS5K5pDAyvJB9bP93pSTws0=; b=CVsWHFzmPLOZJvkPXe9Hl+CfNVn2UbWg6fJvAtJpKs74LvLQYD8MKrMAKwQs72JIIOVW d2qxS1dZ8Suy8U983rNSTM2NLbSS73fFVorAHA/rFl+XFWrDT8ppkPjXkvhO12dROKuL /mi8xkEd9EQ6/iaC5wUWUeZynP3ZhEmrnau6oVeaT8Xus0epof7K3A8cHTjVj23dz38W ZWOejM8P7sB9Ua6C/97WTJN8xZDa9PubFA1COLuCm/OtOo5L/UJ+6uq575uiYnjgAtRU fry3Yu3pkr3R1ToOF+sohRnxTXZn9Ry3sEMqFrmBWYMrJV6/DGbjgPEntd0gmAa5rUUU BA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wewbyguf9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Feb 2024 15:07:44 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 41NEhwv4023217; Fri, 23 Feb 2024 15:07:43 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 3wewbygues-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Feb 2024 15:07:43 +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 41NDwuIi003623; Fri, 23 Feb 2024 15:07:42 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wb74u6c4n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Feb 2024 15:07:42 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41NF7b2Z64291144 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Feb 2024 15:07:39 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1260F20043; Fri, 23 Feb 2024 15:07:37 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F17220040; Fri, 23 Feb 2024 15:07:34 +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:34 +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 1/2] sched/fair: Add EAS checks before updating overutilized Date: Fri, 23 Feb 2024 20:37:06 +0530 Message-Id: <20240223150707.410417-2-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 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 3BYzekx7VTsS-3SEOdnOvJOJyiN99qE1 X-Proofpoint-ORIG-GUID: 9YcPV_8v9UEarWp5xexERSP0NL1KZ_ak 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 mlxlogscore=999 malwarescore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402230110 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791702780654766177 X-GMAIL-MSGID: 1791702780654766177 Overutilized field of root domain is only used for EAS(energy aware scheduler) to decide whether to do regular load balance or EAS aware load balance. It is not used if EAS not possible. Currently enqueue_task_fair and task_tick_fair accesses, sometime updates this field. In update_sd_lb_stats it is updated often. Which causes cache contention due to load/store tearing and burns a lot of cycles. Hence add EAS check before updating this field. EAS check is optimized at compile time or it is static branch. Hence it shouldn't cost much. With the patch, both enqueue_task_fair and newidle_balance don't show up as hot routines in perf profile. 6.8-rc4: 7.18% swapper [kernel.vmlinux] [k] enqueue_task_fair 6.78% s [kernel.vmlinux] [k] newidle_balance +patch: 0.14% swapper [kernel.vmlinux] [k] enqueue_task_fair 0.00% swapper [kernel.vmlinux] [k] newidle_balance While here, Fix updating overutilized as either SG_OVERUTILIZED or 0 instead. Current code can make it 0, 1 or 2. This shouldn't alter the functionality. Fixes: 2802bf3cd936 ("sched/fair: Add over-utilization/tipping point indicator") Signed-off-by: Shrikanth Hegde --- kernel/sched/fair.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) -- 2.39.3 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 8e30e2bb77a0..9529d9ef2c5b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6670,15 +6670,30 @@ static inline bool cpu_overutilized(int cpu) return !util_fits_cpu(cpu_util_cfs(cpu), rq_util_min, rq_util_max, cpu); } -static inline void update_overutilized_status(struct rq *rq) +static inline void update_rd_overutilized_status(struct root_domain *rd, + int status) { - if (!READ_ONCE(rq->rd->overutilized) && cpu_overutilized(rq->cpu)) { - WRITE_ONCE(rq->rd->overutilized, SG_OVERUTILIZED); - trace_sched_overutilized_tp(rq->rd, SG_OVERUTILIZED); + if (sched_energy_enabled()) { + WRITE_ONCE(rd->overutilized, status); + trace_sched_overutilized_tp(rd, !!status); + } +} + +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()) { + if (!READ_ONCE(rq->rd->overutilized) && cpu_overutilized(rq->cpu)) + update_rd_overutilized_status(rq->rd, SG_OVERUTILIZED); } } #else -static inline void 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) { } #endif /* Runqueue only has SCHED_IDLE tasks enqueued */ @@ -6779,7 +6794,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) * and the following generally works well enough in practice. */ if (!task_new) - update_overutilized_status(rq); + check_update_overutilized_status(rq); enqueue_throttle: assert_list_leaf_cfs_rq(rq); @@ -10613,13 +10628,12 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd WRITE_ONCE(rd->overload, sg_status & SG_OVERLOAD); /* Update over-utilization (tipping point, U >= 0) indicator */ - WRITE_ONCE(rd->overutilized, sg_status & SG_OVERUTILIZED); - trace_sched_overutilized_tp(rd, sg_status & SG_OVERUTILIZED); + update_rd_overutilized_status(rd, + (sg_status & SG_OVERUTILIZED) ? SG_OVERUTILIZED : 0); } else if (sg_status & SG_OVERUTILIZED) { struct root_domain *rd = env->dst_rq->rd; - WRITE_ONCE(rd->overutilized, SG_OVERUTILIZED); - trace_sched_overutilized_tp(rd, SG_OVERUTILIZED); + update_rd_overutilized_status(rd, SG_OVERUTILIZED); } update_idle_cpu_scan(env, sum_util); @@ -12625,7 +12639,7 @@ static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued) task_tick_numa(rq, curr); update_misfit_status(curr, rq); - update_overutilized_status(task_rq(curr)); + check_update_overutilized_status(task_rq(curr)); task_tick_core(rq, curr); } From patchwork Fri Feb 23 15:07:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shrikanth Hegde X-Patchwork-Id: 205455 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp645852dyb; Fri, 23 Feb 2024 07:11:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW8BJzAR2oSA+uS6lmGlRCw3HdEHKfM5OwvE2G3CKso7rDbxXD02xvRvyvVlvJjlbEGOBgd9wYku4fhKIaJ7DdmkCbKcw== X-Google-Smtp-Source: AGHT+IHEOor8j+OCfGGc7Q7tZm3/HEbzOrn5HyZ1QgrmbBjBaSz8Se4xq7+V5LxMxKrPbRS5+xOB X-Received: by 2002:a17:902:ce89:b0:1dc:696d:ec6e with SMTP id f9-20020a170902ce8900b001dc696dec6emr110120plg.21.1708701070418; Fri, 23 Feb 2024 07:11:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708701070; cv=pass; d=google.com; s=arc-20160816; b=XypIhJ3ZdZ06hJrrMG1YS22tQLquzCmyjEoFLuEwfpOiUtp2oQadEuMZTfPiKlDzHQ xRihIAHdcsE8Pw5/wHIcXEEhqD5gBA26N8O0Q0B5oVjaZ8KNOp5q1wuY0kvr95g0vmfg XrC9F7msIhTZMsQq/zuAlfI2rywyFK0wFjspQ0EfO/IuHkJ9MFWoD5dsSFix1YMtfMV2 vwILIGNtxx1ZFh80LkCQ6DhIKEBTGEPSiBncPSR28E2WQv8MgfmwL1/Y+ZGUo0zKpj75 Sh3H9w1+4pPSIsMWQxZdi7oSJ8FKzIvoUuLe9uhYsSgNFrTbPA0BlNvU7UGurpBj6myI 3WAQ== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78575-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id u14-20020a170902e80e00b001d8da1c6933si12636155plg.58.2024.02.23.07.11.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 07:11:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78575-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78575-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 131BCB247C8 for ; Fri, 23 Feb 2024 15:09:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 99177823A8; Fri, 23 Feb 2024 15:08:31 +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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791702933724977294 X-GMAIL-MSGID: 1791702933724977294 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(-) -- 2.39.3 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; }