All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ken Milmore <ken.milmore@gmail.com>
To: Heiner Kallweit <hkallweit1@gmail.com>, netdev@vger.kernel.org
Cc: nic_swsd@realtek.com
Subject: Re: r8169: transmit queue timeouts and IRQ masking
Date: Fri, 10 May 2024 23:29:13 +0100	[thread overview]
Message-ID: <f0305064-64d9-4705-9846-cdc0fb103b82@gmail.com> (raw)
In-Reply-To: <adfb0005-3283-4138-97d5-b4af3a314d98@gmail.com>

On 10/05/2024 23:06, Heiner Kallweit wrote:
> 
> Nice idea. The following is a simplified version.
> It's based on the thought that between scheduling NAPI and start of NAPI
> polling interrupts don't hurt.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/net/ethernet/realtek/r8169_main.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index e5ea827a2..7b04dfecc 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -592,6 +592,7 @@ enum rtl_flag {
>  	RTL_FLAG_TASK_RESET_PENDING,
>  	RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE,
>  	RTL_FLAG_TASK_TX_TIMEOUT,
> +	RTL_FLAG_IRQ_DISABLED,
>  	RTL_FLAG_MAX
>  };
>  
> @@ -4657,10 +4658,7 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
>  		rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING);
>  	}
>  
> -	if (napi_schedule_prep(&tp->napi)) {
> -		rtl_irq_disable(tp);
> -		__napi_schedule(&tp->napi);
> -	}
> +	napi_schedule(&tp->napi);
>  out:
>  	rtl_ack_events(tp, status);
>  
> @@ -4714,12 +4712,17 @@ static int rtl8169_poll(struct napi_struct *napi, int budget)
>  	struct net_device *dev = tp->dev;
>  	int work_done;
>  
> +	if (!test_and_set_bit(RTL_FLAG_IRQ_DISABLED, tp->wk.flags))
> +		rtl_irq_disable(tp);
> +
>  	rtl_tx(dev, tp, budget);
>  
>  	work_done = rtl_rx(dev, tp, budget);
>  
> -	if (work_done < budget && napi_complete_done(napi, work_done))
> +	if (work_done < budget && napi_complete_done(napi, work_done)) {
> +		clear_bit(RTL_FLAG_IRQ_DISABLED, tp->wk.flags);
>  		rtl_irq_enable(tp);
> +	}
>  
>  	return work_done;
>  }

Reading this worries me though:

https://docs.kernel.org/networking/napi.html
"napi_disable() and subsequent calls to the poll method only wait for the ownership of the instance to be released, not for the poll method to exit.
This means that drivers should avoid accessing any data structures after calling napi_complete_done()."

Which seems to imply that the IRQ enable following napi_complete_done() is unguarded, and might race with the disable on an incoming poll.
Is that a possibility?

  reply	other threads:[~2024-05-10 22:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-06 21:28 r8169: transmit queue timeouts and IRQ masking Ken Milmore
2024-05-08 21:14 ` Heiner Kallweit
2024-05-09 22:24   ` Ken Milmore
2024-05-10 22:06     ` Heiner Kallweit
2024-05-10 22:29       ` Ken Milmore [this message]
2024-05-11 16:31         ` Heiner Kallweit
2024-05-12 19:49           ` Ken Milmore
2024-05-12 22:08             ` Heiner Kallweit
2024-05-13  0:27               ` Ken Milmore

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=f0305064-64d9-4705-9846-cdc0fb103b82@gmail.com \
    --to=ken.milmore@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=nic_swsd@realtek.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 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.