Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp542758rdb; Thu, 2 Nov 2023 10:38:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPjcPyvYwcDE1pNRnw2hvhm/OEhZ86/kYAMdihIipNw4p3sswiwvJAXOjuX9j+zrxdJbRm X-Received: by 2002:a05:6a20:bea0:b0:161:27c5:9c41 with SMTP id gf32-20020a056a20bea000b0016127c59c41mr12222047pzb.28.1698946701702; Thu, 02 Nov 2023 10:38:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698946701; cv=none; d=google.com; s=arc-20160816; b=Tspiq0CAN2ub1/mnN7midgk54yEQ3c20Fu7F/XjKHOsnwiKkHIE3MIcY8ZnYgo7Hyw F7uDVQ5et2nN1o2UaMHRlZ1MsKHmrBOlIArfhjq1ODGkTOOqHzMfV2AFt7urRG0D1VCz iNSgIe8A+WZIFdy36gohhqv6eVEFsYSR45Kao6mZ3HgS1egNFFLLjkvlTZjXgn3WwqGm nI3eFpOdxI6+Dy6Wj7GwGPMHzUvYXHF5CbfNcqvSWyzLOzWhjWrN+dfXUrsZRFQnXXbL h8DIRGH55CrRZlTdBzPl+IQm6T36chnyfHdiNfgEcqlrkGtfLru3Pk9bmxsfz01QzVOB PS2g== 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=na3XzIvSlvDnD/eVwQVF5YKmy8BotuP7P5GCLEqwuFE=; fh=AfLL/DKK2gQQEoZBzmnH4pb//TwGt2KTQ6T6ssunXrA=; b=B33gO8DyFJKpRFVO6NOasCUxrNjixPPCA0N4nxMN7hYvG5L0BYuBraULmuNTbJXuzR lUv9319mO0Bw4YsCeiq1kG6VEyM2lxldEUT0glceeUGJ9CFQrx08PClMduilCMCyRb93 01xZZBZ9o0nHypn1saHai7u1jQIuW9SMPby3Jhgj12dVaBxwEmKClhEfgf8cJu98PKtR YM3z7m/9qht2v+U4ncNNt4XxXJ9tx8Pp0Bb/j65FvdQOdCIbuSNxn0mI2a2g8ItaAfk1 +4B/1GL+cmruuFRcGa+faFbcm5StxIMIuAPzm68+bvTFUQGox3Wp0XSwZMh0gnXKO5Jl 2Wpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id j12-20020a056a00234c00b006c0fe926fc9si44588pfj.173.2023.11.02.10.38.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 10:38:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 0C586801C02C; Thu, 2 Nov 2023 10:38:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233705AbjKBRhr (ORCPT + 99 others); Thu, 2 Nov 2023 13:37:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232902AbjKBRho (ORCPT ); Thu, 2 Nov 2023 13:37:44 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3B01D184 for ; Thu, 2 Nov 2023 10:37:37 -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 389A72F4; Thu, 2 Nov 2023 10:38:19 -0700 (PDT) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1B2D23F738; Thu, 2 Nov 2023 10:37:34 -0700 (PDT) Message-ID: Date: Thu, 2 Nov 2023 18:37:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 4/6] sched/fair: Rewrite util_fits_cpu() Content-Language: en-US To: Hongyan Xia , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Juri Lelli Cc: Qais Yousef , Morten Rasmussen , Lukasz Luba , Christian Loehle , linux-kernel@vger.kernel.org References: 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Thu, 02 Nov 2023 10:38:19 -0700 (PDT) On 04/10/2023 11:04, Hongyan Xia wrote: > From: Hongyan Xia > > Currently, there's no way to distinguish the difference between 1) a CPU > that is actually maxed out at its highest frequency, or 2) one that is > throttled because of UCLAMP_MAX, since both present util_avg values of > 1024. This is problematic because when we try to pick a CPU for a task > to run, we would like to give 2) a chance, or at least prefer 2) to 1). > > Current upstream gives neither a chance because the spare capacity is 0 > for either case. There are patches to fix this problem by considering 0 > capacities [1], but this might still be inefficient because this ends > up treating 1) and 2) equally, and will always pick the same one because > we don't change how we iterate through all CPUs. If we end up putting > many tasks on 1), then this creates a seriously unbalanced load for the > two CPUs. > > Fix by using util_avg_uclamp for util_fits_cpu(). This way, case 1) will > still keep its utilization at 1024 whereas 2) shows spare capacities if > the sum of util_avg_uclamp values is still under the CPU capacity. > Note that this is roughly what the sum aggregation does in the Android > kernel [2] (although we clamp UCLAMP_MIN as well in this patch, which > may need some discussions), which shows superior energy savings because > there's more chance that a task can get scheduled on 2) instead of > finding a big CPU to run on. > > Under sum aggregation, checking whether a task fits a CPU becomes much > simpler. We simply do fits_capacity() and there does not need to be code > checking all corner cases for uclamp. This means util_fits_cpu() returns > to true and false instead of tri-state, simplifying a significant amount > of code. You could remove util_fits_cpu() and task_fits_cpu() and call fits_capacity() directly. We should try to keep the zoo of util-related functions as small as possible. [...]