Re: [PATCH 04/11] PM: EM: Add the infrastructure for command processing.

From: Lukas Wunner
Date: Mon Jun 02 2025 - 16:00:16 EST


On Thu, May 29, 2025 at 09:13:08AM +0900, Changwoo Min wrote:
> +static int em_genl_cmd_doit(struct sk_buff *skb, struct genl_info *info)
> +{
> + struct param p = { .attrs = info->attrs };
> + struct sk_buff *msg;
> + void *hdr;
> + int cmd = info->genlhdr->cmd;
> + int ret = -EMSGSIZE;
> +
> + msg = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
> + if (!msg)
> + return -ENOMEM;

Just a heads-up, I know everyone recommends NLMSG_GOODSIZE but in reality
it's not that great because netlink_trim() reallocates the skb and copies
the entire linear buffer if it determines that the skb is half-empty.
Performance suffers as a result. So it's actually better to calculate
the exact message length prior to allocation. See the SPDM commit
referenced in my previous e-mail. Another lesson I had to learn the
hard way. :(

Thanks,

Lukas