netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: eth: altera: fix napi poll_list corruption
@ 2015-09-02  8:49 Atsushi Nemoto
  2015-09-02 18:25 ` David Miller
  0 siblings, 1 reply; 7+ messages in thread
From: Atsushi Nemoto @ 2015-09-02  8:49 UTC (permalink / raw)
  To: Vince Bridgers, netdev

tse_poll() calls __napi_complete() with irq enabled.  This leads napi
poll_list corruption and may stop all napi drivers working.
Use napi_complete() instead of __napi_complete().

Signed-off-by: Atsushi Nemoto <nemoto@toshiba-tops.co.jp>
---
 drivers/net/ethernet/altera/altera_tse_main.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index da48e66..8207877 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -511,8 +511,7 @@ static int tse_poll(struct napi_struct *napi, int budget)
 
 	if (rxcomplete < budget) {
 
-		napi_gro_flush(napi, false);
-		__napi_complete(napi);
+		napi_complete(napi);
 
 		netdev_dbg(priv->dev,
 			   "NAPI Complete, did %d packets with budget %d\n",
-- 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: eth: altera: fix napi poll_list corruption
  2015-09-02  8:49 [PATCH] net: eth: altera: fix napi poll_list corruption Atsushi Nemoto
@ 2015-09-02 18:25 ` David Miller
  2015-09-03  0:52   ` Atsushi Nemoto
  0 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2015-09-02 18:25 UTC (permalink / raw)
  To: nemoto; +Cc: vbridger, netdev

From: Atsushi Nemoto <nemoto@toshiba-tops.co.jp>
Date: Wed, 2 Sep 2015 17:49:29 +0900

> tse_poll() calls __napi_complete() with irq enabled.  This leads napi
> poll_list corruption and may stop all napi drivers working.
> Use napi_complete() instead of __napi_complete().
> 
> Signed-off-by: Atsushi Nemoto <nemoto@toshiba-tops.co.jp>

Two lines below this change you are disabling interrupts anyways,
so I would suggest just moving the spin_lock_irqsave() before the
napi_gro_flush() to fix this.

Many of the checks done by napi_complete_done() (invoked by
napi_complete()) are completely redundant in this context.  For
example, the direct __napi_complete() call is a really nice
optimization because we know we are on the poll list and therefore
it is not empty.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: eth: altera: fix napi poll_list corruption
  2015-09-02 18:25 ` David Miller
@ 2015-09-03  0:52   ` Atsushi Nemoto
  2015-09-03  2:42     ` Eric Dumazet
  2015-09-03  5:32     ` David Miller
  0 siblings, 2 replies; 7+ messages in thread
From: Atsushi Nemoto @ 2015-09-03  0:52 UTC (permalink / raw)
  To: davem; +Cc: vbridger, netdev

On Wed, 2 Sep 2015 11:25:00 -0700, David Miller <davem@davemloft.net> wrote:
> Two lines below this change you are disabling interrupts anyways,
> so I would suggest just moving the spin_lock_irqsave() before the
> napi_gro_flush() to fix this.
> 
> Many of the checks done by napi_complete_done() (invoked by
> napi_complete()) are completely redundant in this context.  For
> example, the direct __napi_complete() call is a really nice
> optimization because we know we are on the poll list and therefore
> it is not empty.

Thank you for your suggestion.

I think napi_gro_flush() can be called with irq enabled, so moving the
spin_lock_irqsave() just before the __napi_complete() (or moving the
__napi_complete() just after the spin_lock_irqsave()) would be better,
right?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: eth: altera: fix napi poll_list corruption
  2015-09-03  0:52   ` Atsushi Nemoto
@ 2015-09-03  2:42     ` Eric Dumazet
  2015-09-03  5:32     ` David Miller
  1 sibling, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2015-09-03  2:42 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: davem, vbridger, netdev

On Thu, 2015-09-03 at 09:52 +0900, Atsushi Nemoto wrote:
> On Wed, 2 Sep 2015 11:25:00 -0700, David Miller <davem@davemloft.net> wrote:
> > Two lines below this change you are disabling interrupts anyways,
> > so I would suggest just moving the spin_lock_irqsave() before the
> > napi_gro_flush() to fix this.
> > 
> > Many of the checks done by napi_complete_done() (invoked by
> > napi_complete()) are completely redundant in this context.  For
> > example, the direct __napi_complete() call is a really nice
> > optimization because we know we are on the poll list and therefore
> > it is not empty.
> 
> Thank you for your suggestion.
> 
> I think napi_gro_flush() can be called with irq enabled, so moving the
> spin_lock_irqsave() just before the __napi_complete() (or moving the
> __napi_complete() just after the spin_lock_irqsave()) would be better,
> right?

Unless masking irqs are damn slow on hosts supporting this NIC,
I would rather use napi_complete_done() and add the possibility of
aggregating more frames per GRO packet, setting a non zero
gro_flush_timeout

Calling napi_gro_flush() and __napi_complete() looks error prone.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: eth: altera: fix napi poll_list corruption
  2015-09-03  0:52   ` Atsushi Nemoto
  2015-09-03  2:42     ` Eric Dumazet
@ 2015-09-03  5:32     ` David Miller
  2015-09-03  6:01       ` Atsushi Nemoto
  1 sibling, 1 reply; 7+ messages in thread
From: David Miller @ 2015-09-03  5:32 UTC (permalink / raw)
  To: nemoto; +Cc: vbridger, netdev

From: Atsushi Nemoto <nemoto@toshiba-tops.co.jp>
Date: Thu, 3 Sep 2015 09:52:57 +0900

> On Wed, 2 Sep 2015 11:25:00 -0700, David Miller <davem@davemloft.net> wrote:
>> Two lines below this change you are disabling interrupts anyways,
>> so I would suggest just moving the spin_lock_irqsave() before the
>> napi_gro_flush() to fix this.
>> 
>> Many of the checks done by napi_complete_done() (invoked by
>> napi_complete()) are completely redundant in this context.  For
>> example, the direct __napi_complete() call is a really nice
>> optimization because we know we are on the poll list and therefore
>> it is not empty.
> 
> Thank you for your suggestion.
> 
> I think napi_gro_flush() can be called with irq enabled, so moving the
> spin_lock_irqsave() just before the __napi_complete() (or moving the
> __napi_complete() just after the spin_lock_irqsave()) would be better,
> right?

It should work, yes.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: eth: altera: fix napi poll_list corruption
  2015-09-03  5:32     ` David Miller
@ 2015-09-03  6:01       ` Atsushi Nemoto
  2015-09-03 22:35         ` David Miller
  0 siblings, 1 reply; 7+ messages in thread
From: Atsushi Nemoto @ 2015-09-03  6:01 UTC (permalink / raw)
  To: davem; +Cc: vbridger, netdev, eric.dumazet

On Wed, 2 Sep 2015 22:32:54 -0700, David Miller <davem@davemloft.net> wrote:
>> I think napi_gro_flush() can be called with irq enabled, so moving the
>> spin_lock_irqsave() just before the __napi_complete() (or moving the
>> __napi_complete() just after the spin_lock_irqsave()) would be better,
>> right?
> 
> It should work, yes.

Thank you.  But I agree with Eric's last comment ("Calling
napi_gro_flush() and __napi_complete() looks error prone."), and found
that napi_complete_done() also checks NAPI_STATE_NPSVC to support
NETPOLL.  These checks looks somewhat redundant but I like simple way
unless it is really critical to performance.

So, please take original fix as is.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: eth: altera: fix napi poll_list corruption
  2015-09-03  6:01       ` Atsushi Nemoto
@ 2015-09-03 22:35         ` David Miller
  0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2015-09-03 22:35 UTC (permalink / raw)
  To: nemoto; +Cc: vbridger, netdev, eric.dumazet

 From: Atsushi Nemoto <nemoto@toshiba-tops.co.jp>
Date: Thu, 3 Sep 2015 15:01:02 +0900

> On Wed, 2 Sep 2015 22:32:54 -0700, David Miller <davem@davemloft.net> wrote:
>>> I think napi_gro_flush() can be called with irq enabled, so moving the
>>> spin_lock_irqsave() just before the __napi_complete() (or moving the
>>> __napi_complete() just after the spin_lock_irqsave()) would be better,
>>> right?
>> 
>> It should work, yes.
> 
> Thank you.  But I agree with Eric's last comment ("Calling
> napi_gro_flush() and __napi_complete() looks error prone."), and found
> that napi_complete_done() also checks NAPI_STATE_NPSVC to support
> NETPOLL.  These checks looks somewhat redundant but I like simple way
> unless it is really critical to performance.
> 
> So, please take original fix as is.

Fair enough, applied and queued up for -stable.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-09-03 22:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-02  8:49 [PATCH] net: eth: altera: fix napi poll_list corruption Atsushi Nemoto
2015-09-02 18:25 ` David Miller
2015-09-03  0:52   ` Atsushi Nemoto
2015-09-03  2:42     ` Eric Dumazet
2015-09-03  5:32     ` David Miller
2015-09-03  6:01       ` Atsushi Nemoto
2015-09-03 22:35         ` David Miller

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).