From: Lukasz Luba <lukasz.luba@arm.com>
To: Shubhang Kaushik <sh@gentwo.org>,
Shubhang Kaushik <shubhangpk@gmail.com>
Cc: Christoph Lameter <cl@gentwo.org>,
Changwoo Min <changwoo@igalia.com>,
Donald Hunter <donald.hunter@gmail.com>,
Pavel Machek <pavel@kernel.org>, Len Brown <lenb@kernel.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
linux-pm@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] PM: EM: Fix netlink performance-domain dump pagination
Date: Fri, 27 Nov 2026 09:32:38 +0000 [thread overview]
Message-ID: <8908fb90-ebf0-4652-b44b-657bcf796f80@arm.com> (raw)
In-Reply-To: <20261125-pm-em-dump-v2-1-a28e132f8b0c@gentwo.org>
On 11/25/26 18:10, Shubhang Kaushik wrote:
> GET_PERF_DOMAINS dumps performance domains through:
>
> netlink_dump()
> -> dev_energymodel_nl_get_perf_domains_dumpit()
> -> for_each_em_perf_domain()
> -> __em_nl_get_pd_for_dump()
>
> The dump handler rebuilds its local cursor from cb->args[0] on each
> callback. When the response skb fills, it returns -EMSGSIZE and the
> netlink core sends the nonempty skb before retrying the dump. However,
> the updated cursor is not saved in cb->args[0], so the retry restarts at
> domain zero.
>
> For example, if domains 0 and 1 fit in the first skb but domain 2 does
> not, every subsequent callback emits domains 0 and 1 again and never
> progresses beyond domain 2. The handler also advances the cursor before
> encoding the domain and finalizes its partially encoded message on
> failure.
>
> Advance the cursor only after a domain has been encoded successfully,
> cancel incomplete messages, and store the next domain index in
> cb->args[0]. Return skb->len whenever data was written so netlink_dump()
> sends the current chunk and continues the dump, propagating errors only
> when skb->len is zero.
>
> Fixes: 380ff27af25e ("PM: EM: Add dump to get-perf-domains in the EM YNL spec")
> Cc: stable@vger.kernel.org
> Signed-off-by: Shubhang Kaushik <sh@gentwo.org>
> ---
> Changes in v2:
> - Return skb->len whenever data has been written to the skb, propagating
> negative error codes only when skb->len == 0.
>
> Testing:
> - Validated dev-energymodel YNL spec and exercised GET_PERF_DOMAINS
> dumps via tools/net/ynl/pyynl/cli.py on an 80-core Ampere Altra,
> including registering 4 test performance domains and forcing
> per-domain -EMSGSIZE splits across multiple netlink_dump() chunks.
>
> Link to v1: https://lore.kernel.org/r/20261124-pm-em-dump-v1-1-8f9167d437bc@gentwo.org
> ---
> kernel/power/em_netlink.c | 26 ++++++++++++++++++++------
> 1 file changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/power/em_netlink.c b/kernel/power/em_netlink.c
> index 1f68d456a713c08d7a4f690e88c03182f6ee3ef1..4e85439ed76d240e013cf372dcbc77b3af28d598 100644
> --- a/kernel/power/em_netlink.c
> +++ b/kernel/power/em_netlink.c
> @@ -80,19 +80,25 @@ static int __em_nl_get_pd_for_dump(struct em_perf_domain *pd, void *data)
> void *hdr;
> int ret;
>
> - if (ctx->idx++ < ctx->start)
> + if (ctx->idx < ctx->start) {
> + ctx->idx++;
> return 0;
> + }
>
> info = genl_info_dump(ctx->cb);
> hdr = genlmsg_iput(ctx->skb, info);
> - if (!hdr) {
> - genlmsg_cancel(ctx->skb, hdr);
> + if (!hdr)
> return -EMSGSIZE;
> - }
>
> ret = __em_nl_get_pd(pd, ctx->skb);
> + if (ret) {
> + genlmsg_cancel(ctx->skb, hdr);
> + return ret;
> + }
> +
> genlmsg_end(ctx->skb, hdr);
> - return ret;
> + ctx->idx++;
> + return 0;
> }
>
> struct em_nl_doit_ctx {
> @@ -166,7 +172,15 @@ int dev_energymodel_nl_get_perf_domains_dumpit(struct sk_buff *skb,
> .cb = cb,
> };
>
> - return for_each_em_perf_domain(__em_nl_get_pd_for_dump, &ctx);
> + int ret;
> +
> + ret = for_each_em_perf_domain(__em_nl_get_pd_for_dump, &ctx);
> + cb->args[0] = ctx.idx;
> +
> + if (ret && !skb->len)
> + return ret;
> +
> + return skb->len;
> }
>
> static int __em_nl_get_pd_table_size(const struct em_perf_domain *pd)
>
> ---
> base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5
> change-id: 20261124-pm-em-dump-00f32b88fd6c
>
> Best regards,
That looks good, it should fix the skipping entry issues.
Thanks for the fix.
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
prev parent reply other threads:[~2026-11-27 9:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 18:10 [PATCH v2] PM: EM: Fix netlink performance-domain dump pagination Shubhang Kaushik
2026-11-27 9:32 ` Lukasz Luba [this message]
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=8908fb90-ebf0-4652-b44b-657bcf796f80@arm.com \
--to=lukasz.luba@arm.com \
--cc=changwoo@igalia.com \
--cc=cl@gentwo.org \
--cc=donald.hunter@gmail.com \
--cc=lenb@kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@kernel.org \
--cc=sh@gentwo.org \
--cc=shubhangpk@gmail.com \
--cc=stable@vger.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