From patchwork Sun Feb 5 22:43:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qais Yousef X-Patchwork-Id: 52937 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1951738wrn; Sun, 5 Feb 2023 14:47:50 -0800 (PST) X-Google-Smtp-Source: AK7set/gt8iby/YQN4X6xzvhlNg809vbU58NuSz3r+APIIEKwi6eoEB8cv8ZoX9zD99BCvoA4qPS X-Received: by 2002:a17:906:53d4:b0:878:7ef1:4a20 with SMTP id p20-20020a17090653d400b008787ef14a20mr18576541ejo.4.1675637270548; Sun, 05 Feb 2023 14:47:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675637270; cv=none; d=google.com; s=arc-20160816; b=0zqiobYJ/1x5QJMwl3vlsNiVDLmJQG/zeljMt58FeWsLu98lHuALFRlJLfmnvEfYYg QGyS4YRdBUaonYFQZFjgFomzK2W4Jx1PXv9xj+IDwORs7OFDOMY3WS4N7RWObObapDPG IUTw/EoAovl76k61Rkla5VNjb2Uiv3t4NQm1GLvfXzAvISAPmq1OncMxYtzNi+lofwCs Kv4iDb1/YmlGY0mrW74ZzHJgw9KQmovR7Ctj52IspUsXIVw0sScHUUjYQjvwPbU32LSP JUOYt/AWObIj35+1DO05EhnfTOiZrqHHhLarhaju3U+CyjXYoUrwkjn5N2WAwgNqS7UQ JMFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pIDKpUZt2NnF88laBIzE/5NEaQ9UqssI9HVNrkQhbgE=; b=0RcE4RttGJoRPpeJclC165eJwDIkhjcVHD7EPM9/py+2tXwt3g8fkw365jVaBGnf85 1h3VcJL/L3/s+aRxqU9GMd7M9UWRn/6yPkN+3qbwz5HZWwk1tyHup7tvWKaZvHvr7GRV 97kO4Q5ietYIws4zu31MKWrbw4meUI2UZDi/0RwkSsK+j3fe8xsIsB7ggZcQSen4OlKy 8vW7kGtWFdWE14hpBT5bcTXF4qC+HkJecCGJU3z04Uf2ZYqGvufpa6JSaSVAXVVkby+v hEE6H0DCh/gL1RqFvh/7cGTjtbQutp7IYikSnZNqvIVu0QJSGyqOk+u1eRkTPM1Dn2mQ jwAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@layalina-io.20210112.gappssmtp.com header.s=20210112 header.b=BYL6g5q0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf21-20020a170906c51500b0088eb55ed9d5si8729841ejb.691.2023.02.05.14.47.27; Sun, 05 Feb 2023 14:47:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@layalina-io.20210112.gappssmtp.com header.s=20210112 header.b=BYL6g5q0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229634AbjBEWng (ORCPT + 99 others); Sun, 5 Feb 2023 17:43:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229559AbjBEWne (ORCPT ); Sun, 5 Feb 2023 17:43:34 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F4171A48B for ; Sun, 5 Feb 2023 14:43:33 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id mc11so29413885ejb.10 for ; Sun, 05 Feb 2023 14:43:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20210112.gappssmtp.com; s=20210112; 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=pIDKpUZt2NnF88laBIzE/5NEaQ9UqssI9HVNrkQhbgE=; b=BYL6g5q0EgU9yBxQf59pxMHrdp1oJDqgGJKpiH0qmaXrec/HizPz/+HDUzVpKPquzt jwPEksnWqxxjLC4BpeKg0GTRgY32ad/U4zL9/vWP6yA87pREBy9YG7b10bAdwo7bajFV mB6ZwqlT9bKrj1w37xQZbbc2C9zoEtmPu9L8akdb8BkhUBUXujw2ZcBeAG+NS9vEcNjD pA+FZU5Qe3xN7Mpa8SCiutAXaHs8wU38lo2XdQvmktH6q2GAbK90E2A3GtaQt+hk7SZ/ eFBSeiDwkHddL+oL7MH846vP1n+U/ZF16gijT9LVsyF+cVo5HkNbRkiX5Ke7dnKf3kSf O47g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=pIDKpUZt2NnF88laBIzE/5NEaQ9UqssI9HVNrkQhbgE=; b=UC3NrRwN1ALxr7viDtfDXMBz6tSocy6nPpeoY+naDUhZCgRQBTxNszmbGTJHQC3l1B b2/op3tGtEe7JntNm6nFSLD82XRIVk+F8/IZS8vkl3A5zl0wdYp+zIqPEMRItmXMj1dz EGAou4g5VbDbnFUaHcIOC41aqStpOefly1PDITYIh7sjT4SuwkbAa9Nd7+DoN9pUDjRT O7Eke84e1PijoPSRC0MS8wpaTmTDdzmlGgIWb55hE7RA+kUOL2M/DaFO/2YukTpbzp28 6GnfL+pEf9QB2tORDwPHGKwAwEAu/RVCv7ypKtlziGkYZ17ucRY9ewyZvCyxmXBx3CvZ bs/w== X-Gm-Message-State: AO0yUKXgx724NHWZEOgqCoR/t7AmVCaNDGBR9uI5zvaTy8sW/PkoH22l n4DZFUZWDu6PVEL1jJA/seygcg== X-Received: by 2002:a17:907:3a97:b0:880:2870:7849 with SMTP id fh23-20020a1709073a9700b0088028707849mr13763626ejc.74.1675637011804; Sun, 05 Feb 2023 14:43:31 -0800 (PST) Received: from localhost.localdomain (host86-163-35-10.range86-163.btcentralplus.com. [86.163.35.10]) by smtp.gmail.com with ESMTPSA id m15-20020a1709061ecf00b0087bd2924e74sm4550779ejj.205.2023.02.05.14.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Feb 2023 14:43:31 -0800 (PST) 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 , Qais Yousef Subject: [PATCH v2 1/3] sched/uclamp: Set max_spare_cap_cpu even if max_spare_cap is 0 Date: Sun, 5 Feb 2023 22:43:16 +0000 Message-Id: <20230205224318.2035646-2-qyousef@layalina.io> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230205224318.2035646-1-qyousef@layalina.io> References: <20230205224318.2035646-1-qyousef@layalina.io> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757033026842864418?= X-GMAIL-MSGID: =?utf-8?q?1757033026842864418?= 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 = 0; cpu_cap = 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 = cpu_cap; max_spare_cap_cpu = 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. Fixes: 1d42509e475c ("sched/fair: Make EAS wakeup placement consider uclamp restrictions") Signed-off-by: Qais Yousef (Google) --- kernel/sched/fair.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index c6c8e7f52935..7a21ee74139f 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7382,11 +7382,10 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) for (; pd; pd = pd->next) { unsigned long util_min = p_util_min, util_max = p_util_max; unsigned long cpu_cap, cpu_thermal_cap, util; - unsigned long cur_delta, max_spare_cap = 0; + long prev_spare_cap = -1, max_spare_cap = -1; unsigned long rq_util_min, rq_util_max; - unsigned long prev_spare_cap = 0; + unsigned long cur_delta, base_energy; int max_spare_cap_cpu = -1; - unsigned long base_energy; int fits, max_fits = -1; cpumask_and(cpus, perf_domain_span(pd), cpu_online_mask); @@ -7461,7 +7460,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) } } - if (max_spare_cap_cpu < 0 && prev_spare_cap == 0) + if (max_spare_cap_cpu < 0 && prev_spare_cap < 0) continue; eenv_pd_busy_time(&eenv, cpus, p); @@ -7469,7 +7468,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) base_energy = compute_energy(&eenv, pd, cpus, p, -1); /* Evaluate the energy impact of using prev_cpu. */ - if (prev_spare_cap > 0) { + if (prev_spare_cap > -1) { prev_delta = compute_energy(&eenv, pd, cpus, p, prev_cpu); /* CPU utilization has changed */ From patchwork Sun Feb 5 22:43:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qais Yousef X-Patchwork-Id: 52939 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1960960wrn; Sun, 5 Feb 2023 15:19:14 -0800 (PST) X-Google-Smtp-Source: AK7set+7PBvyhiIoMjfI7ipPsKl6Cw1VlAuGeX6A20DjWpRJ0rlHdXb5RZE/YvMnFXDbSyVuQPRs X-Received: by 2002:a17:907:362:b0:839:74cf:7c4f with SMTP id rs2-20020a170907036200b0083974cf7c4fmr18344031ejb.8.1675639154775; Sun, 05 Feb 2023 15:19:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675639154; cv=none; d=google.com; s=arc-20160816; b=VXSDQpn1f9UVCUYJDUevNNEn27MSkzenl59jKlc96qQ3a/yFfMti/HagBoGFGfHk7c qUxR1shrFZrNnBUIWXL8OFkJeq/A9PsspsF6IIUUY6v/NSfu8FqV8IcZiXOigVTiBBSg 6AIAdA2zFfL7/w9KnPOukkiHeLaKFesl1qRsdQ1pNN++Vd+vRKkj2rIQTKMjZCUWP4EQ x2UIYh3sIElzF7rxDZGpXC7C7T79FlBsYRStoezEgBIKmftMLKtMTQQLY5b3EBJ6REew lpD5eDeyRcbeYcW20+DRpKIF1ArUZK0WcSrYtC19DKUJ9S8EGSMGPF7bwjhKP+Ka+79n Gpfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iqPeO/kNGQGc1U6cNoUfj1cL/02jGGj55jKIfeMBJNg=; b=AtasHvE8Qou78fY86dU8Bq8tlKyZpzesRZZibaA/xADEN2GauXymFBEXQLzr6mvpT3 /Bt8S1mtSXVU8SD1PoGJZ5DHZryYOpb+wNelmFCFVZz6PcDb+aSbf9nsj6lB6Owg4/p0 ut1w5wADcXpStMylMZjSFDGid+Am/xAKr7y5ahCkRAfvI5Utj01prhbW+cqcYR6sa86e DVr7dSOjwaZg+X164Kypr2ka5d7WRkvqYKxm/KKUaxezq1nZr+SQRtsAKE8cw+oe/Zcy 3euLDhUtHQi0n8eEdejayj8n6UGydPdydczWooo58Z2pmzZvgF5SV9tlC8ZgbhC+Fb4Y R4/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@layalina-io.20210112.gappssmtp.com header.s=20210112 header.b=apA3c6eD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wc6-20020a170907124600b008327270a7e0si9744281ejb.65.2023.02.05.15.18.49; Sun, 05 Feb 2023 15:19:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@layalina-io.20210112.gappssmtp.com header.s=20210112 header.b=apA3c6eD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229651AbjBEWni (ORCPT + 99 others); Sun, 5 Feb 2023 17:43:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229621AbjBEWng (ORCPT ); Sun, 5 Feb 2023 17:43:36 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50DDF1A97A for ; Sun, 5 Feb 2023 14:43:35 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id ud5so29496468ejc.4 for ; Sun, 05 Feb 2023 14:43:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20210112.gappssmtp.com; s=20210112; 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=iqPeO/kNGQGc1U6cNoUfj1cL/02jGGj55jKIfeMBJNg=; b=apA3c6eDRcMeQ3Nve4KdAFI74pKWD9vJPKKZpCZ/HAILY0DgzjeQcRi8Zb9Zkf8TqJ 4Rn8f9MDiKOJ0oeNkWy/rmJtbw7/VfoxMWzPnKw1PRj0r3v+ubz8dwRO/76dBhWn28cn WWELacMc7LuFipok14FAxsmsSLq0A2UrB4jgEetCe6fEITMmMtAeK9o2pyPjaTVt2QIh oDyRaNdUKF+AlM5v/lcZLFfd78jjKoFuFNT5P6Di66OQdl3Y1tG7swhrK/i3Kqrs8Urv rJR53AfbAQ2M4lH8HRSnBd21qh+viMQWXsIhp/3iTHPBzlV8QC0Eq+GELeuhGcGm4/a1 9R5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=iqPeO/kNGQGc1U6cNoUfj1cL/02jGGj55jKIfeMBJNg=; b=BDQ1VUAw+hJfE37QpViYQVd6egoE/4pVM4BAOkWslmzJunkp38fFXLdIuolPKfSWft P9rbQzmqMzkS53kmDVRChfBTNjD+fvIcfkAISjZIAZT8eE2BbZlx1TVUxgaEGjlALC9g MaWm56gCQHnIVgYviVHoqy/SX1uLUObg8+3yXIcs8I7/CAwEF0INYQy+6OxK7MxDTCLQ WpyLef73BkjIKXfBx8thE3FlfVfOObvbgGark64h4sM7nrXPc0LHyMHkorh2h3Lr1AGw 7EYRQS0sT73N1CZlWKu6Mej2qnrnzOxHncyGDv7PEAbZkt6/fcVPzBox37ekar2Y6pBP oqpQ== X-Gm-Message-State: AO0yUKWX5aYV736TxPjD8+wBAZSsVMSUPFhKY5xmnXLF+GZ5i0BmDS+S +bcOzgB8JlWxPRKygeUWh/fCReKm/fpd1Ktz X-Received: by 2002:a17:906:1291:b0:88a:73b7:6d5f with SMTP id k17-20020a170906129100b0088a73b76d5fmr14446059ejb.10.1675637013831; Sun, 05 Feb 2023 14:43:33 -0800 (PST) Received: from localhost.localdomain (host86-163-35-10.range86-163.btcentralplus.com. [86.163.35.10]) by smtp.gmail.com with ESMTPSA id m15-20020a1709061ecf00b0087bd2924e74sm4550779ejj.205.2023.02.05.14.43.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Feb 2023 14:43:33 -0800 (PST) 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 , Qais Yousef Subject: [PATCH v2 2/3] sched/uclamp: Ignore (util == 0) optimization in feec() when p_util_max = 0 Date: Sun, 5 Feb 2023 22:43:17 +0000 Message-Id: <20230205224318.2035646-3-qyousef@layalina.io> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230205224318.2035646-1-qyousef@layalina.io> References: <20230205224318.2035646-1-qyousef@layalina.io> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757035002440324949?= X-GMAIL-MSGID: =?utf-8?q?1757035002440324949?= find_energy_efficient_cpu() bails out early if effective util of the task is 0. When uclamp is being used, this could lead to wrong decisions when uclamp_max is set to 0. Cater for that. Fixes: d81304bc6193 ("sched/uclamp: Cater for uclamp in find_energy_efficient_cpu()'s early exit condition") Signed-off-by: Qais Yousef --- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 7a21ee74139f..a8c3d92ff3f6 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7374,7 +7374,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) target = prev_cpu; sync_entity_load_avg(&p->se); - if (!uclamp_task_util(p, p_util_min, p_util_max)) + if (!uclamp_task_util(p, p_util_min, p_util_max) && p_util_max != 0) goto unlock; eenv_task_busy_time(&eenv, p, prev_cpu); From patchwork Sun Feb 5 22:43:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qais Yousef X-Patchwork-Id: 52938 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1952588wrn; Sun, 5 Feb 2023 14:51:50 -0800 (PST) X-Google-Smtp-Source: AK7set8B5FtORyRduigjWRFkAWuaowGLpyprDTlUHlye9ac5vtT0TPVHJInaaEf5k12qA8iItnEC X-Received: by 2002:a17:906:c08f:b0:88c:a2cb:d06d with SMTP id f15-20020a170906c08f00b0088ca2cbd06dmr17447141ejz.31.1675637510165; Sun, 05 Feb 2023 14:51:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675637510; cv=none; d=google.com; s=arc-20160816; b=xmgvfzsIwx6TzPcNCTckE7Vo2Dd8oaF/UseERFNfuZsW9mdFvd4d6g3H8TO5bUgCbn vlvSkNDQyFQ1IVwZ/A3gEn6Vt90feLKxbdjZx9K/lJVFIV/cxWo/Jvsas7vOfIuRUD9w vtJNu2lLUbnQ6E1yMK+8RvZ/p5t86HwqAA4kbHKHpSq5cvdXKhKyDNC7LmHsOFMp6ISZ 3vy97iVi05+3J4hQU4XbXxWWV+hnfHzRh4+PSxVTUao/GG2U6TF0JwdzN2rHYcog1FNN H0AgUabk1G2aHk0ARwXkuuFP3wHDwQCeJCPwv5CnpuvZDwo7jSMhTXhgLevVu0Ozy4yF sr/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/esgXyXTTPxQhwv1dQWaspfNIbrAOoa4gfi3afJxYbI=; b=xc+rzV982fu0yLafQD8zmIX6kRHDgbMD7eL5h/sW1uQjMZ1MemD5nU44I1a2SGmeFD vGnzENb5tIyOtqdf7PigJXccZwCxDwhxGQ6YKsMtZ0unaOC6jxf858xKFsmvnZHcEuG/ BsoRCbvUWKhUW+vikwAgLnbC3qM3B84yeMk+zOW6uieJhe0A1e5FvV91Ft/Ehtpjm1iv q3ZLaoE6jTQQmYY3CSB2BWdFseiJes0MRk1Fc/YgGTq0vL5X8VMCF47KlmgtfPu6tATo l0NvssHJCebpUPWbhB0s4efEp8VDor+rS1n9bioaqSQqGJrprmIR/XioWdxBebGuTE3Y 4CRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@layalina-io.20210112.gappssmtp.com header.s=20210112 header.b=saj4RMnp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f1-20020a170906738100b00889c115cf70si12054641ejl.190.2023.02.05.14.51.26; Sun, 05 Feb 2023 14:51:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@layalina-io.20210112.gappssmtp.com header.s=20210112 header.b=saj4RMnp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229669AbjBEWnl (ORCPT + 99 others); Sun, 5 Feb 2023 17:43:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229559AbjBEWni (ORCPT ); Sun, 5 Feb 2023 17:43:38 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B6021B55C for ; Sun, 5 Feb 2023 14:43:37 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id e22so158033ejb.1 for ; Sun, 05 Feb 2023 14:43:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20210112.gappssmtp.com; s=20210112; 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=/esgXyXTTPxQhwv1dQWaspfNIbrAOoa4gfi3afJxYbI=; b=saj4RMnp18qzp3YrMX0TvOgrT4AhT+MZWfVpznyOwkspaZ7mHFNPNL8wgFYJ8UpNe2 QsY1OW+ovidQImrOqpQ9IrUAxLltUpGfv2ST1CYutfGFZTPFpK0gMsqLjI5o3qVXQI5h ln17Y+sihiyTJ8pTngx/S0qj64QlZp29zrWuMc3rJaM49/yX+pZMq+oiCpT+g5Y5iwmC xgNjXnKZiJ1E6Ek+5FOptZFgcUIrSP/isqFSGiFWhR8FQEruttKhC2prknON/QJ5Vzmu nYiG57CCGb+nhFsyRnztxW8+ojJKINiXYn/irMUP+pNILIMlZVC8q1JNwUKGVOTZJyZG Kimg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=/esgXyXTTPxQhwv1dQWaspfNIbrAOoa4gfi3afJxYbI=; b=8IZb2VLAuK+zGtyKN3/oQVor0INGUBbIQoMk3eOiYsawhpbhwP2b2tLcsHrBT85fK6 2UOmVSgNY3pvblsb6ZXwqGBd02bo8zPrviiVrclPUkTQ8mv0ZWMZn8UGGjnBcRXhdnTY krLEVIzvIv5TQoJH/cPGqGVRW15+WUjVy7m4U5P8IMoX+OQcnKVpEGEpHLFlFh+MSGX4 zqyC41Kvm7Bf9CqxUKOzx0gROe57lGKf+70uJbPpZ4UchR/xf7bIW4HRMCKlAuLQhjxS hlVNVJhLXCHC94tEqMb9LwWRERKWGuBcQrHmoVC2JOB4Jid24lo+KNIO+j3RUOFz5tqd mRwQ== X-Gm-Message-State: AO0yUKXaR+MlOSF/UuKlSTHLzRzDVyoldl0f4YfWo3tE6ImgvEbyRKMi jSCeHPMFaSlKgGkv5Ob9cGAoag== X-Received: by 2002:a17:906:4c84:b0:88a:da35:dd51 with SMTP id q4-20020a1709064c8400b0088ada35dd51mr17534300eju.14.1675637015794; Sun, 05 Feb 2023 14:43:35 -0800 (PST) Received: from localhost.localdomain (host86-163-35-10.range86-163.btcentralplus.com. [86.163.35.10]) by smtp.gmail.com with ESMTPSA id m15-20020a1709061ecf00b0087bd2924e74sm4550779ejj.205.2023.02.05.14.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Feb 2023 14:43:35 -0800 (PST) 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 , Qais Yousef Subject: [PATCH v2 3/3] sched/tp: Add new tracepoint to track compute energy computation Date: Sun, 5 Feb 2023 22:43:18 +0000 Message-Id: <20230205224318.2035646-4-qyousef@layalina.io> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230205224318.2035646-1-qyousef@layalina.io> References: <20230205224318.2035646-1-qyousef@layalina.io> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757033277615723481?= X-GMAIL-MSGID: =?utf-8?q?1757033277615723481?= It was useful to track feec() placement decision and debug the spare capacity and optimization issues vs uclamp_max. Signed-off-by: Qais Yousef --- include/trace/events/sched.h | 4 ++++ kernel/sched/core.c | 1 + kernel/sched/fair.c | 7 ++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h index fbb99a61f714..20cc884f72ff 100644 --- a/include/trace/events/sched.h +++ b/include/trace/events/sched.h @@ -735,6 +735,10 @@ DECLARE_TRACE(sched_update_nr_running_tp, TP_PROTO(struct rq *rq, int change), TP_ARGS(rq, change)); +DECLARE_TRACE(sched_compute_energy_tp, + TP_PROTO(struct task_struct *p, int dst_cpu, unsigned long energy), + TP_ARGS(p, dst_cpu, energy)); + #endif /* _TRACE_SCHED_H */ /* This part must be outside protection */ diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 4580fe3e1d0c..5f6dde9b892b 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -110,6 +110,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); DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index a8c3d92ff3f6..801e903c4307 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7295,11 +7295,16 @@ compute_energy(struct energy_env *eenv, struct perf_domain *pd, { unsigned long max_util = eenv_pd_max_util(eenv, pd_cpus, p, dst_cpu); unsigned long busy_time = eenv->pd_busy_time; + unsigned long energy; if (dst_cpu >= 0) busy_time = min(eenv->pd_cap, busy_time + eenv->task_busy_time); - return em_cpu_energy(pd->em_pd, max_util, busy_time, eenv->cpu_cap); + energy = em_cpu_energy(pd->em_pd, max_util, busy_time, eenv->cpu_cap); + + trace_sched_compute_energy_tp(p, dst_cpu, energy); + + return energy; } /*