From: Slava Ovsiienko <viacheslavo@nvidia.com>
To: Sivaprasad Tummala <sivaprasad.tummala@amd.com>,
Dariusz Sosnowski <dsosnowski@nvidia.com>,
Bing Zhao <bingz@nvidia.com>, Ori Kam <orika@nvidia.com>,
Suanming Mou <suanmingm@nvidia.com>,
Matan Azrad <matan@nvidia.com>,
Alexander Kozyrev <akozyrev@nvidia.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, "stable@dpdk.org" <stable@dpdk.org>
Subject: RE: [PATCH v2] net/mlx5: fix spurious CPU wakeups caused by invalid CQE
Date: Fri, 14 Nov 2025 13:04:33 +0000 [thread overview]
Message-ID: <MN6PR12MB856718271C670BAB59DDD477DFCAA@MN6PR12MB8567.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20251111034057.3177641-1-sivaprasad.tummala@amd.com>
> -----Original Message-----
> From: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
> Sent: Tuesday, November 11, 2025 5:41 AM
> To: Dariusz Sosnowski <dsosnowski@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Bing Zhao <bingz@nvidia.com>; Ori Kam
> <orika@nvidia.com>; Suanming Mou <suanmingm@nvidia.com>; Matan Azrad
> <matan@nvidia.com>; Alexander Kozyrev <akozyrev@nvidia.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: [PATCH v2] net/mlx5: fix spurious CPU wakeups caused by invalid CQE
>
> Previously, the PMD used a common monitor callback to determine CQE
> ownership for power-aware polling. However, when a CQE contained an invalid
> opcode(MLX5_CQE_INVALID), ownership bit was not reliable.
> As a result, the monitor condition could falsely indicate CQE availability and
> cause the CPU to wake up unnecessarily during low traffic periods.
>
> This resulted in spurious wakeups in monitor-wait mode and reduced the
> expected power savings, as cores exited the sleep state even when no valid CQEs
> were available.
>
> This patch introduces a dedicated callback that skips invalid CQEs and optimizes
> power efficiency by preventing false wakeups caused by hardware-owned or
> invalid entries.
>
> Fixes: a8f0df6bf98d ("net/mlx5: support power monitoring")
> Cc: akozyrev@nvidia.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
>
> v2:
> - Updated CQE opcode check logic — replaced XOR with comparison
> - Renamed variable match to sw_owned for clarity
> - Updated CQE ownership check order
> ---
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> drivers/net/mlx5/mlx5_rx.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/mlx5/mlx5_rx.c b/drivers/net/mlx5/mlx5_rx.c index
> 420a03068d..ac663a978e 100644
> --- a/drivers/net/mlx5/mlx5_rx.c
> +++ b/drivers/net/mlx5/mlx5_rx.c
> @@ -295,6 +295,20 @@ mlx5_monitor_callback(const uint64_t value,
> return (value & m) == v ? -1 : 0;
> }
>
> +static int
> +mlx5_monitor_cqe_own_callback(const uint64_t value,
> + const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ])
> +{
> + const uint64_t m = opaque[CLB_MSK_IDX];
> + const uint64_t v = opaque[CLB_VAL_IDX];
> + const uint64_t sw_owned = ((value & m) == v);
> + const uint64_t opcode = MLX5_CQE_OPCODE(value);
> + const uint64_t valid_op = (opcode != MLX5_CQE_INVALID);
> +
> + /* ownership bit is not valid for invalid opcode; CQE is HW owned */
> + return -(valid_op & sw_owned);
> +}
> +
> int mlx5_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond
> *pmc) {
> struct mlx5_rxq_data *rxq = rx_queue;
> @@ -312,12 +326,13 @@ int mlx5_get_monitor_addr(void *rx_queue, struct
> rte_power_monitor_cond *pmc)
> pmc->addr = &cqe->validity_iteration_count;
> pmc->opaque[CLB_VAL_IDX] = vic;
> pmc->opaque[CLB_MSK_IDX] = MLX5_CQE_VIC_INIT;
> + pmc->fn = mlx5_monitor_callback;
> } else {
> pmc->addr = &cqe->op_own;
> pmc->opaque[CLB_VAL_IDX] = !!idx;
> pmc->opaque[CLB_MSK_IDX] = MLX5_CQE_OWNER_MASK;
> + pmc->fn = mlx5_monitor_cqe_own_callback;
> }
> - pmc->fn = mlx5_monitor_callback;
> pmc->size = sizeof(uint8_t);
> return 0;
> }
> --
> 2.43.0
next prev parent reply other threads:[~2025-11-14 13:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 13:39 [PATCH] " Sivaprasad Tummala
2025-10-28 14:53 ` Thomas Monjalon
2025-11-07 17:59 ` Dariusz Sosnowski
2025-11-10 9:29 ` Tummala, Sivaprasad
2025-11-11 3:40 ` [PATCH v2] " Sivaprasad Tummala
2025-11-14 13:04 ` Slava Ovsiienko [this message]
2025-11-14 13:07 ` Dariusz Sosnowski
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=MN6PR12MB856718271C670BAB59DDD477DFCAA@MN6PR12MB8567.namprd12.prod.outlook.com \
--to=viacheslavo@nvidia.com \
--cc=akozyrev@nvidia.com \
--cc=bingz@nvidia.com \
--cc=dev@dpdk.org \
--cc=dsosnowski@nvidia.com \
--cc=matan@nvidia.com \
--cc=orika@nvidia.com \
--cc=sivaprasad.tummala@amd.com \
--cc=stable@dpdk.org \
--cc=suanmingm@nvidia.com \
/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;
as well as URLs for NNTP newsgroup(s).