From: Eric Dumazet <eric.dumazet@gmail.com>
To: Caleb Sander <csander@purestorage.com>, netdev@vger.kernel.org
Cc: Ariel Elior <aelior@marvell.com>,
GR-everest-linux-l2@marvell.com,
Joern Engel <joern@purestorage.com>
Subject: Re: [PATCH] qed: avoid spin loops in _qed_mcp_cmd_and_union()
Date: Wed, 27 Oct 2021 15:25:14 -0700 [thread overview]
Message-ID: <d9d4b6d1-d64d-4bfb-17d9-b28153e02b9e@gmail.com> (raw)
In-Reply-To: <20211027214519.606096-1-csander@purestorage.com>
On 10/27/21 2:45 PM, Caleb Sander wrote:
> 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)) {
I do not know this driver, but apparently, there is this CAN_SLEEP test
hinting about being able to sleep.
> msleep(msecs);
> - else
> + } else {
> + cond_resched();
Here you might sleep/schedule, while CAN_SLEEP was not set ?
> udelay(usecs);
I would suggest using usleep_range() instead, because cond_resched()
can be a NOP under some circumstances.
> + }
> } while (++cnt < max_retries);
Then perhaps not count against max_retries, but based on total elapsed time ?
>
> 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);
>
>
next prev parent reply other threads:[~2021-10-27 22:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-27 21:45 [PATCH] qed: avoid spin loops in _qed_mcp_cmd_and_union() Caleb Sander
2021-10-27 22:25 ` Eric Dumazet [this message]
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=d9d4b6d1-d64d-4bfb-17d9-b28153e02b9e@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=GR-everest-linux-l2@marvell.com \
--cc=aelior@marvell.com \
--cc=csander@purestorage.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.