[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aD4CrOmIwhUI-pet@wunner.de>
Date: Mon, 2 Jun 2025 21:59:40 +0200
From: Lukas Wunner <lukas@...ner.de>
To: Changwoo Min <changwoo@...lia.com>
Cc: lukasz.luba@....com, rafael@...nel.org, len.brown@...el.com,
pavel@...nel.org, christian.loehle@....com, tj@...nel.org,
kernel-dev@...lia.com, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 04/11] PM: EM: Add the infrastructure for command
processing.
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
Powered by blists - more mailing lists