From nobody Sat Sep 13 04:02:17 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 4FCA9CD13D1 for ; Sat, 16 Sep 2023 23:35:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235376AbjIPXa3 (ORCPT ); Sat, 16 Sep 2023 19:30:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232530AbjIPXaT (ORCPT ); Sat, 16 Sep 2023 19:30:19 -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 AE345CD1 for ; Sat, 16 Sep 2023 16:30:11 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-404314388ceso35094835e9.2 for ; Sat, 16 Sep 2023 16:30:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1694907010; x=1695511810; darn=vger.kernel.org; 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=OWEM5rFnaxOpgcGqQ9iXm3kgW4XrovKW3FNIx9UUP3U=; b=aX0OVGvG8a6WCDG1Hz5uw3UYiluU7DKtM7LcqqRaPC7q20kcZsaG3q6KimWyKqCaLP kGi/+c+KzTZQMjnmMH2vnBjHmv4Kx84zMDNqUT8SzqHZHl4Em5B6ev56jk7SvyXQZrR9 WPqX7Y9TBes7u+Z8ayKNE4VvYuJMbVJRP1Lh4xnRVprv5v8XRX/XuuW9JL15miZC0vzi AJyQkSmVH5hfdRK3+DZnzZNqW3BegBN1Pb08eUaBSm32EyzYACz6nmKLIAR0Yu7Tol4a gUJTszRXy338qUC336Dv3t2sONouPtOraFMp2Qm0Id3v1FRBBgx588EFtxZ8lpxiRUun swUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694907010; x=1695511810; 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=OWEM5rFnaxOpgcGqQ9iXm3kgW4XrovKW3FNIx9UUP3U=; b=oGWSGD3JTZdyfQm1LRjS97TtuN4TZWy3EvfARTRiveut6tlp5DTJemG9lTsgftbhWS kRLMyct6YjtKERHvmdFTe0lJeAoIE4kF9fLAZ3RY99be6/oP6jIqv/S302Sxh8fIXcsD dAB4csUTFpaRSuAlXLvU/sxolw+vgKClft12/m/ILqt0wfCXWfMPDQXuDcXsXMhC668H WUbF8yNbRlvcQN2mLJIacC9vTyHCBhR6YaL58GMSSITZHlS7dSLSdWiKrHzlckp2vVA3 HwwYjjf8RDf37Qa6CL7GSRRgyFYEeB8rK2nT1n/X7uUpX8aXPXCJT6NXfCv9Fo8J5P9+ UAJg== X-Gm-Message-State: AOJu0YxlWo5aqNQtwGVhIXQoTgBpcIzA6OEc1shfmkbKNrxTDORZZU7G ZR+ajUPd3zeaXrP/E/oWuCChzg== X-Google-Smtp-Source: AGHT+IH8zt9b/coOQ/xxZj95zGbY/KfbY9VgHNql/0TMbF0y5DIMj6gMNv9nWvsWMlFWXyyAhIvdwQ== X-Received: by 2002:a1c:7407:0:b0:3fd:30cb:18bd with SMTP id p7-20020a1c7407000000b003fd30cb18bdmr4936651wmc.15.1694907009520; Sat, 16 Sep 2023 16:30:09 -0700 (PDT) Received: from airbuntu.. (host109-151-228-137.range109-151.btcentralplus.com. [109.151.228.137]) by smtp.gmail.com with ESMTPSA id b14-20020a05600c11ce00b003fee8502999sm11203929wmi.18.2023.09.16.16.30.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 16:30:09 -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 v5 1/3] sched/uclamp: Set max_spare_cap_cpu even if max_spare_cap is 0 Date: Sun, 17 Sep 2023 00:29:53 +0100 Message-Id: <20230916232955.2099394-2-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230916232955.2099394-1-qyousef@layalina.io> References: <20230916232955.2099394-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) - cpu_util(p); // 0 if cpu_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 Reviewed-by: Dietmar Eggemann Signed-off-by: Qais Yousef (Google) --- 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 c893721ff5b1..3a0a28a0b9c7 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7695,11 +7695,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); @@ -7762,7 +7761,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 @@ -7774,7 +7773,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); @@ -7782,7 +7781,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 Sat Sep 13 04:02:17 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 3E7C1C2BA1B for ; Sat, 16 Sep 2023 23:35:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235638AbjIPXab (ORCPT ); Sat, 16 Sep 2023 19:30:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232389AbjIPXaS (ORCPT ); Sat, 16 Sep 2023 19:30:18 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3211ACD3 for ; Sat, 16 Sep 2023 16:30:13 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-402d499580dso36058615e9.1 for ; Sat, 16 Sep 2023 16:30:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1694907011; x=1695511811; darn=vger.kernel.org; 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=KjwrFheoCHUo12B1slBH8742esS72cLDk94QJ+87wIg=; b=JKqcgBNEEnaF+XBWVoJMf8mIPlL7G+jVMkGzgxujVdgHdO/jsehHsNxNN8secWe1cs bDt7+o4/0Ar9atEk9TZcXdLzZ26qauMTXlVbZtYusOJ1iqjftmv4kjqaZsXWPUGtJcFT hrexe+Y3ERRf2MUfw+7UQFI1oDjGflYarO8fweO0yrYaenoqmTkpsXf/ph8+QioansRn 1wSCJKfW5Du1jpzGzhSdlaUtWFUTW8caf7D7rE+Qdk9pbIx8ujA9tm4QbK2A5Kh5+Pj5 YOT/BUh1D9zlZaOa2i80q7W1cLvKhHbub0zq7S1oIRhZhOtMCvqezd+BL0Qik5rsqtPh Zfsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694907011; x=1695511811; 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=KjwrFheoCHUo12B1slBH8742esS72cLDk94QJ+87wIg=; b=SpRiy356ZmaMVPFq/sOzEuCQ9Wi+nPHWx3sdNfwo9CfMo9Q4dcpzbIVNED1/d6Zjt/ Eym/NYory/v4J0KQmW7L+VhmW+v+hb1EKz7MAP6ZBnBJ4UaasMhLBzUXdlcivlj5sOMT QukAaOou8LFgaNhBk12PDy3RKS9nKoRicL2iSNUACIlZP3uB8+CPD+aZBQt/U5PYnKOy SaRBisrirbNobFaWd/K7kOCd0dPGXfBXxRQK0U1qflr0nMCt0kCfiQBopMJLkXCHyWhM ICnBvULf9D8OXyAecboNZ/AJRhcIX9wU87aiWyWC34vE6FX/Mfj42kWQraEwcQRubxdO hDyw== X-Gm-Message-State: AOJu0YyUWWPUjfW9XaYf94O/5SAEwk6Xqf4++fV34RhnLGxdF3engYdE +f0Wpe4ntwT7SdVrhEDmb0Uy/g== X-Google-Smtp-Source: AGHT+IHcvSC6ERLy719iC4PnIU38X71EJ3HBoioZJ4M+rvOghzBOC7h+3/wgDHTMGbZ50FrPzUXOyA== X-Received: by 2002:a05:600c:2055:b0:3fb:efe2:34a2 with SMTP id p21-20020a05600c205500b003fbefe234a2mr4568815wmg.5.1694907011584; Sat, 16 Sep 2023 16:30:11 -0700 (PDT) Received: from airbuntu.. (host109-151-228-137.range109-151.btcentralplus.com. [109.151.228.137]) by smtp.gmail.com with ESMTPSA id b14-20020a05600c11ce00b003fee8502999sm11203929wmi.18.2023.09.16.16.30.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 16:30:11 -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 v5 2/3] sched/uclamp: Ignore (util == 0) optimization in feec() when p_util_max = 0 Date: Sun, 17 Sep 2023 00:29:54 +0100 Message-Id: <20230916232955.2099394-3-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230916232955.2099394-1-qyousef@layalina.io> References: <20230916232955.2099394-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 when both util and uclamp_min are 0. 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 Reviewed-by: Dietmar Eggemann Signed-off-by: Qais Yousef (Google) --- 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 3a0a28a0b9c7..0d0582e02409 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4560,22 +4560,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) { @@ -7687,7 +7671,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 Sat Sep 13 04:02:17 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 1B170C2BA2B for ; Sat, 16 Sep 2023 23:35:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236026AbjIPXaf (ORCPT ); Sat, 16 Sep 2023 19:30:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232626AbjIPXaU (ORCPT ); Sat, 16 Sep 2023 19:30:20 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4829CD5 for ; Sat, 16 Sep 2023 16:30:14 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-401b393ddd2so38229645e9.0 for ; Sat, 16 Sep 2023 16:30:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1694907013; x=1695511813; darn=vger.kernel.org; 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=CvpHqEWL9tMeSEEzcenarEoP8GnGGnnH5tB09ndPi7w=; b=212WK3aKLXkp/Ji6htbdVwyWND4jzTXqmQxi0i+zI1H9DPa0Fj1gBl5MGtWPD3DuVs ctKF9oXotBhTigLzIwENut93eKCeaLDhffu81gcKquas7Le5Ad3RUy0Q0YfoqCz7TeDa 9ybxNXyoqDRbtokMndlh5UalyGbKgINz3szXaJwJ7n8ciepy2pJ8Bx20O2Z7GAnttnxn 2FfFLl7IF3lw2de2v6hu2IE5V+14lxfpnVy40mwwnUKt8tlQE7VM62yhW0DSAO1m+Dfn B16LfRx2dLOeMB8eITJAzlydgZl+SNnB3YcDmQ3aoRA1aLyg/MmrSSdSJ4qbCqnMF4yc 6A6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694907013; x=1695511813; 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=CvpHqEWL9tMeSEEzcenarEoP8GnGGnnH5tB09ndPi7w=; b=J5ucWGRUAKyzQMezRLD5Tt1q3yxEbOFD9zRQgOpMcSntKmSxi8O2gBkTWQTE6U1j+J skfInh1l6HJLFxRmxodFwi9kqHPfhEy3hZ8R+GRubwCPt1PlDQsf7VPyfEqUCZHHjjDK FWu61oDuYAYu4/YfTRqzKw+4dnDc6gddModKNAWMcbEjsd3FJI4vGZsSa9FqeZ5Vph0A Bxh1CVdqpGSghtTGw7rlGBYAh21tYJV2sCKHa67GMUNMlGwu3ELyDlyWEYYdyu833JWC cQFD9pyuEOn/rkahJybOy+1F/KKNNlk9/0JuXbDSFzKupRGhvJwXx8R49p07E0aMGGLR KbEA== X-Gm-Message-State: AOJu0YxcsS/YLka1aNZHXgkVnzLPMNmkQOgOyZm0+0trXwPsaOSbOhyY G1BDyTRGXLv5dE25350CzjTXjg== X-Google-Smtp-Source: AGHT+IGJaftLGOz56YNHXpoJKuj24Fzr5v2Elkfs4cvzy8dqPeKRUBAW5iVc1kJAXF0umJTJC6K+Uw== X-Received: by 2002:a7b:cd0b:0:b0:401:d947:c8a9 with SMTP id f11-20020a7bcd0b000000b00401d947c8a9mr4506416wmj.19.1694907013344; Sat, 16 Sep 2023 16:30:13 -0700 (PDT) Received: from airbuntu.. (host109-151-228-137.range109-151.btcentralplus.com. [109.151.228.137]) by smtp.gmail.com with ESMTPSA id b14-20020a05600c11ce00b003fee8502999sm11203929wmi.18.2023.09.16.16.30.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 16:30:13 -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 v5 3/3] sched/tp: Add new tracepoint to track compute energy computation Date: Sun, 17 Sep 2023 00:29:55 +0100 Message-Id: <20230916232955.2099394-4-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230916232955.2099394-1-qyousef@layalina.io> References: <20230916232955.2099394-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. Reviewed-by: Dietmar Eggemann Signed-off-by: Qais Yousef (Google) --- 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 f39482d6a6e6..cc87627a7c63 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 0d0582e02409..fd7fd7b5aef2 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7592,11 +7592,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