public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Harshitha Ramamurthy <hramamurthy@google.com>, netdev@vger.kernel.org
Cc: joshwash@google.com, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, willemb@google.com,
	maolson@google.com, nktgrg@google.com, jfraker@google.com,
	ziweixiao@google.com, jacob.e.keller@intel.com,
	pkaligineedi@google.com, shailend@google.com,
	jordanrhee@google.com, stable@vger.kernel.org,
	linux-kernel@vger.kernel.org, Pin-yen Lin <treapking@google.com>
Subject: Re: [PATCH net 4/4] gve: Make ethtool config changes synchronous
Date: Thu, 23 Apr 2026 15:25:24 +0200	[thread overview]
Message-ID: <d0981984-b55f-495e-848b-6e9611f0c2ff@redhat.com> (raw)
In-Reply-To: <20260420171837.455487-5-hramamurthy@google.com>

On 4/20/26 7:18 PM, Harshitha Ramamurthy wrote:
> From: Pin-yen Lin <treapking@google.com>
> 
> When modifying device features via ethtool, the driver queues the
> carrier status update to its workqueue (gve_wq). This leads to a
> short link-down state after running the ethtool command.
> 
> Use `gve_turnup_and_check_status()` instead of `gve_turnup()` in
> `gve_queues_start()` to update the carrier status before returning to
> the userspace.
> 
> This was discovered by drivers/net/ping.py selftest. The test calls
> ping command right after an ethtool configuration, but the interface
> could be down without this fix.
> 
> Cc: stable@vger.kernel.org
> Fixes: 5f08cd3d6423 ("gve: Alloc before freeing when adjusting queues")
> Reviewed-by: Joshua Washington <joshwash@google.com>
> Signed-off-by: Pin-yen Lin <treapking@google.com>
> Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com>
> ---
>  drivers/net/ethernet/google/gve/gve_main.c | 56 +++++++++++-----------
>  1 file changed, 28 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
> index 8617782791e0..d3b4bec38de5 100644
> --- a/drivers/net/ethernet/google/gve/gve_main.c
> +++ b/drivers/net/ethernet/google/gve/gve_main.c
> @@ -1374,6 +1374,33 @@ static void gve_queues_mem_remove(struct gve_priv *priv)
>  	priv->rx = NULL;
>  }
>  
> +static void gve_handle_link_status(struct gve_priv *priv, bool link_status)
> +{
> +	if (!gve_get_napi_enabled(priv))
> +		return;
> +
> +	if (link_status == netif_carrier_ok(priv->dev))
> +		return;
> +
> +	if (link_status) {
> +		netdev_info(priv->dev, "Device link is up.\n");
> +		netif_carrier_on(priv->dev);
> +	} else {
> +		netdev_info(priv->dev, "Device link is down.\n");
> +		netif_carrier_off(priv->dev);
> +	}
> +}
> +
> +static void gve_turnup_and_check_status(struct gve_priv *priv)
> +{
> +	u32 status;
> +
> +	gve_turnup(priv);
> +	status = ioread32be(&priv->reg_bar0->device_status);
> +	gve_handle_link_status(priv,
> +			       GVE_DEVICE_STATUS_LINK_STATUS_MASK & status);
> +}
> +
>  /* The passed-in queue memory is stored into priv and the queues are made live.
>   * No memory is allocated. Passed-in memory is freed on errors.
>   */
> @@ -1434,8 +1461,7 @@ static int gve_queues_start(struct gve_priv *priv,
>  			  round_jiffies(jiffies +
>  				msecs_to_jiffies(priv->stats_report_timer_period)));
>  
> -	gve_turnup(priv);
> -	queue_work(priv->gve_wq, &priv->service_task);
> +	gve_turnup_and_check_status(priv);

Sashiko says:

Since gve_handle_link_status() can now be called from process context
via gve_turnup_and_check_status(), while also being concurrently
executed by gve_service_task() on the workqueue, could this create a
time-of-check to time-of-use race?
If the physical link toggles rapidly, could the workqueue thread sample
the later hardware state (e.g. OFF) but see the software state is
already OFF and return early, while the process context thread sampled
the earlier state (e.g. ON), evaluated netif_carrier_ok() as OFF, and
proceeded to call netif_carrier_on()?
This might leave the software carrier state stuck ON when the most
recent hardware state is OFF, because the condition check and update are
no longer serialized by the workqueue.

Notes that there more comments:

https://sashiko.dev/#/patchset/20260420171837.455487-1-hramamurthy%40google.com

but I'm not sure if they are actual regressions introduced by this series.

/P


      reply	other threads:[~2026-04-23 13:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-20 17:18 [PATCH net 0/4] gve: Fixes for issues discovered via net selftests Harshitha Ramamurthy
2026-04-20 17:18 ` [PATCH net 1/4] gve: Add NULL pointer checks for per-queue statistics Harshitha Ramamurthy
2026-04-20 17:18 ` [PATCH net 2/4] gve: Fix backward stats when interface goes down or configuration is adjusted Harshitha Ramamurthy
2026-04-23 11:46   ` Paolo Abeni
2026-04-20 17:18 ` [PATCH net 3/4] gve: Use default min ring size when device option values are 0 Harshitha Ramamurthy
2026-04-20 17:18 ` [PATCH net 4/4] gve: Make ethtool config changes synchronous Harshitha Ramamurthy
2026-04-23 13:25   ` Paolo Abeni [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=d0981984-b55f-495e-848b-6e9611f0c2ff@redhat.com \
    --to=pabeni@redhat.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hramamurthy@google.com \
    --cc=jacob.e.keller@intel.com \
    --cc=jfraker@google.com \
    --cc=jordanrhee@google.com \
    --cc=joshwash@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maolson@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=nktgrg@google.com \
    --cc=pkaligineedi@google.com \
    --cc=shailend@google.com \
    --cc=stable@vger.kernel.org \
    --cc=treapking@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