Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp77190rdb; Tue, 16 Jan 2024 15:48:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFidrYHh3xK0HJEWXIQJasmhjsfRK36stPcNARY2HOWPmFDJhkq6N6P3cy8t7svHlWYQrx3 X-Received: by 2002:a05:6402:1c97:b0:559:d50c:c366 with SMTP id cy23-20020a0564021c9700b00559d50cc366mr39841edb.58.1705448927949; Tue, 16 Jan 2024 15:48:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705448927; cv=pass; d=google.com; s=arc-20160816; b=wWyf5czp3ZoO76UwTupgOoaQJAVzQYGOTixYt/AbwCKU1Vtd7+T16pIon9q3QVh/u8 MBKW4ccirqtUzq7I2+w6GbwEZyQH2NcvlIBdiA9zuUKcYQ7jQSDnA/INLva3ZBOruv14 pDMjDbesJGLqfFn/r+0grDx8hDkiIRf/SZ5/ToXroxRHf/ejVJoNr6hw4DUqRxNXVPVr xyThpqmr4rqs9gUKMaTuan9L0TtrfAmBZAQbB2pznqxvq5VR4ORZwXRwz4RLg5D38/+a TPuOyxjihFB12bZsrdr0Xpn6ZkBdlEN0K28hqCXmOBYYi4LeXJN9ma59mQkLG3XebMlU xHdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=TcX6td37QRw3Q78lq9NLHvuhZmpzzW+P43xh6D/Stls=; fh=wCQfljKnjrh9XtZKXEEw9fsgRecXnC8+H/eBAcq/1gU=; b=hOYv7UOOMYuBapUcBNwnhW9yYAiIaE6be92XNPMPxFRXLj6mcK+m5E3+ziveZAot9q AYjwot7Mdu9w4H+bsyZXOnpf+ZGxwiQLxbS+CoOlY0AArNQ/6EC2C9mNRRO46ldEJHit iisL+QwNK2mBVtLrZHY069FaPWzF+R6Kk3cMpwUrdLhd0WMkuagPIqLPVKFifK+l59uf uB9iHUAxrSx/QIg6WDTRO8VN1hS4AFdPyosrlxDB9eet+Nxm0gw6AgvLEnSb01+0hgrZ uxAAVeAHIizxg3zz7ZeXMvJXgM2yu0Ud4Vlg6HGzrqyx+7dY8Iiy0fGDghK5F8CfHcCA enPg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YdYqvvKN; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-28385-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28385-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ef9-20020a05640228c900b00554c2e4e39esi5344182edb.523.2024.01.16.15.48.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 15:48:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-28385-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YdYqvvKN; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-28385-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28385-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8301F1F26F2F for ; Tue, 16 Jan 2024 23:48:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C33BF1B97E; Tue, 16 Jan 2024 23:48:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YdYqvvKN" Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FB5567C66 for ; Tue, 16 Jan 2024 23:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705448916; cv=none; b=hwlJoW2DUD8DwjysqsT/tBLOK2VoiYpxRyCF4N/wI5P6gbcwcpTtDgX5iJNzX93D/UE7QTsXFxLLf6knHSE79NbDu4aYG+4dl4fygVWEnsPZlDth3C3SJzxoXmn3P7e6NcAAqOR03oJlDWH/mQCzdwI6K7BxCoDFg7dviSPm3Q4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705448916; c=relaxed/simple; bh=O8Kq4uPVWRZlnIMs1LFsvejHjua+7vRBykNcj6Vhcqo=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:MIME-Version: References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc: Content-Type:Content-Transfer-Encoding; b=njX/QGKakk/6xvgVUdPsi0O/HPkblCKCKDu1ozuE31yiWDpepP+U4PKMepACEkCbDeAQAFG5DW6j4XfU/Oa/g2nqMHf7EWXRVsjEQgfVStGbepSX+xU1JNKGWbdDlLORwjfp49TQ4cOowjL57E8YZEbnyIbFIo1o/jfYqzJ7+V4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=YdYqvvKN; arc=none smtp.client-ip=209.85.160.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-429bdb17616so111011cf.0 for ; Tue, 16 Jan 2024 15:48:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705448914; x=1706053714; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=TcX6td37QRw3Q78lq9NLHvuhZmpzzW+P43xh6D/Stls=; b=YdYqvvKNHRTH0X/2vu0U5CkdwRnoWjDeDO9Evet+PiaE7PQPnh0lEIkDgbTwc41OkM al+iwravePihA9SjBZPRJ/9TsmgDORoA4vJbCLz36bNS2GBFkVKHWkE4D0I7T88yECc4 Mnxq1ZVxhpm3EIdis0d74KuKXCW08AagpCwL/PQ3kvqqK+triz0vVLWR6ttY+Dm01WQ/ WkBux7YfV9U718Cxx1Sywpa/glejtvh+hVIOdR9CCHwIZSYKyKge5lc4g0rnL18Lxc9Y 9pflwdwI+ZH2TYR+JT4gmm8tLlgr7xHfoVMJiPo9NVPG31Qz4IoQkP40jBvmP4P1R+jR guLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705448914; x=1706053714; h=content-transfer-encoding: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=TcX6td37QRw3Q78lq9NLHvuhZmpzzW+P43xh6D/Stls=; b=b4F5TIgKLeX5/JOmMQi29wjuoRvvbmugAfCuJXdCiKLixpIGjNBhLjVXRUr/qK5O04 GslwZjlWx2CUcx7HHvePLtdL426kpUaWBmhT2Cw07hQA/Pp10kAEFIyk4nR/z/98e7/K JRZkk/qizzaMlaoSaqG9QgLgdUT1zzCgwXyXNZuVNru6XFYgOqJ0H8R3pMfRuO296F7+ Lj9g+QRHPV66Tm2XKsBzDMe8ZATciEEIXZcS5cd5hujWTba027R9zss/eKDXaath0EUG 250xCYfLDa0gjsGprY6h/ssvAYz8W2qQK2LvvUTS3B+jVnRC+BCbcsgO2wBeoYIav2V4 J7zA== X-Gm-Message-State: AOJu0YwHa03raMMkbFh2gXmGPwnOwgZICCagKKT6YKZdHbnu/fR5dmOV kM2/KRDgtuz9AS7j/3qFqRSOkvuoc4Kx5KT9KKW5GRxZRbRBPfdJo/pcSeZkTSX6Ng4CvKIaIRO yAIfWFYbdwnw9yUTc9gdJo5dZV41o5g+gfMeJ X-Received: by 2002:a05:622a:1dc6:b0:429:b532:5075 with SMTP id bn6-20020a05622a1dc600b00429b5325075mr51787qtb.22.1705448913924; Tue, 16 Jan 2024 15:48:33 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231111014933.1934562-1-davidai@google.com> <20231111014933.1934562-2-davidai@google.com> <865y231jvj.wl-maz@kernel.org> <867clpaxel.wl-maz@kernel.org> <86zfx98tgi.wl-maz@kernel.org> In-Reply-To: <86zfx98tgi.wl-maz@kernel.org> From: Saravana Kannan Date: Tue, 16 Jan 2024 15:47:57 -0800 Message-ID: Subject: Re: [PATCH v4 1/2] dt-bindings: cpufreq: add virtual cpufreq device To: Marc Zyngier Cc: David Dai , "Rafael J. Wysocki" , Viresh Kumar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sudeep Holla , Quentin Perret , Masami Hiramatsu , Will Deacon , Peter Zijlstra , Vincent Guittot , Oliver Upton , Dietmar Eggemann , Pavan Kondeti , Gupta Pankaj , Mel Gorman , kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Jan 13, 2024 at 1:37=E2=80=AFAM Marc Zyngier wrote= : > > On Fri, 12 Jan 2024 22:02:39 +0000, > Saravana Kannan wrote: > > > > Sorry for the delay in response. Was very busy for a while and then > > holidays started. > > > > On Fri, Dec 8, 2023 at 12:52=E2=80=AFAM Marc Zyngier w= rote: > > > > > > On Thu, 07 Dec 2023 22:44:36 +0000, > > > Saravana Kannan wrote: > > > > > > > > On Wed, Nov 15, 2023 at 12:49=E2=80=AFAM Marc Zyngier wrote: > > > > > > > > > > On Sat, 11 Nov 2023 01:49:29 +0000, > > > > > David Dai wrote: > > > > > > > > > > > > Adding bindings to represent a virtual cpufreq device. > > > > > > > > > > > > Virtual machines may expose MMIO regions for a virtual cpufreq = device > > > > > > for guests to read frequency information or to request frequenc= y > > > > > > selection. The virtual cpufreq device has an individual control= ler for > > > > > > each frequency domain. > > > > > > > > > > I would really refrain form having absolute frequencies here. A > > > > > virtual machine can be migrated, and there are *zero* guarantees = that > > > > > the target system has the same clock range as the source. > > > > > > > > > > This really should be a relative number, much like the capacity. = That, > > > > > at least, can be migrated across systems. > > > > > > > > There's nothing in this patch that mandates absolute frequency. > > > > In true KVM philosophy, we leave it to the VMM to decide. > > > > > > This has nothing to do with KVM. It would apply to any execution > > > environment, including QEMU in TCG mode. > > > > > > To quote the original patch: > > > > > > + description: > > > + Address and size of region containing frequency controls for e= ach of the > > > + frequency domains. Regions for each frequency domain is placed > > > + contiugously and contain registers for controlling DVFS(Dynami= c Frequency > > > + and Voltage) characteristics. The size of the region is propor= tional to > > > + total number of frequency domains. > > > > > > What part of that indicates that *relative* frequencies are > > > acceptable? The example explicitly uses the opp-v2 binding, which > > > clearly is about absolute frequency. > > > > We can update the doc to make that clearer and update the example too. > > > > > To reiterate: absolute frequencies are not the right tool for the job= , > > > and they should explicitly be described as relative in the spec. Not > > > left as a "whatev'" option for the execution environment to interpret= . > > > > I think it depends on the use case. If there's no plan to migrate the > > VM across different devices, there's no need to do the unnecessary > > normalization back and forth. > > VM migration is a given, specially when QEMU is involved. Designing > something that doesn't support it is a bug, plain and simple. I'm not saying this patch series doesn't allow migrating. I'm just pointing out that normalization might not always be worth it for a VMM to do. We'll update the example and documentation to used normalize values. CPUfreq itself used KHz for the tables and we can't really change that when we are emulating CPU freq scaling. Same goes for OPP table DT property names. But the values we use can be 0 to 1024 Hz and be normalized. > > And if we can translate between pCPU frequency and a normalized > > frequency, we can do the same for whatever made up frequencies too. In > > fact, we plan to do exactly that in our internal use cases for this. > > There's nothing here that prevents the VMM from doing that. > > > > Also, if there are hardware virtualized performance counters (AMU, > > CPPC, etc) that are used for frequency normalization, then we have to > > use the real frequencies in those devices otherwise the "current > > frequency" can be 2 GHz while the max normalized frequency is 1024 > > KHz. That'll mess up load tracking. > > And that's exactly why this shouldn't be a *frequency*, but a > performance scale or some other unit-less coefficient. Just like the > big-little capacity. Sorry I wasn't cleared in my explanation. Let me explain it better. When performance counters are available, the scheduler uses them to compute the current average CPU frequency over a scheduler tick. It looks at the performance counters to figure out how many CPU cycles have gone by and how much time has gone by and does (delta cycles / delta seconds) to compute current CPU freq in Hz. So, when a HW virtualized performance counter is available, and the scheduler inside the VM uses it to compute the average CPU frequency, the resulting frequency is going to be the real physical CPU frequency. And the CPU frequency value the scheduler used to compute the PELT load will be completely different from the normalized values and the load tracking will be completely wrong. Using their performance counters inside the VM reduces a lot of MMIO access exits to the host or memory accesses. So it makes sense a VM might want to use that. I was just trying to say that in that situation, a VMM might have a good reason to just use the real frequencies inside the VM too. In any case, we can update the doc to use normalized values/examples and call out this caveat. Thanks, Saravana