On 9/25/26 12:16 PM, Timothy Redaelli via dev wrote:
> When --format json is passed to ovs-appctl, pmd-sleep-show returns a
> JSON object with "default-max-sleep-us" and a "threads" object. Each
> thread is keyed by a stable identifier ("pmd-cNN" derived from the core
> ID) and contains "core", "max-sleep-us", and "numa" fields.
>
> The "pmd-cNN" key format is chosen over the full thread name
> ("pmd-cNN/id:XXX") because the thread ID suffix is dynamic and would
> make the key unstable across restarts.
>
> The implementation is split into separate text and JSON helper functions.
>
> Example output:
> {"default-max-sleep-us": 100,
> "threads": {"pmd-c03": {"core": 3, "max-sleep-us": 100,
> "numa": 1}}}
>
> Signed-off-by: Timothy Redaelli <[email protected]>
> ---
> NEWS | 2 ++
> lib/dpif-netdev.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
> tests/pmd.at | 19 ++++++++++++++++++
> 3 files changed, 71 insertions(+)
>
> diff --git a/NEWS b/NEWS
> index b4c67dbc8..3c8ec26e8 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -3,6 +3,8 @@ Post-v4.0.0
> - ovs-appctl:
> * Added JSON output support (--format json) for 'fdb/stats-show'.
> * Added JSON output support (--format json) for 'upcall/show'.
> + * Added JSON output support (--format json) for
> + 'dpif-netdev/pmd-sleep-show'.
Same comment as in 2/6.
>
>
> v4.0.0 - 17 Aug 2026
> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index 4151ea056..65d3abf69 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -65,6 +65,7 @@
> #include "odp-execute.h"
> #include "odp-util.h"
> #include "openvswitch/dynamic-string.h"
> +#include "openvswitch/json.h"
> #include "openvswitch/list.h"
> #include "openvswitch/match.h"
> #include "openvswitch/ofp-parse.h"
> @@ -880,6 +881,43 @@ dpif_netdev_pmd_rebalance(struct unixctl_conn *conn, int
> argc,
> ds_destroy(&reply);
> }
>
> +static struct json *
> +pmd_info_sleep_show_json(struct dp_netdev *dp,
> + struct dp_netdev_pmd_thread **pmd_list, size_t n)
> +{
> + struct json *json_threads = json_object_create();
> + struct json *json_result = json_object_create();
> +
> + json_object_put(json_result, "default-max-sleep-us",
> + json_integer_create(dp->pmd_max_sleep_default));
> +
> + for (size_t i = 0; i < n; i++) {
> + struct dp_netdev_pmd_thread *pmd = pmd_list[i];
> + struct json *json_pmd;
> + uint64_t max_sleep;
> + char *key;
> +
> + if (!pmd || pmd->core_id == NON_PMD_CORE_ID) {
> + continue;
> + }
> +
> + json_pmd = json_object_create();
> + key = xasprintf("pmd-c%02u", pmd->core_id);
> +
> + atomic_read_relaxed(&pmd->max_sleep, &max_sleep);
> + json_object_put(json_pmd, "core",
> + json_integer_create(pmd->core_id));
> + json_object_put(json_pmd, "max-sleep-us",
> + json_integer_create(max_sleep));
> + json_object_put(json_pmd, "numa",
> + json_integer_create(pmd->numa_id));
nit: Are these in alphabetical order? I'd suggest we move the numa
one line up to the core, as they are related. And both the core and
the numa can be single lines without being a visual clutter this way.
Best regards, Ilya Maximets.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev