From: Caleb Sander <csander@purestorage.com>
To: netdev@vger.kernel.org
Cc: Ariel Elior <aelior@marvell.com>,
GR-everest-linux-l2@marvell.com,
Caleb Sander <csander@purestorage.com>,
Joern Engel <joern@purestorage.com>
Subject: [PATCH] qed: avoid spin loops in _qed_mcp_cmd_and_union()
Date: Wed, 27 Oct 2021 15:45:19 -0600 [thread overview]
Message-ID: <20211027214519.606096-1-csander@purestorage.com> (raw)
By default, qed_mcp_cmd_and_union() sets max_retries to 500K and
usecs to 10, so these loops can together delay up to 5s.
We observed thread scheduling delays of over 700ms in production,
with stacktraces pointing to this code as the culprit.
Add calls to cond_resched() in both loops to yield the CPU if necessary.
Signed-off-by: Caleb Sander <csander@purestorage.com>
Reviewed-by: Joern Engel <joern@purestorage.com>
---
drivers/net/ethernet/qlogic/qed/qed_mcp.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
index 24cd41567..d6944f020 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
@@ -485,10 +485,12 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock);
- if (QED_MB_FLAGS_IS_SET(p_mb_params, CAN_SLEEP))
+ if (QED_MB_FLAGS_IS_SET(p_mb_params, CAN_SLEEP)) {
msleep(msecs);
- else
+ } else {
+ cond_resched();
udelay(usecs);
+ }
} while (++cnt < max_retries);
if (cnt >= max_retries) {
@@ -517,10 +519,12 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
* The spinlock stays locked until the list element is removed.
*/
- if (QED_MB_FLAGS_IS_SET(p_mb_params, CAN_SLEEP))
+ if (QED_MB_FLAGS_IS_SET(p_mb_params, CAN_SLEEP)) {
msleep(msecs);
- else
+ } else {
+ cond_resched();
udelay(usecs);
+ }
spin_lock_bh(&p_hwfn->mcp_info->cmd_lock);
--
2.25.1
next reply other threads:[~2021-10-27 21:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-27 21:45 Caleb Sander [this message]
2021-10-27 22:25 ` [PATCH] qed: avoid spin loops in _qed_mcp_cmd_and_union() Eric Dumazet
2021-10-28 0:20 ` Caleb Sander
2021-10-28 5:47 ` [EXT] " Ariel Elior
2021-10-28 14:59 ` Jörn Engel
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=20211027214519.606096-1-csander@purestorage.com \
--to=csander@purestorage.com \
--cc=GR-everest-linux-l2@marvell.com \
--cc=aelior@marvell.com \
--cc=joern@purestorage.com \
--cc=netdev@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