public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Luba <lukasz.luba@arm.com>
To: Changwoo Min <changwoo@igalia.com>
Cc: christian.loehle@arm.com, tj@kernel.org, pavel@kernel.org,
	len.brown@intel.com, rafael@kernel.org, kernel-dev@igalia.com,
	linux-pm@vger.kernel.org, sched-ext@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND v4 04/10] PM: EM: Add em.yaml and autogen files
Date: Mon, 6 Oct 2025 16:25:05 +0100	[thread overview]
Message-ID: <d715c2be-c309-4fc6-b072-094095539cc1@arm.com> (raw)
In-Reply-To: <20250921031928.205869-5-changwoo@igalia.com>



On 9/21/25 04:19, Changwoo Min wrote:
> Add a generic netlink spec in YAML format and autogenerate boilerplate
> code using ynl-regen.sh to introduce a generic netlink for the energy
> model. It allows a userspace program to read the performance domain and
> its energy model. It notifies the userspace program when a performance
> domain is created or deleted or its energy model is updated through a
> multicast interface.
> 
> Specifically, it supports two commands:
>    - EM_CMD_GET_PDS: Get the list of information for all performance
>      domains.
>    - EM_CMD_GET_PD_TABLE: Get the energy model table of a performance
>      domain.
> 
> Also, it supports three notification events:
>    - EM_CMD_PD_CREATED: When a performance domain is created.
>    - EM_CMD_PD_DELETED: When a performance domain is deleted.
>    - EM_CMD_PD_UPDATED: When the energy model table of a performance domain
>      is updated.
> 
> Finally, update MAINTAINERS to include new files.
> 
> Signed-off-by: Changwoo Min <changwoo@igalia.com>
> ---
>   Documentation/netlink/specs/em.yaml | 113 ++++++++++++++++++++++++++++
>   MAINTAINERS                         |   3 +
>   include/uapi/linux/energy_model.h   |  62 +++++++++++++++
>   kernel/power/em_netlink_autogen.c   |  48 ++++++++++++
>   kernel/power/em_netlink_autogen.h   |  23 ++++++
>   5 files changed, 249 insertions(+)
>   create mode 100644 Documentation/netlink/specs/em.yaml
>   create mode 100644 include/uapi/linux/energy_model.h
>   create mode 100644 kernel/power/em_netlink_autogen.c
>   create mode 100644 kernel/power/em_netlink_autogen.h
> 
> diff --git a/Documentation/netlink/specs/em.yaml b/Documentation/netlink/specs/em.yaml
> new file mode 100644
> index 000000000000..9905ca482325
> --- /dev/null
> +++ b/Documentation/netlink/specs/em.yaml
> @@ -0,0 +1,113 @@
> +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
> +
> +name: em
> +
> +doc: |
> +  Energy model netlink interface to notify its changes.
> +
> +protocol: genetlink
> +
> +uapi-header: linux/energy_model.h
> +
> +attribute-sets:
> +  -
> +    name: pds
> +    attributes:
> +      -
> +        name: pd
> +        type: nest
> +        nested-attributes: pd
> +        multi-attr: true
> +  -
> +    name: pd
> +    attributes:
> +      -
> +        name: pad
> +        type: pad
> +      -
> +        name: pd-id
> +        type: u32
> +      -
> +        name: flags
> +        type: u64
> +      -
> +        name: cpus
> +        type: string
> +  -
> +    name: pd-table
> +    attributes:
> +      -
> +        name: pd-id
> +        type: u32
> +      -
> +        name: ps
> +        type: nest
> +        nested-attributes: ps
> +        multi-attr: true
> +  -
> +    name: ps
> +    attributes:
> +      -
> +        name: pad
> +        type: pad
> +      -
> +        name: performance
> +        type: u64
> +      -
> +        name: frequency
> +        type: u64
> +      -
> +        name: power
> +        type: u64
> +      -
> +        name: cost
> +        type: u64
> +      -
> +        name: flags
> +        type: u64
> +
> +operations:
> +  list:
> +    -
> +      name: get-pds
> +      attribute-set: pds
> +      doc: Get the list of information for all performance domains.
> +      do:
> +        reply:
> +          attributes:
> +            - pd
> +    -
> +      name: get-pd-table
> +      attribute-set: pd-table
> +      doc: Get the energy model table of a performance domain.
> +      do:
> +        request:
> +          attributes:
> +            - pd-id
> +        reply:
> +          attributes:
> +            - pd-id
> +            - ps
> +    -
> +      name: pd-created
> +      doc: A performance domain is created.
> +      notify: get-pd-table
> +      mcgrp: event
> +    -
> +      name: pd-updated
> +      doc: A performance domain is updated.
> +      notify: get-pd-table
> +      mcgrp: event
> +    -
> +      name: pd-deleted
> +      doc: A performance domain is deleted.
> +      attribute-set: pd-table
> +      event:
> +        attributes:
> +            - pd-id
> +      mcgrp: event
> +
> +mcast-groups:
> +  list:
> +    -
> +      name: event
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 520fb4e379a3..0992029d271d 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -9032,6 +9032,9 @@ S:	Maintained
>   F:	kernel/power/energy_model.c
>   F:	include/linux/energy_model.h
>   F:	Documentation/power/energy-model.rst
> +F:	Documentation/netlink/specs/em.yaml
> +F:	include/uapi/linux/energy_model.h
> +F:	kernel/power/em_netlink_autogen.*
>   
>   EPAPR HYPERVISOR BYTE CHANNEL DEVICE DRIVER
>   M:	Laurentiu Tudor <laurentiu.tudor@nxp.com>
> diff --git a/include/uapi/linux/energy_model.h b/include/uapi/linux/energy_model.h
> new file mode 100644
> index 000000000000..4ec4c0eabbbb
> --- /dev/null
> +++ b/include/uapi/linux/energy_model.h
> @@ -0,0 +1,62 @@
> +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
> +/* Do not edit directly, auto-generated from: */
> +/*	Documentation/netlink/specs/em.yaml */
> +/* YNL-GEN uapi header */
> +
> +#ifndef _UAPI_LINUX_ENERGY_MODEL_H
> +#define _UAPI_LINUX_ENERGY_MODEL_H
> +
> +#define EM_FAMILY_NAME		"em"
> +#define EM_FAMILY_VERSION	1
> +
> +enum {
> +	EM_A_PDS_PD = 1,
> +
> +	__EM_A_PDS_MAX,
> +	EM_A_PDS_MAX = (__EM_A_PDS_MAX - 1)
> +};
> +
> +enum {
> +	EM_A_PD_PAD = 1,
> +	EM_A_PD_PD_ID,
> +	EM_A_PD_FLAGS,
> +	EM_A_PD_CPUS,
> +
> +	__EM_A_PD_MAX,
> +	EM_A_PD_MAX = (__EM_A_PD_MAX - 1)
> +};
> +
> +enum {
> +	EM_A_PD_TABLE_PD_ID = 1,
> +	EM_A_PD_TABLE_PS,
> +
> +	__EM_A_PD_TABLE_MAX,
> +	EM_A_PD_TABLE_MAX = (__EM_A_PD_TABLE_MAX - 1)
> +};
> +
> +enum {
> +	EM_A_PS_PAD = 1,
> +	EM_A_PS_PERFORMANCE,
> +	EM_A_PS_FREQUENCY,
> +	EM_A_PS_POWER,
> +	EM_A_PS_COST,
> +	EM_A_PS_FLAGS,
> +
> +	__EM_A_PS_MAX,
> +	EM_A_PS_MAX = (__EM_A_PS_MAX - 1)
> +};
> +
> +enum {
> +	EM_CMD_GET_PDS = 1,
> +	EM_CMD_GET_PD_TABLE,
> +	EM_CMD_PD_CREATED,
> +	EM_CMD_PD_UPDATED,
> +	EM_CMD_PD_DELETED,
> +
> +	__EM_CMD_MAX,
> +	EM_CMD_MAX = (__EM_CMD_MAX - 1)
> +};
> +
> +#define EM_MCGRP_EVENT	"event"
> +
> +#endif /* _UAPI_LINUX_ENERGY_MODEL_H */
> diff --git a/kernel/power/em_netlink_autogen.c b/kernel/power/em_netlink_autogen.c
> new file mode 100644
> index 000000000000..a7a09ab1d1c2
> --- /dev/null
> +++ b/kernel/power/em_netlink_autogen.c
> @@ -0,0 +1,48 @@
> +// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
> +/* Do not edit directly, auto-generated from: */
> +/*	Documentation/netlink/specs/em.yaml */
> +/* YNL-GEN kernel source */
> +
> +#include <net/netlink.h>
> +#include <net/genetlink.h>
> +
> +#include "em_netlink_autogen.h"
> +
> +#include <uapi/linux/energy_model.h>
> +
> +/* EM_CMD_GET_PD_TABLE - do */
> +static const struct nla_policy em_get_pd_table_nl_policy[EM_A_PD_TABLE_PD_ID + 1] = {
> +	[EM_A_PD_TABLE_PD_ID] = { .type = NLA_U32, },
> +};
> +
> +/* Ops table for em */
> +static const struct genl_split_ops em_nl_ops[] = {
> +	{
> +		.cmd	= EM_CMD_GET_PDS,
> +		.doit	= em_nl_get_pds_doit,
> +		.flags	= GENL_CMD_CAP_DO,
> +	},
> +	{
> +		.cmd		= EM_CMD_GET_PD_TABLE,
> +		.doit		= em_nl_get_pd_table_doit,
> +		.policy		= em_get_pd_table_nl_policy,
> +		.maxattr	= EM_A_PD_TABLE_PD_ID,
> +		.flags		= GENL_CMD_CAP_DO,
> +	},
> +};
> +
> +static const struct genl_multicast_group em_nl_mcgrps[] = {
> +	[EM_NLGRP_EVENT] = { "event", },
> +};
> +
> +struct genl_family em_nl_family __ro_after_init = {
> +	.name		= EM_FAMILY_NAME,
> +	.version	= EM_FAMILY_VERSION,
> +	.netnsok	= true,
> +	.parallel_ops	= true,
> +	.module		= THIS_MODULE,
> +	.split_ops	= em_nl_ops,
> +	.n_split_ops	= ARRAY_SIZE(em_nl_ops),
> +	.mcgrps		= em_nl_mcgrps,
> +	.n_mcgrps	= ARRAY_SIZE(em_nl_mcgrps),
> +};
> diff --git a/kernel/power/em_netlink_autogen.h b/kernel/power/em_netlink_autogen.h
> new file mode 100644
> index 000000000000..78ce609641f1
> --- /dev/null
> +++ b/kernel/power/em_netlink_autogen.h
> @@ -0,0 +1,23 @@
> +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
> +/* Do not edit directly, auto-generated from: */
> +/*	Documentation/netlink/specs/em.yaml */
> +/* YNL-GEN kernel header */
> +
> +#ifndef _LINUX_EM_GEN_H
> +#define _LINUX_EM_GEN_H
> +
> +#include <net/netlink.h>
> +#include <net/genetlink.h>
> +
> +#include <uapi/linux/energy_model.h>
> +
> +int em_nl_get_pds_doit(struct sk_buff *skb, struct genl_info *info);
> +int em_nl_get_pd_table_doit(struct sk_buff *skb, struct genl_info *info);
> +
> +enum {
> +	EM_NLGRP_EVENT,
> +};
> +
> +extern struct genl_family em_nl_family;
> +
> +#endif /* _LINUX_EM_GEN_H */


LGTM,

Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>

  reply	other threads:[~2025-10-06 15:24 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-21  3:19 [PATCH RESEND v4 00/10] PM: EM: Add netlink support for the energy model Changwoo Min
2025-09-21  3:19 ` [PATCH RESEND v4 01/10] PM: EM: Assign a unique ID when creating a performance domain Changwoo Min
2025-10-06  8:17   ` Lukasz Luba
2025-10-06 12:24     ` Lukasz Luba
2025-10-13 13:46       ` Changwoo Min
2025-09-21  3:19 ` [PATCH RESEND v4 02/10] PM: EM: Expose the ID of a performance domain via debugfs Changwoo Min
2025-10-06 14:26   ` Lukasz Luba
2025-09-21  3:19 ` [PATCH RESEND v4 03/10] PM: EM: Add an iterator and accessor for the performance domain Changwoo Min
2025-10-06 15:14   ` Lukasz Luba
2025-09-21  3:19 ` [PATCH RESEND v4 04/10] PM: EM: Add em.yaml and autogen files Changwoo Min
2025-10-06 15:25   ` Lukasz Luba [this message]
2025-09-21  3:19 ` [PATCH RESEND v4 05/10] PM: EM: Add a skeleton code for netlink notification Changwoo Min
2025-10-06 15:44   ` Lukasz Luba
2025-10-13 13:46     ` Changwoo Min
2025-10-13 13:53       ` Lukasz Luba
2025-10-13 14:43         ` Changwoo Min
2025-09-21  3:19 ` [PATCH RESEND v4 06/10] PM: EM: Implement em_nl_get_pds_doit() Changwoo Min
2025-10-10  9:32   ` Lukasz Luba
2025-09-21  3:19 ` [PATCH RESEND v4 07/10] PM: EM: Implement em_nl_get_pd_table_doit() Changwoo Min
2025-10-10 10:01   ` Lukasz Luba
2025-10-13 13:47     ` Changwoo Min
2025-09-21  3:19 ` [PATCH RESEND v4 08/10] PM: EM: Implement em_notify_pd_deleted() Changwoo Min
2025-10-10 10:17   ` Lukasz Luba
2025-09-21  3:19 ` [PATCH RESEND v4 09/10] PM: EM: Implement em_notify_pd_created/updated() Changwoo Min
2025-10-10 10:19   ` Lukasz Luba
2025-09-21  3:19 ` [PATCH RESEND v4 10/10] PM: EM: Notify an event when the performance domain changes Changwoo Min
2025-10-10 10:20   ` Lukasz Luba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d715c2be-c309-4fc6-b072-094095539cc1@arm.com \
    --to=lukasz.luba@arm.com \
    --cc=changwoo@igalia.com \
    --cc=christian.loehle@arm.com \
    --cc=kernel-dev@igalia.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=rafael@kernel.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox