Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7081078rwb; Tue, 6 Dec 2022 00:28:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf4JPymh9TgovATALGPiOaF/+G6t/K2gjaW0AaMxSHHYw7E6jOJkvlKBrHstOVrB2ysbkO1L X-Received: by 2002:a17:906:f157:b0:7c0:b0fe:263a with SMTP id gw23-20020a170906f15700b007c0b0fe263amr17989806ejb.496.1670315310042; Tue, 06 Dec 2022 00:28:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670315310; cv=none; d=google.com; s=arc-20160816; b=ibauAnKtgu8WvRWp8NzLcSpjWratX6BvUHwSc958XlwFQTuyFBMchWPF2LtHeQ1LiM 8TSIiZtTJyRphH0Rv7Dnj/4LCp8EC8+l/kEyAHk1I6O/hErmOBSQ6woP9iDm35jDlww0 4EmQVGDTVJg1X+SWn9bZ/J7smSFN2v5UrlOO3ml94yxgzErGhow5mi7w3/eG+9pxDKte caDZ8OrGH6waZ/l4+VDrm4shJJgZQ0tmkuyVZwvQRxqt8nlQsb8pMhxsEq+kr1LRsoGF jzFGEZTHOZEIFDx8y5UOPgv94DCmKQsnFHttJ7bGrIej710qxLkFn17Gd5t7t7b/p3rm 2hQA== 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=irKVuEG89n7A5OrveipTr5IJDQSWHwtGshMT0FrzfjA=; b=mLtGkD+U+/g/7K9Xf1xjgPgdC4CnEMSis8VBosWFeWwouMcRxxGWAJowcQZlv42hwL PzKwHyx6DW0Ux6CH9W9voDYr1Wpk1d7MIc4c6P6bJW4ZumEXfuQyyGowFLW7u6B+WHhQ gnKghbsWMXNVuvGOINygkS7OpqZuMAZC8JgWzctFS2CvDmTh9d2zcOMQ1IPIBjVbluGL yQq3YHMCHCsn/PFeA6vVUUuPdxc3/7YVstu3pReLgLg/DB7+DuPPNXqASvartKfhX+2e APhSb6uLUPDrAJbuQ9SzzE8w0awJzNh7xMpho1aIpGS68Nkb+zWtdFwIWN8I5syhxx06 CliQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k10-20020aa7d2ca000000b0046aa7121b8csi1299620edr.232.2022.12.06.00.28.08; Tue, 06 Dec 2022 00:28:30 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233517AbiLFITg (ORCPT + 80 others); Tue, 6 Dec 2022 03:19:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233289AbiLFISq (ORCPT ); Tue, 6 Dec 2022 03:18:46 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EA233DA5; Tue, 6 Dec 2022 00:17:34 -0800 (PST) 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 BA82523A; Tue, 6 Dec 2022 00:17:17 -0800 (PST) Received: from [10.57.7.134] (unknown [10.57.7.134]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CB2403F73B; Tue, 6 Dec 2022 00:17:07 -0800 (PST) Message-ID: Date: Tue, 6 Dec 2022 08:17:05 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v1] Revert "cpufreq: schedutil: Move max CPU capacity to sugov_policy" Content-Language: en-US To: Viresh Kumar Cc: "Rafael J. Wysocki" , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Sam Wu , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Saravana Kannan , "Isaac J . Manjarres" , kernel-team@android.com, "Rafael J. Wysocki" , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20221110195732.1382314-1-wusamuel@google.com> <20221205091830.pttdbyts4hujkpq2@vireshk-i7> From: Lukasz Luba In-Reply-To: <20221205091830.pttdbyts4hujkpq2@vireshk-i7> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE 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 Hi Viresh, On 12/5/22 09:18, Viresh Kumar wrote: > Lukasz, > > On 10-11-22, 19:57, Sam Wu wrote: >> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c >> index 9161d1136d01..1207c78f85c1 100644 >> --- a/kernel/sched/cpufreq_schedutil.c >> +++ b/kernel/sched/cpufreq_schedutil.c >> @@ -25,9 +25,6 @@ struct sugov_policy { >> unsigned int next_freq; >> unsigned int cached_raw_freq; >> >> - /* max CPU capacity, which is equal for all CPUs in freq. domain */ >> - unsigned long max; >> - >> /* The next fields are only needed if fast switch cannot be used: */ >> struct irq_work irq_work; >> struct kthread_work work; >> @@ -51,6 +48,7 @@ struct sugov_cpu { >> >> unsigned long util; >> unsigned long bw_dl; >> + unsigned long max; > > IIUC, this part, i.e. moving max to sugov_policy, wasn't the problem > here, right ? Can you send a patch for that at least first, since this > is fully reverted now. > > Or it doesn't make sense? > Yes, that still could make sense. We could still optimize a bit that code in the sugov_next_freq_shared(). Look at that function. It loops over all CPUs in the policy and calls sugov_get_util() which calls this arch_scale_cpu_capacity() N times. Then it does those multiplications below: if (j_util * max > j_max * util) which will be 2*N mul operations... IMO this is pointless and heavy for LITTLE cores which are 4 or sometimes 6 in the policy. As you could see, my code just left that loop with a simple max() operation. I might just attack this code differently. Switch to that sugov_policy::max, fetch the cpu capacity only once, before that loop. I will rewrite a bit the sugov_get_util() and adjust the 2nd user of it: sugov_update_single_common() Regards, Lukasz