From nobody Wed Dec 17 10:59:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77CD3EE4996 for ; Mon, 21 Aug 2023 22:45:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231613AbjHUWph (ORCPT ); Mon, 21 Aug 2023 18:45:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231596AbjHUWpg (ORCPT ); Mon, 21 Aug 2023 18:45:36 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 994E611C for ; Mon, 21 Aug 2023 15:45:34 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fee51329feso14800255e9.0 for ; Mon, 21 Aug 2023 15:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20221208.gappssmtp.com; s=20221208; t=1692657933; x=1693262733; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Rzq7IbgBFvXakSTDpDD8sUuiaW62Itouod8nHWu/KrQ=; b=njsObfMPbLtoGjA7l4l+mCRF58/BRFLm3RNAL11cjYI+ph5M0gG453YGPdLJYY/t1r KJdfaKGef0nkVGD8f4bJ9xbOI2j87eEpraaVi63SlKQOw9tBFqtPxZ56BBFEtykNjzt2 ywSB9d7GE7eCbjr7FrWa/e2Ra8HH0sgHN/OpxVhKWl84bJcCi67NHLkCGf/uvLkwzaqv /KqUPDZNb93Peu4Hgbm7DmDxyflBC/HWMEtgkDGisYeXFZnetsDbpi5fOBYjjfIgbS43 rEMLV7+QC/ttQjTfqzeF3TfE3Zo+bu0uxkHgOub2BjdVG6lZEZkBh2M7S2E1VOIcmGPb Spsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692657933; x=1693262733; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Rzq7IbgBFvXakSTDpDD8sUuiaW62Itouod8nHWu/KrQ=; b=lPtxbY7mza5eqXtdha+jG633u+BB7XVjCYozqsj7PDvBMC2a/3dFWQRrIk6dKcz1Rt b6lIPLHTGmKcCj6TqJjoZPuX1GtzTgdVp7iXksHj+udzvLoCC8Z1xX3d0RKfZzUq2Iij Eo7wfGiICCNrx6jpYDxxWgnEeo/uHpA12WXfp3aVnlt96fcS8tiplyZtgML7dk/0QDI3 2UcX5XHR/j4WMQruZ7QC7+6ORZq4hyTSe4fNqdv4NrTr7ZpdKVpCMicJR6IhQGIanGwO GS3aVHNDiHg0CZaqnpU+xWN8tuqsaKaA+eOTBmqJgwA4D3jpV4tMNB8Li6oB0D0qccA9 A0rA== X-Gm-Message-State: AOJu0Yx0yOzcOY+IJUMGdsteGuso+BadYTLqyzh5ih6yzsz4q5s2To1L U+JL1IKE9FM+qBqRkMGbqaRjFL37QMpuDYL1pJQ= X-Google-Smtp-Source: AGHT+IHfRxXvJnAknB81a8TAJT4sx6xhy1IfGtec2IhtQak9V5VTrKQvhGobVueM0Gtx716z/RSvfw== X-Received: by 2002:a05:600c:2e51:b0:3f9:b867:4bb with SMTP id q17-20020a05600c2e5100b003f9b86704bbmr5935676wmf.2.1692657933204; Mon, 21 Aug 2023 15:45:33 -0700 (PDT) Received: from airbuntu.. (host109-151-228-137.range109-151.btcentralplus.com. [109.151.228.137]) by smtp.gmail.com with ESMTPSA id a1-20020a056000100100b0031981c500aasm13820788wrx.25.2023.08.21.15.45.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Aug 2023 15:45:32 -0700 (PDT) From: Qais Yousef To: Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann Cc: linux-kernel@vger.kernel.org, Lukasz Luba , Wei Wang , Xuewen Yan , Hank , Jonathan JMChen , Hongyan Xia , Qais Yousef Subject: [PATCH v4 1/3] sched/uclamp: Set max_spare_cap_cpu even if max_spare_cap is 0 Date: Mon, 21 Aug 2023 23:45:02 +0100 Message-Id: <20230821224504.710576-2-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230821224504.710576-1-qyousef@layalina.io> References: <20230821224504.710576-1-qyousef@layalina.io> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When uclamp_max is being used, the util of the task could be higher than the spare capacity of the CPU, but due to uclamp_max value we force fit it there. The way the condition for checking for max_spare_cap in find_energy_efficient_cpu() was constructed; it ignored any CPU that has its spare_cap less than or _equal_ to max_spare_cap. Since we initialize max_spare_cap to 0; this lead to never setting max_spare_cap_cpu and hence ending up never performing compute_energy() for this cluster and missing an opportunity for a better energy efficient placement to honour uclamp_max setting. max_spare_cap =3D 0; cpu_cap =3D capacity_of(cpu) - task_util(p); // 0 if task_util(p) is high ... util_fits_cpu(...); // will return true if uclamp_max forces it to fit ... // this logic will fail to update max_spare_cap_cpu if cpu_cap is 0 if (cpu_cap > max_spare_cap) { max_spare_cap =3D cpu_cap; max_spare_cap_cpu =3D cpu; } prev_spare_cap suffers from a similar problem. Fix the logic by converting the variables into long and treating -1 value as 'not populated' instead of 0 which is a viable and correct spare capacity value. We need to be careful signed comparison is used when comparing with cpu_cap in one of the conditions. Fixes: 1d42509e475c ("sched/fair: Make EAS wakeup placement consider uclamp= restrictions") Reviewed-by: Vincent Guittot Signed-off-by: Qais Yousef (Google) Reviewed-by: Dietmar Eggemann --- kernel/sched/fair.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 0b7445cd5af9..5da6538ed220 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7707,11 +7707,10 @@ static int find_energy_efficient_cpu(struct task_st= ruct *p, int prev_cpu) for (; pd; pd =3D pd->next) { unsigned long util_min =3D p_util_min, util_max =3D p_util_max; unsigned long cpu_cap, cpu_thermal_cap, util; - unsigned long cur_delta, max_spare_cap =3D 0; + long prev_spare_cap =3D -1, max_spare_cap =3D -1; unsigned long rq_util_min, rq_util_max; - unsigned long prev_spare_cap =3D 0; + unsigned long cur_delta, base_energy; int max_spare_cap_cpu =3D -1; - unsigned long base_energy; int fits, max_fits =3D -1; =20 cpumask_and(cpus, perf_domain_span(pd), cpu_online_mask); @@ -7774,7 +7773,7 @@ static int find_energy_efficient_cpu(struct task_stru= ct *p, int prev_cpu) prev_spare_cap =3D cpu_cap; prev_fits =3D fits; } else if ((fits > max_fits) || - ((fits =3D=3D max_fits) && (cpu_cap > max_spare_cap))) { + ((fits =3D=3D max_fits) && ((long)cpu_cap > max_spare_cap))) { /* * Find the CPU with the maximum spare capacity * among the remaining CPUs in the performance @@ -7786,7 +7785,7 @@ static int find_energy_efficient_cpu(struct task_stru= ct *p, int prev_cpu) } } =20 - if (max_spare_cap_cpu < 0 && prev_spare_cap =3D=3D 0) + if (max_spare_cap_cpu < 0 && prev_spare_cap < 0) continue; =20 eenv_pd_busy_time(&eenv, cpus, p); @@ -7794,7 +7793,7 @@ static int find_energy_efficient_cpu(struct task_stru= ct *p, int prev_cpu) base_energy =3D compute_energy(&eenv, pd, cpus, p, -1); =20 /* Evaluate the energy impact of using prev_cpu. */ - if (prev_spare_cap > 0) { + if (prev_spare_cap > -1) { prev_delta =3D compute_energy(&eenv, pd, cpus, p, prev_cpu); /* CPU utilization has changed */ --=20 2.34.1 From nobody Wed Dec 17 10:59:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86201EE49A5 for ; Mon, 21 Aug 2023 22:45:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231618AbjHUWpm (ORCPT ); Mon, 21 Aug 2023 18:45:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231610AbjHUWph (ORCPT ); Mon, 21 Aug 2023 18:45:37 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90150127 for ; Mon, 21 Aug 2023 15:45:35 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-317f1c480eeso3494515f8f.2 for ; Mon, 21 Aug 2023 15:45:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20221208.gappssmtp.com; s=20221208; t=1692657934; x=1693262734; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4xo2rDYUn6cFsvHWOIxIDUTC2tCLPno1dd5/kaYQheQ=; b=hpORAIsqxPqUvsJDPgUUOgqOOsPITw5aBADc4lzUUA6cBvuQ1KnJZSpigi6sxCz1/E RqNgD7q7MM4ub1RwGERZQTkIKt5Haoomb11NxCM0EehP8nPHvZXwHvmGIjPuZqTCp9v2 HuuzNtMn6JNx3tibw/OKkefawHq13sYcL593U4c/wgWxGBemiCzNG5MksEssYeMSqbez fvACtFvQxFVAvLVf5EFejyb+CuaSKFRikv5MSyRDZWDHTvLJTe0UWwC8wNJfEf3/7+5j n0Mbg2CSgnO9IBnL8a6+EJovPPOJfxUR5lCFlnRynywifecXONZVV91Z1thS1+IjkB3x J97Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692657934; x=1693262734; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4xo2rDYUn6cFsvHWOIxIDUTC2tCLPno1dd5/kaYQheQ=; b=e3s6xaS1McXgTuQbzULWf7LEKiI1BrlWO+Dq+fXUcDKIaDgCN9JE49gJrbSEQKLet4 nLHmR4lngNDywE0ZxHvY7PCjM/QGakU0PXp7E9YCRCdNWDLSoc9K9CR2jcnkT5kxoJqC nOqrMdtoODnxgf5ot4T0oanGY45yxTxHjkitmTFS+fI2TWS90Lceol3XUtqsmu3NIv4X jyUqx9471CVPtfI+LkntanYEvK7lk7AIrjcyKmi6xZMHiwePU+NCO2Qwti2UW06HDPbz zdZGDK5PGiS9inyyNKirf6cWR2Da7rQtNv4SrvPft3s0k9BcaFzbfc4A/4ou7lKwXf0i dowA== X-Gm-Message-State: AOJu0Yz5hyA7ITCOi2xiTOWIypQ3E7aZO+kCKw/94iWqqSeiB03/Jsie na30vsdjEXHD/HHOcCp06nxoIwDh48koRLqA7Xs= X-Google-Smtp-Source: AGHT+IFiADB+DiMkzWKI/AzaBSuLw1jBHwy5dMPIUbHPNwTPAd+TEdtZpRSSgEpoh3n8MTMak2gjMQ== X-Received: by 2002:a05:6000:108f:b0:31a:e728:867d with SMTP id y15-20020a056000108f00b0031ae728867dmr5435065wrw.46.1692657934205; Mon, 21 Aug 2023 15:45:34 -0700 (PDT) Received: from airbuntu.. (host109-151-228-137.range109-151.btcentralplus.com. [109.151.228.137]) by smtp.gmail.com with ESMTPSA id a1-20020a056000100100b0031981c500aasm13820788wrx.25.2023.08.21.15.45.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Aug 2023 15:45:33 -0700 (PDT) From: Qais Yousef To: Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann Cc: linux-kernel@vger.kernel.org, Lukasz Luba , Wei Wang , Xuewen Yan , Hank , Jonathan JMChen , Hongyan Xia , Qais Yousef Subject: [PATCH v4 2/3] sched/uclamp: Ignore (util == 0) optimization in feec() when p_util_max = 0 Date: Mon, 21 Aug 2023 23:45:03 +0100 Message-Id: <20230821224504.710576-3-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230821224504.710576-1-qyousef@layalina.io> References: <20230821224504.710576-1-qyousef@layalina.io> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" find_energy_efficient_cpu() bails out early if effective util of the task is 0 as the delta at this point will be zero and there's nothing for EAS to do. When uclamp is being used, this could lead to wrong decisions when uclamp_max is set to 0. In this case the task is capped to performance point 0, but it is actually running and consuming energy and we can benefit from EAS energy calculations. Rework the condition so that it bails out for when util is actually 0 or uclamp_min is requesting a higher performance point. We can do that without needing to use uclamp_task_util(); remove it. Fixes: d81304bc6193 ("sched/uclamp: Cater for uclamp in find_energy_efficie= nt_cpu()'s early exit condition") Reviewed-by: Vincent Guittot Signed-off-by: Qais Yousef (Google) Reviewed-by: Dietmar Eggemann --- kernel/sched/fair.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 5da6538ed220..e19a36e7b433 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4571,22 +4571,6 @@ static inline unsigned long task_util_est(struct tas= k_struct *p) return max(task_util(p), _task_util_est(p)); } =20 -#ifdef CONFIG_UCLAMP_TASK -static inline unsigned long uclamp_task_util(struct task_struct *p, - unsigned long uclamp_min, - unsigned long uclamp_max) -{ - return clamp(task_util_est(p), uclamp_min, uclamp_max); -} -#else -static inline unsigned long uclamp_task_util(struct task_struct *p, - unsigned long uclamp_min, - unsigned long uclamp_max) -{ - return task_util_est(p); -} -#endif - static inline void util_est_enqueue(struct cfs_rq *cfs_rq, struct task_struct *p) { @@ -7699,7 +7683,7 @@ static int find_energy_efficient_cpu(struct task_stru= ct *p, int prev_cpu) target =3D prev_cpu; =20 sync_entity_load_avg(&p->se); - if (!uclamp_task_util(p, p_util_min, p_util_max)) + if (!task_util_est(p) && p_util_min =3D=3D 0) goto unlock; =20 eenv_task_busy_time(&eenv, p, prev_cpu); --=20 2.34.1 From nobody Wed Dec 17 10:59:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CD2CEE4996 for ; Mon, 21 Aug 2023 22:45:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231631AbjHUWpn (ORCPT ); Mon, 21 Aug 2023 18:45:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231614AbjHUWpi (ORCPT ); Mon, 21 Aug 2023 18:45:38 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7981511C for ; Mon, 21 Aug 2023 15:45:36 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fef34c33d6so10843785e9.3 for ; Mon, 21 Aug 2023 15:45:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20221208.gappssmtp.com; s=20221208; t=1692657935; x=1693262735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iTRbCBxMRaYij2kRTYuGmwmVEHPH52LS7r5bTY/h3bA=; b=UY+K+BD7c6+P2yUeQVE2TWrcWb/V3Kdcl675gl3k6bqT7wUr0Mkb2/MfvW/yFtQW9i tk7nG+P4Vjf5EM7Y+ltswVvjANHzqQ791OcknjDLaTbPzPS1Hbe94aTTFZp8cc8Lo7dy sr0crZmJ2xiu+D5Cn4PFgT+dqjy1Lqpcr5tJUWpD+G7fNhAwdeQpJR6U/vwSPwkRJKd0 QfwJY9P/QrJ5S7Tbe+4Mr5ZKZ9JZPpnKbq3q9xdDwbECfQ8B0G0/2j8mnvbS2vsX+SRt n4ZhCilaMZkRFD+TSRagKvDpPkg5LXBm6x6y23w1Fmu/dOgdBoczeRkYYN73B8vlQ06o Et2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692657935; x=1693262735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iTRbCBxMRaYij2kRTYuGmwmVEHPH52LS7r5bTY/h3bA=; b=VTXNQy+zQBHKZ0Rg7UfeWyVQZeBlicC9kODSfxisqQuP6emeD9eI9Z65TAq8pGlKTh COD5VAU49kStpPemkJZUyVs2AJmUEwzbkvzxipfF68VWJuGn+Rv8ceAScryInvYhPghO rYbONagFnMPPlaYC48PB27ux6Qyvl8oJv7zCjQnSj+Ze+8woF5nP6HWc23Oz5+k0GODq agtToIQEw9apEEklfafE+HVA2TxfCBQXn8ZwKlHI9f9pjVOgywqAKC2wGE31vRBf/41N Q+ERDenrx4OvEqiRvDbipVmwLFIpGU0jQJs3eRvUpbHvEvOU7vBx6aIyzN/ye7E8Q/9v DjlQ== X-Gm-Message-State: AOJu0YwVCzqHsSNK2GN3E4jFkSHWOf6jL+cOX4aifkaEI8jS2hg2cseX SbCFYXL6YYLTdh0W71pTa2WJ7A== X-Google-Smtp-Source: AGHT+IFGmg4UpofLbuyziHiz8PVxC78shmZ9+U/EcscObJzorr4RfANcKioe7Unt4Yi909ii9GwpZg== X-Received: by 2002:a1c:750a:0:b0:3fe:d1b9:7ea9 with SMTP id o10-20020a1c750a000000b003fed1b97ea9mr6151072wmc.36.1692657935141; Mon, 21 Aug 2023 15:45:35 -0700 (PDT) Received: from airbuntu.. (host109-151-228-137.range109-151.btcentralplus.com. [109.151.228.137]) by smtp.gmail.com with ESMTPSA id a1-20020a056000100100b0031981c500aasm13820788wrx.25.2023.08.21.15.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Aug 2023 15:45:34 -0700 (PDT) From: Qais Yousef To: Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann Cc: linux-kernel@vger.kernel.org, Lukasz Luba , Wei Wang , Xuewen Yan , Hank , Jonathan JMChen , Hongyan Xia , Qais Yousef Subject: [PATCH v4 3/3] sched/tp: Add new tracepoint to track compute energy computation Date: Mon, 21 Aug 2023 23:45:04 +0100 Message-Id: <20230821224504.710576-4-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230821224504.710576-1-qyousef@layalina.io> References: <20230821224504.710576-1-qyousef@layalina.io> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It was useful to track feec() placement decision and debug the spare capacity and optimization issues vs uclamp_max. Signed-off-by: Qais Yousef (Google) Reviewed-by: Dietmar Eggemann --- include/trace/events/sched.h | 5 +++++ kernel/sched/core.c | 1 + kernel/sched/fair.c | 7 ++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h index fbb99a61f714..a13d5d06be9d 100644 --- a/include/trace/events/sched.h +++ b/include/trace/events/sched.h @@ -735,6 +735,11 @@ DECLARE_TRACE(sched_update_nr_running_tp, TP_PROTO(struct rq *rq, int change), TP_ARGS(rq, change)); =20 +DECLARE_TRACE(sched_compute_energy_tp, + TP_PROTO(struct task_struct *p, int dst_cpu, unsigned long energy, + unsigned long max_util, unsigned long busy_time), + TP_ARGS(p, dst_cpu, energy, max_util, busy_time)); + #endif /* _TRACE_SCHED_H */ =20 /* This part must be outside protection */ diff --git a/kernel/sched/core.c b/kernel/sched/core.c index efe3848978a0..36c60ad9966a 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -114,6 +114,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_overutilized_tp); EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_cfs_tp); EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_se_tp); EXPORT_TRACEPOINT_SYMBOL_GPL(sched_update_nr_running_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL(sched_compute_energy_tp); =20 DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); =20 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e19a36e7b433..779c285203e3 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7604,11 +7604,16 @@ compute_energy(struct energy_env *eenv, struct perf= _domain *pd, { unsigned long max_util =3D eenv_pd_max_util(eenv, pd_cpus, p, dst_cpu); unsigned long busy_time =3D eenv->pd_busy_time; + unsigned long energy; =20 if (dst_cpu >=3D 0) busy_time =3D min(eenv->pd_cap, busy_time + eenv->task_busy_time); =20 - return em_cpu_energy(pd->em_pd, max_util, busy_time, eenv->cpu_cap); + energy =3D em_cpu_energy(pd->em_pd, max_util, busy_time, eenv->cpu_cap); + + trace_sched_compute_energy_tp(p, dst_cpu, energy, max_util, busy_time); + + return energy; } =20 /* --=20 2.34.1