All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Changwoo Min <changwoo@igalia.com>
Cc: lukasz.luba@arm.com, rafael@kernel.org, len.brown@intel.com,
	pavel@kernel.org, christian.loehle@arm.com, tj@kernel.org,
	kernel-dev@igalia.com, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 02/11] PM: EM: Add a skeleton code for netlink notification.
Date: Mon, 2 Jun 2025 21:53:30 +0200	[thread overview]
Message-ID: <aD4BOga3GvPewnqI@wunner.de> (raw)
In-Reply-To: <20250529001315.233492-3-changwoo@igalia.com>

> diff --git a/include/uapi/linux/energy_model.h b/include/uapi/linux/energy_model.h
> new file mode 100644
> index 000000000000..42a19e614c7d
> --- /dev/null
> +++ b/include/uapi/linux/energy_model.h
> @@ -0,0 +1,40 @@
> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> +#ifndef _UAPI_LINUX_ENERGY_MODEL_H
> +#define _UAPI_LINUX_ENERGY_MODEL_H
> +

It looks like you created the header file manually.  There is tooling
to auto-generate all the boilerplate code from a YAML description in
Documentation/netlink/specs/ and my (limited) understanding is that
using it is mandatory for all newly introduced Netlink protocols.

I just had to wrap my head around all that for SPDM (a device
authentication protocol), see the top-most commit on this branch,
which is in a WIP state though:

https://github.com/l1k/linux/commits/doe

Basically you create the uapi and kernel header files plus kernel source
like this:

tools/net/ynl/pyynl/ynl_gen_c.py --spec Documentation/netlink/specs/em.yaml \
  --mode uapi --header
tools/net/ynl/pyynl/ynl_gen_c.py --spec Documentation/netlink/specs/em.yaml \
  --mode kernel --header
tools/net/ynl/pyynl/ynl_gen_c.py --spec Documentation/netlink/specs/em.yaml \
  --mode kernel --source

And then you add both the YAML file as well as the generated files to
the commit.  The reason you have to do that is because Python is
optional for building the kernel per Documentation/process/changes.rst,
so the files cannot be generated at compile time.  It is possible though
to regenerate them with tools/net/ynl/ynl-regen.sh whenever the YAML file
is changed.

The tooling is somewhat brittle, see 396786af1cea.  In theory ynl_gen_c.py
is capable of auto-generating code for user space applications as well
but it crashed when parsing my YAML file.  So there are more bugs,
just haven't had the time yet to fix them.


> +int __init em_netlink_init(void)
> +{
> +	return genl_register_family(&em_genl_family);
> +}
> +
> +void __init em_netlink_exit(void)
> +{
> +	genl_unregister_family(&em_genl_family);
> +}
> +

It looks like em_netlink_exit() isn't invoked anywhere, so why define
it in the first place?  You only need this if the feature can be modular
(which it cannot - it's gated by a bool Kconfig option).  Then you'd
call em_netlink_exit() in module_exit().

Also, you may want to consider moving this to patch [03/11], where
em_netlink_init() is actually invoked.  And you may want to move the
postcore_initcall() to this file so that you can declare em_netlink_init()
static, don't need em_init() and don't need the empty inline stubs.

Thanks,

Lukas

  reply	other threads:[~2025-06-02 19:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-29  0:13 [PATCH 00/11] PM: EM: Add netlink support for the energy model Changwoo Min
2025-05-29  0:13 ` [PATCH 01/11] PM: EM: Add ENERGY_MODEL_NETLINK Kconfig Changwoo Min
2025-05-29  0:13 ` [PATCH 02/11] PM: EM: Add a skeleton code for netlink notification Changwoo Min
2025-06-02 19:53   ` Lukas Wunner [this message]
2025-06-03  6:01     ` Changwoo Min
2025-05-29  0:13 ` [PATCH 03/11] PM: EM: Initialize the netlink notification during booting Changwoo Min
2025-05-29  0:13 ` [PATCH 04/11] PM: EM: Add the infrastructure for command processing Changwoo Min
2025-06-02 19:59   ` Lukas Wunner
2025-06-04 16:11     ` Changwoo Min
2025-05-29  0:13 ` [PATCH 05/11] PM: EM: Assign a unique ID when creating a performance domain Changwoo Min
2025-05-29  0:13 ` [PATCH 06/11] PM: EM: Expose the ID of a performance domain via debugfs Changwoo Min
2025-05-29  0:13 ` [PATCH 07/11] PM: EM: Add an iterator and accessor for the performance domain Changwoo Min
2025-05-29  0:13 ` [PATCH 08/11] PM: EM: Implement EM_GENL_CMD_PD_GET_ID Changwoo Min
2025-05-29  0:13 ` [PATCH 09/11] PM: EM: Implement EM_GENL_CMD_PD_GET_TBL Changwoo Min
2025-05-29  0:13 ` [PATCH 10/11] PM: EM: Implement event notification Changwoo Min
2025-05-29  0:13 ` [PATCH 11/11] PM: EM: Notify an event when the performance domain changes Changwoo Min
2025-06-02 11:52 ` [PATCH 00/11] PM: EM: Add netlink support for the energy model 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=aD4BOga3GvPewnqI@wunner.de \
    --to=lukas@wunner.de \
    --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=lukasz.luba@arm.com \
    --cc=pavel@kernel.org \
    --cc=rafael@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.