* [PATCH net] pds_core: yield the CPU while waiting for the adminq to drain
@ 2026-07-14 20:14 Nikhil P. Rao
2026-07-15 13:14 ` Pavan Chebbi
2026-07-21 19:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Nikhil P. Rao @ 2026-07-14 20:14 UTC (permalink / raw)
To: netdev
Cc: kuba, brett.creeley, eric.joyner, andrew+netdev, davem, edumazet,
pabeni, Nikhil P. Rao
pdsc_adminq_wait_and_dec_once_unused() busy-waits for adminq_refcnt to
drop to one:
while (!refcount_dec_if_one(&pdsc->adminq_refcnt))
cpu_relax();
The refcount is held by pdsc_adminq_post() for the duration of an
in-flight command, which can wait up to devcmd_timeout seconds
(PDS_CORE_DEVCMD_TIMEOUT is 5) for the hardware to complete. cpu_relax()
is not a reschedule point, so on a non-preemptible kernel this loop can
spin on the CPU for several seconds, starving other tasks on that core.
Add cond_resched() to the loop so the waiter yields to other runnable
tasks while it polls, keeping cpu_relax() as the busy-wait hint between
checks.
Fixes: 7e82a8745b95 ("pds_core: Prevent race issues involving the adminq")
Reported-by: sashiko-bot <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260629200358.2626129-1-nikhil.rao%40amd.com?part=2
Signed-off-by: Nikhil P. Rao <nikhil.rao@amd.com>
Reviewed-by: Eric Joyner <eric.joyner@amd.com>
---
drivers/net/ethernet/amd/pds_core/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c
index 38a2446571af..19eeb5b06f4d 100644
--- a/drivers/net/ethernet/amd/pds_core/core.c
+++ b/drivers/net/ethernet/amd/pds_core/core.c
@@ -533,6 +533,7 @@ static void pdsc_adminq_wait_and_dec_once_unused(struct pdsc *pdsc)
dev_dbg_ratelimited(pdsc->dev, "%s: adminq in use\n",
__func__);
cpu_relax();
+ cond_resched();
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] pds_core: yield the CPU while waiting for the adminq to drain
2026-07-14 20:14 [PATCH net] pds_core: yield the CPU while waiting for the adminq to drain Nikhil P. Rao
@ 2026-07-15 13:14 ` Pavan Chebbi
2026-07-21 19:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Pavan Chebbi @ 2026-07-15 13:14 UTC (permalink / raw)
To: Nikhil P. Rao
Cc: netdev, kuba, brett.creeley, eric.joyner, andrew+netdev, davem,
edumazet, pabeni
[-- Attachment #1: Type: text/plain, Size: 1276 bytes --]
On Wed, Jul 15, 2026 at 1:46 AM Nikhil P. Rao <nikhil.rao@amd.com> wrote:
>
> pdsc_adminq_wait_and_dec_once_unused() busy-waits for adminq_refcnt to
> drop to one:
>
> while (!refcount_dec_if_one(&pdsc->adminq_refcnt))
> cpu_relax();
>
> The refcount is held by pdsc_adminq_post() for the duration of an
> in-flight command, which can wait up to devcmd_timeout seconds
> (PDS_CORE_DEVCMD_TIMEOUT is 5) for the hardware to complete. cpu_relax()
> is not a reschedule point, so on a non-preemptible kernel this loop can
> spin on the CPU for several seconds, starving other tasks on that core.
>
> Add cond_resched() to the loop so the waiter yields to other runnable
> tasks while it polls, keeping cpu_relax() as the busy-wait hint between
> checks.
>
> Fixes: 7e82a8745b95 ("pds_core: Prevent race issues involving the adminq")
> Reported-by: sashiko-bot <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/patchset/20260629200358.2626129-1-nikhil.rao%40amd.com?part=2
> Signed-off-by: Nikhil P. Rao <nikhil.rao@amd.com>
> Reviewed-by: Eric Joyner <eric.joyner@amd.com>
> ---
> drivers/net/ethernet/amd/pds_core/core.c | 1 +
> 1 file changed, 1 insertion(+)
>
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5469 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] pds_core: yield the CPU while waiting for the adminq to drain
2026-07-14 20:14 [PATCH net] pds_core: yield the CPU while waiting for the adminq to drain Nikhil P. Rao
2026-07-15 13:14 ` Pavan Chebbi
@ 2026-07-21 19:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-07-21 19:50 UTC (permalink / raw)
To: Nikhil P. Rao
Cc: netdev, kuba, brett.creeley, eric.joyner, andrew+netdev, davem,
edumazet, pabeni
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 14 Jul 2026 20:14:56 +0000 you wrote:
> pdsc_adminq_wait_and_dec_once_unused() busy-waits for adminq_refcnt to
> drop to one:
>
> while (!refcount_dec_if_one(&pdsc->adminq_refcnt))
> cpu_relax();
>
> The refcount is held by pdsc_adminq_post() for the duration of an
> in-flight command, which can wait up to devcmd_timeout seconds
> (PDS_CORE_DEVCMD_TIMEOUT is 5) for the hardware to complete. cpu_relax()
> is not a reschedule point, so on a non-preemptible kernel this loop can
> spin on the CPU for several seconds, starving other tasks on that core.
>
> [...]
Here is the summary with links:
- [net] pds_core: yield the CPU while waiting for the adminq to drain
https://git.kernel.org/netdev/net/c/a11f0b8a2042
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-21 19:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-14 20:14 [PATCH net] pds_core: yield the CPU while waiting for the adminq to drain Nikhil P. Rao
2026-07-15 13:14 ` Pavan Chebbi
2026-07-21 19:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox