From patchwork Fri Oct 27 08:03:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 158809 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp438318vqb; Fri, 27 Oct 2023 01:08:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/AH5DuMh0SsdQ3tc77MvOv+QCLgniuutCccn5Y3TuPEJgvh63GtX0Nlazz3hiVuQnv78U X-Received: by 2002:a25:5f4d:0:b0:da0:44fa:6cb1 with SMTP id h13-20020a255f4d000000b00da044fa6cb1mr3483453ybm.6.1698394082243; Fri, 27 Oct 2023 01:08:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698394082; cv=none; d=google.com; s=arc-20160816; b=BG3Yp1CNxPjVQFPdXhHWw/Gw3cEP6rmP5LUOr+pPSiS9howrP2aVQibRE6igyTdLgB Qo4x7k4Tx96a/jrib3VotpNX0VPnX0f9te6axrnhTpf1Z1uu02+iMAZBct3l3ESQp91Z ARok+7FEELCH7HFBjk9OFMZ9NDoCc8HHuFsXi/592Qw6A5pV1RQDTOjqnTJACyfOEh1r mahGxW39FFCJL+9kZ5NMs7gGrZYS85uHet8KaCImti5aT7s+QcnJZLoaALsX78AwucbF FDULfIC6nYXe84rO9wXK7+qChr3gxUJDHs22Ngdn2xYE4TNy/zeLeCICfWMe8aFja0GS bEaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c18WsKqkMLxlFb2kxy1TvqZw0mGllHhrI7E/VCZUkXM=; fh=aqXlZKEuqBn32GiqXwfBTBEPXMVE+dzbtwpLcW+Wljc=; b=vVTY18iTu4VKSBmAjZpmgHtvSLmmcmCZOFWyzJFykXlr+SAwMpbI5IpgpqcqKV4Ipq TfNDDVkdeoeX2wvjIFX7YdL3hgt6RYsNvPOVoi7zABaOAJbFDcON9oHXk9iLaHW+4uqb L2ME8BQrZrWu4TDo5rtAO+ey7Qe5Vn+8EBrn1GqpdboWQintu79oOgdX6SOY61rvjpI1 dO+dg0H4rn7MLKDe3gIYmj2mfERGK+6UKMzQH6AdCBLaG+2ktVzdolDX93JGOUcnCzfi 8qycX52FLM8udxuQKRYL9wKPcyMhqmwEe7v98QKso3ycQr5ovuliJT1W5+IUb/iyc6Kl qXKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="q/hXih+d"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id w9-20020a05690204e900b00da06fb44e62si1811700ybs.300.2023.10.27.01.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 01:08:02 -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; dkim=pass header.i=@linaro.org header.s=google header.b="q/hXih+d"; 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=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 pete.vger.email (Postfix) with ESMTP id A366D8042B79; Fri, 27 Oct 2023 01:05:34 -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 S235149AbjJ0IEr (ORCPT + 26 others); Fri, 27 Oct 2023 04:04:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235126AbjJ0IEe (ORCPT ); Fri, 27 Oct 2023 04:04:34 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3E1D1B9 for ; Fri, 27 Oct 2023 01:04:18 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-5079f9675c6so2745462e87.2 for ; Fri, 27 Oct 2023 01:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698393857; x=1698998657; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c18WsKqkMLxlFb2kxy1TvqZw0mGllHhrI7E/VCZUkXM=; b=q/hXih+d/oCm2aSJa4q02OZKkW1RVmFrLh1IxuBe0NS8MK1lPFBQxs1qnKHV66sqWN ZohVFDk9Fy7SxPXr4CgkXE62CTCSwLokru99Ir7CgPg1eppEgeDjmVRGg57qR0t7CdxD gVcpsr1HauYsCItYCXmlsbJ7D5H1nEOp/MVFmjfoGGQKOwrZGle4tjNGKkb7R3EQPWAG h6re274P+wmBwUOxaZK97BKffAmFeLqeTlGgpC0jjUprR6itqqEUSzSFbCvoCa5aKc5K VuUOxt+HOWB/VeTQuNAfW5KqlVvqg8k4ADKMJOpNwkBAfUnW7AQcBE4LQPMAL4jNFqzo jGNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698393857; x=1698998657; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c18WsKqkMLxlFb2kxy1TvqZw0mGllHhrI7E/VCZUkXM=; b=bv0HBjPj6VhM5fidxKROeT/yoVkBa/GVlQ1LdiOga/HipyZKwYFJO3VXlrBIFWwfBO YHB3ix3u16w3A8fCkFYLR6lIf7WH1tBCDf289WghL3WI6Nzh2kMHvHFxmYDQ6ShAUVKL 24NsiPXZcC5jkXrF3L6Czfo8W2+SskSA5OjjqlGbGo/ZseDoCJsYaDkJv+4L90UMksaE uE3+OptIUsASNJyqKBLS8Jh2K4Xkni1C8JCktax7S8JlGpMDZh09J3E9daPXzfdnsrMt I2txzxzBJ7bN/x9iGKqI46dGIJVR0LcyKo0eMQmYG+9gLrnxvVXP0sd3PRcxQlTwHZHq G//A== X-Gm-Message-State: AOJu0Yz7wAaz3aJn3TlI/yd7otwK/odREmchSmn0Udm9lX64JIkmZfRo wFoS9Ztilzw3mimMCoi9fRlTYw== X-Received: by 2002:a05:6512:3287:b0:500:aed0:cb1b with SMTP id p7-20020a056512328700b00500aed0cb1bmr1288833lfe.24.1698393856230; Fri, 27 Oct 2023 01:04:16 -0700 (PDT) Received: from vingu-book.. ([2a01:e0a:f:6020:c5e:e24e:ad0b:58c6]) by smtp.gmail.com with ESMTPSA id 17-20020a05600c025100b004083729fc14sm4397488wmj.20.2023.10.27.01.04.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 01:04:15 -0700 (PDT) From: Vincent Guittot To: 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, pierre.gondois@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 Cc: conor.dooley@microchip.com, suagrfillet@gmail.com, ajones@ventanamicro.com, lftan@kernel.org, Vincent Guittot Subject: [PATCH v4 6/7] cpufreq/cppc: set the frequency used for computing the capacity Date: Fri, 27 Oct 2023 10:03:59 +0200 Message-Id: <20231027080400.56703-7-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231027080400.56703-1-vincent.guittot@linaro.org> References: <20231027080400.56703-1-vincent.guittot@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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]); Fri, 27 Oct 2023 01:05:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780895273178142630 X-GMAIL-MSGID: 1780895273178142630 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]); + 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");