From mboxrd@z Thu Jan 1 00:00:00 1970 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 5C627C00A8F for ; Tue, 24 Oct 2023 15:03:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229512AbjJXPDi (ORCPT ); Tue, 24 Oct 2023 11:03:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjJXPDe (ORCPT ); Tue, 24 Oct 2023 11:03:34 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 14F8D10C2 for ; Tue, 24 Oct 2023 08:03:31 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D807E2F4; Tue, 24 Oct 2023 08:04:11 -0700 (PDT) Received: from [192.168.2.82] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0CDF43F762; Tue, 24 Oct 2023 08:03:27 -0700 (PDT) Message-ID: <14ab201e-0170-4dd7-a1ec-7587fe27385a@arm.com> Date: Tue, 24 Oct 2023 17:03:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v2 1/2] sched/fair: Introduce UTIL_FITS_CAPACITY feature (v2) Content-Language: en-US To: Chen Yu , Mathieu Desnoyers Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Ingo Molnar , Valentin Schneider , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Vincent Guittot , Juri Lelli , Swapnil Sapkal , Aaron Lu , Tim Chen , K Prateek Nayak , "Gautham R . Shenoy" , x86@kernel.org References: <20231019160523.1582101-1-mathieu.desnoyers@efficios.com> <20231019160523.1582101-2-mathieu.desnoyers@efficios.com> From: Dietmar Eggemann In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/10/2023 08:10, Chen Yu wrote: > On 2023-10-23 at 11:04:49 -0400, Mathieu Desnoyers wrote: >> On 2023-10-23 10:11, Dietmar Eggemann wrote: >>> On 19/10/2023 18:05, Mathieu Desnoyers wrote: [...] >>> Or like find_energy_efficient_cpu() (feec(), used in >>> Energy-Aware-Scheduling (EAS)) which uses cpu_util(cpu, p, cpu, 0) to get: >>> >>> max(util_avg(CPU + p), util_est(CPU + p)) >> >> I've tried using cpu_util(), but unfortunately anything that considers >> blocked/sleeping tasks in its utilization total does not work for my >> use-case. >> >> From cpu_util(): >> >> * CPU utilization is the sum of running time of runnable tasks plus the >> * recent utilization of currently non-runnable tasks on that CPU. >> > > I thought cpu_util() indicates the utilization decay sum of task that was once > "running" on this CPU, but will not sum up the "util/load" of the blocked/sleeping > task? cpu_util() here refers to: cpu_util(int cpu, struct task_struct *p, int dst_cpu, int boost) which when called with (cpu, p, cpu, 0) and task_cpu(p) != cpu returns: max(util_avg(CPU + p), util_est(CPU + p)) The term `CPU utilization` in cpu_util()'s header stands for cfs_rq->avg.util_avg. It does not sum up the utilization of blocked tasks but it can contain it. They have to be a blocked tasks and not tasks which were running in cfs_rq since we subtract utilization of tasks which are migrating away from the cfs_rq (cfs_rq->removed.util_avg in remove_entity_load_avg() and update_cfs_rq_load_avg()). > accumulate_sum() > /* only the running task's util will be sum up */ > if (running) > sa->util_sum += contrib << SCHED_CAPACITY_SHIFT; > > WRITE_ONCE(sa->util_avg, sa->util_sum / divider); __update_load_avg_cfs_rq() ___update_load_sum(..., cfs_rq->curr != NULL ^^^^^^^^^^^^^^^^^^^^ running accumulate_sum() if (periods) /* decay _sum */ sa->util_sum = decay_load(sa->util_sum, ...) if (load) /* decay and accrue _sum */ contrib = __accumulate_pelt_segments(...) When crossing periods we decay the old _sum and when additionally load != 0 we decay and accrue the new _sum as well.