From: Heiner Kallweit <hkallweit1@gmail.com>
To: Ken Milmore <ken.milmore@gmail.com>, netdev@vger.kernel.org
Cc: nic_swsd@realtek.com
Subject: Re: r8169: transmit queue timeouts and IRQ masking
Date: Sat, 11 May 2024 18:31:27 +0200 [thread overview]
Message-ID: <940faa90-81db-40dc-8773-1720520b10ed@gmail.com> (raw)
In-Reply-To: <f0305064-64d9-4705-9846-cdc0fb103b82@gmail.com>
On 11.05.2024 00:29, Ken Milmore wrote:
> 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()."
>
According to kernel doc napi_disable() waits.
/**
* napi_disable - prevent NAPI from scheduling
* @n: NAPI context
*
* Stop NAPI from being scheduled on this context.
* Waits till any outstanding processing completes.
*/
> 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?
Same documents states in section "Scheduling and IRQ masking":
IRQ should only be unmasked after a successful call to napi_complete_done()
So I think we should be fine.
next prev parent reply other threads:[~2024-05-11 16:31 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
2024-05-11 16:31 ` Heiner Kallweit [this message]
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=940faa90-81db-40dc-8773-1720520b10ed@gmail.com \
--to=hkallweit1@gmail.com \
--cc=ken.milmore@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 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 read-only IMAP folder(s) and NNTP newsgroup(s).