From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiner Kallweit Subject: Re: [PATCH v2 net] r8169: fix NAPI handling under high load Date: Thu, 18 Oct 2018 20:17:15 +0200 Message-ID: <6c04a291-ccb5-c08c-6067-43a68ec29c36@gmail.com> References: <8d75498e-6f43-a699-3a0a-fb4a2b5dc860@gmail.com> <05eb4233-bf98-4aeb-73f6-94fec46ca3de@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: "netdev@vger.kernel.org" To: Eric Dumazet , David Miller , Realtek linux nic maintainers Return-path: Received: from mail-wm1-f67.google.com ([209.85.128.67]:37743 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727439AbeJSCTe (ORCPT ); Thu, 18 Oct 2018 22:19:34 -0400 Received: by mail-wm1-f67.google.com with SMTP id 185-v6so1272090wmt.2 for ; Thu, 18 Oct 2018 11:17:22 -0700 (PDT) In-Reply-To: <05eb4233-bf98-4aeb-73f6-94fec46ca3de@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 18.10.2018 20:02, Eric Dumazet wrote: > > > On 10/18/2018 10:56 AM, Heiner Kallweit wrote: >> rtl_rx() and rtl_tx() are called only if the respective bits are set >> in the interrupt status register. Under high load NAPI may not be >> able to process all data (work_done == budget) and it will schedule >> subsequent calls to the poll callback. >> rtl_ack_events() however resets the bits in the interrupt status >> register, therefore subsequent calls to rtl8169_poll() won't call >> rtl_rx() and rtl_tx() - chip interrupts are still disabled. >> >> Fix this by calling rtl_rx() and rtl_tx() independent of the bits >> set in the interrupt status register. Both functions will detect >> if there's nothing to do for them. >> >> Fixes: da78dbff2e05 ("r8169: remove work from irq handler.") >> Signed-off-by: Heiner Kallweit >> --- >> v2: >> - added "Fixes" tag >> --- >> drivers/net/ethernet/realtek/r8169.c | 8 +++----- >> 1 file changed, 3 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c >> index 8c4f49adc..7caf3b7e9 100644 >> --- a/drivers/net/ethernet/realtek/r8169.c >> +++ b/drivers/net/ethernet/realtek/r8169.c >> @@ -6528,17 +6528,15 @@ static int rtl8169_poll(struct napi_struct *napi, int budget) >> struct rtl8169_private *tp = container_of(napi, struct rtl8169_private, napi); >> struct net_device *dev = tp->dev; >> u16 enable_mask = RTL_EVENT_NAPI | tp->event_slow; >> - int work_done= 0; >> + int work_done; >> u16 status; >> >> status = rtl_get_events(tp); >> rtl_ack_events(tp, status & ~tp->event_slow); >> >> - if (status & RTL_EVENT_NAPI_RX) >> - work_done = rtl_rx(dev, tp, (u32) budget); >> + work_done = rtl_rx(dev, tp, (u32) budget); >> >> - if (status & RTL_EVENT_NAPI_TX) >> - rtl_tx(dev, tp); >> + rtl_tx(dev, tp); >> >> if (status & tp->event_slow) { >> enable_mask &= ~tp->event_slow; >> > > One has to wonder why rtl8169_poll(), which might be called in a loop under DOS, > has to call rtl_ack_events() ? > > Should not this be called one time from hard irq handler instead ? > Yes, it should. I have a patch in my tree including this, in addition it moves everything from rtl_slow_event_work() to the hard irq handler. However, due to recent changes, this patch may not apply cleanly to older kernel versions. Calling rtl_ack_events() in the poll callback isn't nice but not directly a bug, so I'd prefer to submit this to net-next. >