From: Simon Horman <horms@kernel.org>
To: Rushil Gupta <rushilg@google.com>
Cc: netdev@vger.kernel.org, jeroendb@google.com,
pkaligineedi@google.com, davem@davemloft.net, kuba@kernel.org,
edumazet@google.com, pabeni@redhat.com, willemb@google.com,
hramamurthy@google.com, Shailend Chand <shailend@google.com>,
Ziwei Xiao <ziweixiao@google.com>
Subject: Re: [PATCH] gve: Add retry logic for recoverable adminq errors
Date: Mon, 1 Jul 2024 12:21:39 +0100 [thread overview]
Message-ID: <20240701112139.GX17134@kernel.org> (raw)
In-Reply-To: <20240628185446.262191-1-rushilg@google.com>
On Fri, Jun 28, 2024 at 06:54:46PM +0000, Rushil Gupta wrote:
> From: Jeroen de Borst <jeroendb@google.com>
>
> An adminq command is retried if it fails with an ETIME error code
> which translates to the deadline exceeded error for the device.
> The create and destroy adminq commands are now managed via a common
> method. This method keeps track of return codes for each queue and retries
> the commands for the queues that failed with ETIME.
> Other adminq commands that do not require queue level granularity are
> simply retried in gve_adminq_execute_cmd.
>
> Signed-off-by: Rushil Gupta <rushilg@google.com>
> Signed-off-by: Jeroen de Borst <jeroendb@google.com>
> Reviewed-by: Shailend Chand <shailend@google.com>
> Reviewed-by: Ziwei Xiao <ziweixiao@google.com>
> ---
> drivers/net/ethernet/google/gve/gve_adminq.c | 197 ++++++++++++-------
> drivers/net/ethernet/google/gve/gve_adminq.h | 5 +
> 2 files changed, 129 insertions(+), 73 deletions(-)
>
> diff --git a/drivers/net/ethernet/google/gve/gve_adminq.c b/drivers/net/ethernet/google/gve/gve_adminq.c
Hi Rushil,
Some minor feedback from my side.
...
> +static int gve_adminq_manage_queues(struct gve_priv *priv,
> + gve_adminq_queue_cmd *cmd,
> + u32 start_id, u32 num_queues)
> +{
> + u32 cmd_idx, queue_idx, ret_code_idx;
> + int queue_done = -1;
> + int *queues_waiting;
> + int retry_cnt = 0;
> + int retry_needed;
> + int *ret_codes;
> + int *commands;
> + int err;
> + int ret;
> +
> + queues_waiting = kvcalloc(num_queues, sizeof(int), GFP_KERNEL);
> + if (!queues_waiting)
> + return -ENOMEM;
> + ret_codes = kvcalloc(num_queues, sizeof(int), GFP_KERNEL);
> + if (!ret_codes) {
> + err = -ENOMEM;
> + goto free_with_queues_waiting;
> + }
> + commands = kvcalloc(num_queues, sizeof(int), GFP_KERNEL);
> + if (!commands) {
> + err = -ENOMEM;
> + goto free_with_ret_codes;
> + }
> +
> + for (queue_idx = 0; queue_idx < num_queues; queue_idx++)
> + queues_waiting[queue_idx] = start_id + queue_idx;
> + do {
> + retry_needed = 0;
> + queue_idx = 0;
> + while (queue_idx < num_queues) {
> + cmd_idx = 0;
> + while (queue_idx < num_queues) {
> + if (queues_waiting[queue_idx] != queue_done) {
> + err = cmd(priv, queues_waiting[queue_idx]);
It looks like this line, and some others in this patch, could trivially
be wrapped so they are no longer than 80 columns wide. As is still
preferred for networking code.
Flagged by checkpatch.pl --max-line-length=80
> + if (err == -ENOMEM)
> + break;
> + if (err)
> + goto free_with_commands;
> + commands[cmd_idx++] = queue_idx;
> + }
> + queue_idx++;
> + }
> +
> + if (queue_idx < num_queues)
> + dev_dbg(&priv->pdev->dev,
> + "Issued %d of %d batched commands\n",
> + queue_idx, num_queues);
> +
> + err = gve_adminq_kick_and_wait(priv, cmd_idx, ret_codes);
> + if (err)
> + goto free_with_commands;
> +
> + for (ret_code_idx = 0; ret_code_idx < cmd_idx; ret_code_idx++) {
> + if (ret_codes[ret_code_idx] == 0) {
> + queues_waiting[commands[ret_code_idx]] = queue_done;
> + } else if (ret_codes[ret_code_idx] != -ETIME) {
> + ret = ret_codes[ret_code_idx];
> + goto free_with_commands;
> + } else {
> + retry_needed++;
> + }
> + }
> +
> + if (retry_needed)
> + dev_dbg(&priv->pdev->dev,
> + "Issued %d batched commands, %d needed a retry\n",
> + cmd_idx, retry_needed);
> + }
> + } while (retry_needed && ++retry_cnt < GVE_ADMINQ_RETRY_COUNT);
> +
> + ret = retry_needed ? -ETIME : 0;
> +
> +free_with_commands:
> + kvfree(commands);
> + commands = NULL;
> +free_with_ret_codes:
> + kvfree(ret_codes);
> + ret_codes = NULL;
> +free_with_queues_waiting:
> + kvfree(queues_waiting);
> + queues_waiting = NULL;
> + if (err)
> + return err;
I'm unsure if this can occur in practice, because it seems to depend
on the do loop above running , but cmd() not being executed at all.
However, FWIIW, Smatch flags that err may be used uninitialised here.
> + return ret;
> +}
...
prev parent reply other threads:[~2024-07-01 11:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-28 18:54 [PATCH] gve: Add retry logic for recoverable adminq errors Rushil Gupta
2024-07-01 11:21 ` Simon Horman [this message]
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=20240701112139.GX17134@kernel.org \
--to=horms@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hramamurthy@google.com \
--cc=jeroendb@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pkaligineedi@google.com \
--cc=rushilg@google.com \
--cc=shailend@google.com \
--cc=willemb@google.com \
--cc=ziweixiao@google.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).