Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1950240rda; Tue, 24 Oct 2023 08:04:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHRpbO9wmIBMfR9hp1IDq7az9JTxo7Rqg99M/7gMTTR3OdiYINe5kvWre7sPxoV57izT8AI X-Received: by 2002:a05:6a00:1142:b0:6be:23dd:d612 with SMTP id b2-20020a056a00114200b006be23ddd612mr11425562pfm.16.1698159862920; Tue, 24 Oct 2023 08:04:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698159862; cv=none; d=google.com; s=arc-20160816; b=sYLM5MD3LoDfOCt8rOp9jtKAF1Sn8rgiwHsqd4yIPkPCvvzwObQ2bEOuXRDAZF9ulH vOkNi0yglnU1gwnCGMW9yjiPkyBp6Xcv4irTGv+n5nAgsIQmsrsKSPg5VPgD9mWMU8e9 j/BonKvYCeRkuZ5Xo1ObtvKxqWOtcvv4DyYsA8kMVoNN0vd7Gz+em8GOQXnaivvFEVGw MKN5QguJ9vB6Y7ru8IC/46KZ40jZ7YBmNvrr+wF6/xMF1NYVaJwh7IMLBcc+Gz80H8hY ZmVrqp43BmVQwrSj4+ALkEWlDdZDQuWMSBYHOmnE57xedGykzHbcxvPy0dCT6hd/89gf wVgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=uAvn+e1ipjrb0Hh2PJO0UvJE5OJclTZ0Olp7NDz94NU=; fh=PZjrIWWRvD4iOo55LJrF24sLlTaW6vK0Ie1NWePSHgQ=; b=hBfS0dnyH5JiHFIlcug4iG/75RTXDzpIVy5pWbdBy+Ooih7gPx9KjyDDw4W7RWhYi8 4nIACbItfc1jNDFel8/DbwIP8Lbmj4ZQzWgGfqRA8YMH3K9GcDRWyXkE9eugmnz9avx3 mqJVE0q0IH8x0x7C6T29/bYRQFygtHI5+BH4RF8zQErasFO2g6BfkC0FJZJRz3xo4Q2n OHGxk6tc9/xjMixix5o6jpVtopylijkG5XnE6i5wxOrGwSJdgNNRiRw5ikWVXQFk4gta JBxH9yIVwS2qo/I58kVCn2YZ5AS/RTd8VoC/bFjdjqWFopaki0oIQ2l0HNW0NsPkSAHg nPPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id q25-20020aa78439000000b006bd2e896465si8312178pfn.199.2023.10.24.08.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 08:04:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 4C86A8034A5A; Tue, 24 Oct 2023 08:03:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230018AbjJXPDg (ORCPT + 99 others); Tue, 24 Oct 2023 11:03:36 -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 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 24 Oct 2023 08:03:58 -0700 (PDT) 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.