Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp281098rdb; Thu, 2 Nov 2023 03:43:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFv3cfDf2jfwRTtckh/7mRGSHA5Fd6yVBbmalOg2ulaGrJszvpOuYQMqut/Pc+rljV9Wre4 X-Received: by 2002:a17:90a:d497:b0:27f:ecd9:6d0e with SMTP id s23-20020a17090ad49700b0027fecd96d0emr16861128pju.34.1698921794976; Thu, 02 Nov 2023 03:43:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698921794; cv=none; d=google.com; s=arc-20160816; b=gJesIScVcCiZ6WbMxLh/cGsDAS3qZ7juqgX0Estdx7Ky1Dzw2DlyWsWhYh4hnadCra +SMDnGAXsyQWRMZhboh9xH55IqjfpldUjQ/cthqTwD2ioHGcXxUiZskhvXzkZmlUUMGA CX6vuVvBHk5l28vG6s0gHAsBqSffmGyAiJvE1aG8Tto38RDXHSqAt3gTKW/cBIySRN9s oW3R1IDjvm1/JFj4IxEIUiVZj8nRa83W/D9kOTLRPeWbgKr0SKYK/UTwx4KMNTED+mVw wc4vgUWX9DYunbU80dLaocrCfhG+DWvx0QhXivhdTRCp1eHv9gToTzaHrQyZjpMIJN5H F2hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Pd/NLx66E9zKbyZKSmW6GKzzom6QC7VJQH4VG6waGJI=; fh=qyY9fkgIK5+FbHQtmSg7O3wx2+X5KB4rGNUVHUjCh3U=; b=V5tdSfgVQCSH3ORQEFE6lNA60cfCIlUOmcr0tfnclpNXFM9jk6mDfcVR4YfzoXgTZL u5nON5+ztJzNwQIlh1zi9odrKC9eK259W5vY1RXQ1A9Fa5SCRnhyieda88zozbYD8Ko3 aLF/WvwD+DZRFzOrsHlKkKJTC8crQ7UFwAPyZaeOQS2pUQXnbmRAgPSU8s5YzxacqtMD 9yvSAh+Xb1zcY/ZbkYoKkONmqilu5j175djgaq15FtHL2QSyQiygM/rWjmZHXBK5KLDt 8FWWDlPgyzLl976ONSaeEQaJzTO9IRLmN84+ooqY4i//Ro2m57vKP1VzuqOhvnGO72UQ rNmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JngVmes3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id o5-20020a17090ac70500b0027cff4f35cbsi2662221pjt.73.2023.11.02.03.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 03:43:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JngVmes3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 43F6A8051A27; Thu, 2 Nov 2023 03:43:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347153AbjKBKm5 (ORCPT + 99 others); Thu, 2 Nov 2023 06:42:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346637AbjKBKmy (ORCPT ); Thu, 2 Nov 2023 06:42:54 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21E4DE7 for ; Thu, 2 Nov 2023 03:42:49 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6be1bc5aa1cso830495b3a.3 for ; Thu, 02 Nov 2023 03:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698921768; x=1699526568; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Pd/NLx66E9zKbyZKSmW6GKzzom6QC7VJQH4VG6waGJI=; b=JngVmes3LKL+tq7VRLskzUathjAuUPBIpszmIMvi3JExngnHk7fEGjBCmyK6b6fzmL 9vibGKdEzIVQIPiw1q6hq2zzk0GTT0bplbFF7K/Ehvr+C9LGpARQIUlJTyJUojn2O9Xa DyKmHYD7ZT1LvwIWMa8FNYuiiPtM3BJO3KW3Cg+4oB7C7K+W8bT6SOTjvknOPSadAjRl s3wz8pD14HiI7XsUvKThGzo4XtirBs3croyMI9QyYBG02+lfGM8DTPF0bCeV0UzCjfBn wHTx2EQ6KCG4LZIeKu/J6sC8570D1LrwoJ0XQRNn13fbvaMbbysI0BZHLEJ3oQ+ocD5o P7QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698921768; x=1699526568; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Pd/NLx66E9zKbyZKSmW6GKzzom6QC7VJQH4VG6waGJI=; b=XGu5fGk8CeCsiDYxkdj9CUQACgGFzFJ/ddXNJ+rMcFP4q24U45wJMo3EDBOtAxLb10 a4Cdm1bLBz1ry9SWSVRQT9etgZesfzNLS4TXChrIGcEEFCm+cfr5v4bppROuDPCk1lCt OwUVdbaBuWqoY1furwbn+pnCqvvZvC3lC7kHhB04PXNLEsXfLswPBYn2pVpyDCIV4fDF xVZSLpqx6um+pI+339LzAHKJn5KEjHgNIkZGRwSPwdAZcj6oLvHa6EP1i9KKIV68Suke 1WWNyXaEFxJxJXimOlHZ52Y4QzEFOYiqx56AL8M4Yv2okdeC7BFZkIOFX4VzPZq5Ndi1 ZTBQ== X-Gm-Message-State: AOJu0Yz2wBX1lLpOUuQNFIiF8RTJL+7ljgGKg8YZJKyrBp/nuH3PrYsM D6tCGk0/K8GfLg4g88tTi7mN37/k06AlwyoMRzVLQQ== X-Received: by 2002:a05:6a21:7903:b0:181:7914:7b34 with SMTP id bg3-20020a056a21790300b0018179147b34mr3334001pzc.21.1698921768594; Thu, 02 Nov 2023 03:42:48 -0700 (PDT) MIME-Version: 1.0 References: <20231027080400.56703-1-vincent.guittot@linaro.org> <20231027080400.56703-7-vincent.guittot@linaro.org> <89b5db0e-1121-4d0c-a8f4-1202465f5251@arm.com> In-Reply-To: <89b5db0e-1121-4d0c-a8f4-1202465f5251@arm.com> From: Vincent Guittot Date: Thu, 2 Nov 2023 11:42:37 +0100 Message-ID: Subject: Re: [PATCH v4 6/7] cpufreq/cppc: set the frequency used for computing the capacity To: Pierre Gondois Cc: linux@armlinux.org.uk, catalin.marinas@arm.com, will@kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, sudeep.holla@arm.com, gregkh@linuxfoundation.org, rafael@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, viresh.kumar@linaro.org, lenb@kernel.org, robert.moore@intel.com, lukasz.luba@arm.com, ionela.voinescu@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linuxfoundation.org, conor.dooley@microchip.com, suagrfillet@gmail.com, ajones@ventanamicro.com, lftan@kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 02 Nov 2023 03:43:10 -0700 (PDT) Hi Pierre, On Thu, 2 Nov 2023 at 10:07, Pierre Gondois wrote: > > Hello Vincent, > > On 10/27/23 10:03, Vincent Guittot wrote: > > Save the frequency associated to the performance that has been used when > > initializing the capacity of CPUs. > > Also, cppc cpufreq driver can register an artificial energy model. In such > > case, it needs the frequency for this compute capacity. > > > > Signed-off-by: Vincent Guittot > > --- > > drivers/base/arch_topology.c | 15 ++++++++++++++- > > 1 file changed, 14 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c > > index 9a073c2d2086..d4bef370feb3 100644 > > --- a/drivers/base/arch_topology.c > > +++ b/drivers/base/arch_topology.c > > @@ -349,6 +349,7 @@ bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) > > > > void topology_init_cpu_capacity_cppc(void) > > { > > + u64 capacity, capacity_scale = 0; > > struct cppc_perf_caps perf_caps; > > int cpu; > > > > @@ -365,6 +366,10 @@ void topology_init_cpu_capacity_cppc(void) > > (perf_caps.highest_perf >= perf_caps.nominal_perf) && > > (perf_caps.highest_perf >= perf_caps.lowest_perf)) { > > raw_capacity[cpu] = perf_caps.highest_perf; > > + capacity_scale = max_t(u64, capacity_scale, raw_capacity[cpu]); > > + > > + per_cpu(capacity_ref_freq, cpu) = cppc_perf_to_khz(&perf_caps, raw_capacity[cpu]); > > + > > To continue Beata's point, I think there is an issue with the following: > cppc_perf_to_khz() and cppc_khz_to_perf() were previously used with a struct containing > frequencies in KHz, cf. [1]. > In the original _CPC object, frequencies are in MHz. It means that the perf_caps struct > here contains frequencies in MHz, and per_cpu(capacity_ref_freq, cpu) is in MHz aswell. Yeah, I haven't noticed this intermediate step in cppc_cpufreq. I'm going to fix this > > [1] https://github.com/torvalds/linux/blob/master/drivers/cpufreq/cppc_cpufreq.c#L682 > > > > pr_debug("cpu_capacity: CPU%d cpu_capacity=%u (raw).\n", > > cpu, raw_capacity[cpu]); > > continue; > > @@ -375,7 +380,15 @@ void topology_init_cpu_capacity_cppc(void) > > goto exit; > > } > > > > - topology_normalize_cpu_scale(); > > + for_each_possible_cpu(cpu) { > > + capacity = raw_capacity[cpu]; > > + capacity = div64_u64(capacity << SCHED_CAPACITY_SHIFT, > > + capacity_scale); > > + topology_set_cpu_scale(cpu, capacity); > > + pr_debug("cpu_capacity: CPU%d cpu_capacity=%lu\n", > > + cpu, topology_get_cpu_scale(cpu)); > > + } > > + > > schedule_work(&update_topology_flags_work); > > pr_debug("cpu_capacity: cpu_capacity initialization done\n"); > >