diff mbox series

[RFC,v2,5/6] dt-bindings: cpufreq: add bindings for virtual kvm cpufreq

Message ID 20230331014356.1033759-6-davidai@google.com (mailing list archive)
State RFC, archived
Headers show
Series Improve VM CPUfreq and task placement behavior | expand

Commit Message

David Dai March 31, 2023, 1:43 a.m. UTC
Add devicetree bindings for a virtual kvm cpufreq driver.

Co-developed-by: Saravana Kannan <saravanak@google.com>
Signed-off-by: Saravana Kannan <saravanak@google.com>
Signed-off-by: David Dai <davidai@google.com>
---
 .../bindings/cpufreq/cpufreq-virtual-kvm.yaml | 39 +++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml

Comments

Krzysztof Kozlowski March 31, 2023, 8:55 a.m. UTC | #1
On 31/03/2023 03:43, David Dai wrote:
> Add devicetree bindings for a virtual kvm cpufreq driver.

Why? Why virtual devices should be documented in DT? DT is for
non-discoverable hardware, right? You have entire commit msg to explain
it instead of saying something easily visible by the diff.

> 
> Co-developed-by: Saravana Kannan <saravanak@google.com>
> Signed-off-by: Saravana Kannan <saravanak@google.com>
> Signed-off-by: David Dai <davidai@google.com>
> ---
>  .../bindings/cpufreq/cpufreq-virtual-kvm.yaml | 39 +++++++++++++++++++
>  1 file changed, 39 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml
> 
> diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml b/Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml
> new file mode 100644
> index 000000000000..31e64558a7f1
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml
> @@ -0,0 +1,39 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/cpufreq/cpufreq-virtual-kvm.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Virtual KVM CPUFreq
> +
> +maintainers:
> +  - David Dai <davidai@google.com>
> +
> +description: |

Do not need '|'.
> +

Drop stray blank line.

> +  KVM CPUFreq is a virtualized driver in guest kernels that sends utilization
> +  of its vCPUs as a hint to the host. The host uses hint to schedule vCPU
> +  threads and select CPU frequency. It enables accurate Per-Entity Load
> +  Tracking for tasks running in the guest by querying host CPU frequency
> +  unless a virtualized FIE exists(Like AMUs).

No clue why you need DT bindings for this. KVM has interfaces between
host and guests.

> +
> +properties:
> +  compatible:
> +    const: virtual,kvm-cpufreq
> +
> +required:
> +  - compatible
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    {

This is some broken syntax and/or indentation.

I don't get what this node is about.

> +      #address-cells = <2>;
> +      #size-cells = <2>;

Why?

> +
> +      cpufreq {
> +            compatible = "virtual,kvm-cpufreq";
> +      };
> +

Drop stray blank lines

> +    };

Best regards,
Krzysztof
Rob Herring (Arm) March 31, 2023, 12:42 p.m. UTC | #2
On Thu, 30 Mar 2023 18:43:49 -0700, David Dai wrote:
> Add devicetree bindings for a virtual kvm cpufreq driver.
> 
> Co-developed-by: Saravana Kannan <saravanak@google.com>
> Signed-off-by: Saravana Kannan <saravanak@google.com>
> Signed-off-by: David Dai <davidai@google.com>
> ---
>  .../bindings/cpufreq/cpufreq-virtual-kvm.yaml | 39 +++++++++++++++++++
>  1 file changed, 39 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml
> 

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Error: Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.example.dts:18.9-10 syntax error
FATAL ERROR: Unable to parse input tree
make[1]: *** [scripts/Makefile.lib:419: Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.example.dtb] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1512: dt_binding_check] Error 2

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20230331014356.1033759-6-davidai@google.com

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.
Rob Herring March 31, 2023, 12:46 p.m. UTC | #3
On Thu, Mar 30, 2023 at 8:45 PM David Dai <davidai@google.com> wrote:
>
> Add devicetree bindings for a virtual kvm cpufreq driver.
>
> Co-developed-by: Saravana Kannan <saravanak@google.com>
> Signed-off-by: Saravana Kannan <saravanak@google.com>
> Signed-off-by: David Dai <davidai@google.com>
> ---
>  .../bindings/cpufreq/cpufreq-virtual-kvm.yaml | 39 +++++++++++++++++++
>  1 file changed, 39 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml
>
> diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml b/Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml
> new file mode 100644
> index 000000000000..31e64558a7f1
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml
> @@ -0,0 +1,39 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/cpufreq/cpufreq-virtual-kvm.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Virtual KVM CPUFreq
> +
> +maintainers:
> +  - David Dai <davidai@google.com>
> +
> +description: |
> +
> +  KVM CPUFreq is a virtualized driver in guest kernels that sends utilization
> +  of its vCPUs as a hint to the host. The host uses hint to schedule vCPU
> +  threads and select CPU frequency. It enables accurate Per-Entity Load
> +  Tracking for tasks running in the guest by querying host CPU frequency
> +  unless a virtualized FIE exists(Like AMUs).
> +
> +properties:
> +  compatible:
> +    const: virtual,kvm-cpufreq
> +
> +required:
> +  - compatible
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    {
> +      #address-cells = <2>;
> +      #size-cells = <2>;
> +
> +      cpufreq {
> +            compatible = "virtual,kvm-cpufreq";
> +      };

The same thing was tried on non-virtual h/w too. This is not a device
so it doesn't go in DT. It is just an abuse of DT as a kernel driver
instantiation mechanism.

Rob
Saravana Kannan April 5, 2023, 10:07 p.m. UTC | #4
On Fri, Mar 31, 2023 at 5:47 AM Rob Herring <robh+dt@kernel.org> wrote:
>
> On Thu, Mar 30, 2023 at 8:45 PM David Dai <davidai@google.com> wrote:
> >
> > Add devicetree bindings for a virtual kvm cpufreq driver.
> >
> > Co-developed-by: Saravana Kannan <saravanak@google.com>
> > Signed-off-by: Saravana Kannan <saravanak@google.com>
> > Signed-off-by: David Dai <davidai@google.com>
> > ---
> >  .../bindings/cpufreq/cpufreq-virtual-kvm.yaml | 39 +++++++++++++++++++
> >  1 file changed, 39 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml b/Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml
> > new file mode 100644
> > index 000000000000..31e64558a7f1
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml
> > @@ -0,0 +1,39 @@
> > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/cpufreq/cpufreq-virtual-kvm.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Virtual KVM CPUFreq
> > +
> > +maintainers:
> > +  - David Dai <davidai@google.com>
> > +
> > +description: |
> > +
> > +  KVM CPUFreq is a virtualized driver in guest kernels that sends utilization
> > +  of its vCPUs as a hint to the host. The host uses hint to schedule vCPU
> > +  threads and select CPU frequency. It enables accurate Per-Entity Load
> > +  Tracking for tasks running in the guest by querying host CPU frequency
> > +  unless a virtualized FIE exists(Like AMUs).
> > +
> > +properties:
> > +  compatible:
> > +    const: virtual,kvm-cpufreq
> > +
> > +required:
> > +  - compatible
> > +
> > +additionalProperties: false
> > +
> > +examples:
> > +  - |
> > +    {
> > +      #address-cells = <2>;
> > +      #size-cells = <2>;
> > +
> > +      cpufreq {
> > +            compatible = "virtual,kvm-cpufreq";
> > +      };
>
> The same thing was tried on non-virtual h/w too. This is not a device
> so it doesn't go in DT. It is just an abuse of DT as a kernel driver
> instantiation mechanism.

Because it has no registers it's reading and writing, right? Yeah,
just went with this for now to make it easy for people to cherry pick
and test it. Maybe we shouldn't have added documentation and made this
look too official.

In the end, I'm expecting this will be a real MMIO device. Until we
move from RFC to PATCH, feel free to ignore this patch.

-Saravana
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml b/Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml
new file mode 100644
index 000000000000..31e64558a7f1
--- /dev/null
+++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-virtual-kvm.yaml
@@ -0,0 +1,39 @@ 
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/cpufreq/cpufreq-virtual-kvm.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Virtual KVM CPUFreq
+
+maintainers:
+  - David Dai <davidai@google.com>
+
+description: |
+
+  KVM CPUFreq is a virtualized driver in guest kernels that sends utilization
+  of its vCPUs as a hint to the host. The host uses hint to schedule vCPU
+  threads and select CPU frequency. It enables accurate Per-Entity Load
+  Tracking for tasks running in the guest by querying host CPU frequency
+  unless a virtualized FIE exists(Like AMUs).
+
+properties:
+  compatible:
+    const: virtual,kvm-cpufreq
+
+required:
+  - compatible
+
+additionalProperties: false
+
+examples:
+  - |
+    {
+      #address-cells = <2>;
+      #size-cells = <2>;
+
+      cpufreq {
+            compatible = "virtual,kvm-cpufreq";
+      };
+
+    };