* [net-next PATCH] net: Avoid overwriting valid skb->napi_id
@ 2020-06-18 21:22 Amritha Nambiar
2020-06-18 22:29 ` Eric Dumazet
2020-06-21 0:31 ` David Miller
0 siblings, 2 replies; 5+ messages in thread
From: Amritha Nambiar @ 2020-06-18 21:22 UTC (permalink / raw)
To: netdev, davem
Cc: edumazet, alexander.h.duyck, eliezer.tamir, sridhar.samudrala,
amritha.nambiar
This will be useful to allow busy poll for tunneled traffic. In case of
busy poll for sessions over tunnels, the underlying physical device's
queues need to be polled.
Tunnels schedule NAPI either via netif_rx() for backlog queue or
schedule the gro_cell_poll(). netif_rx() propagates the valid skb->napi_id
to the socket. OTOH, gro_cell_poll() stamps the skb->napi_id again by
calling skb_mark_napi_id() with the tunnel NAPI which is not a busy poll
candidate. This was preventing tunneled traffic to use busy poll. A valid
NAPI ID in the skb indicates it was already marked for busy poll by a
NAPI driver and hence needs to be copied into the socket.
Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
---
include/net/busy_poll.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h
index 86e028388bad..b001fa91c14e 100644
--- a/include/net/busy_poll.h
+++ b/include/net/busy_poll.h
@@ -114,7 +114,11 @@ static inline void skb_mark_napi_id(struct sk_buff *skb,
struct napi_struct *napi)
{
#ifdef CONFIG_NET_RX_BUSY_POLL
- skb->napi_id = napi->napi_id;
+ /* If the skb was already marked with a valid NAPI ID, avoid overwriting
+ * it.
+ */
+ if (skb->napi_id < MIN_NAPI_ID)
+ skb->napi_id = napi->napi_id;
#endif
}
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [net-next PATCH] net: Avoid overwriting valid skb->napi_id
2020-06-18 21:22 [net-next PATCH] net: Avoid overwriting valid skb->napi_id Amritha Nambiar
@ 2020-06-18 22:29 ` Eric Dumazet
2020-06-18 23:44 ` Nambiar, Amritha
2020-06-21 0:31 ` David Miller
1 sibling, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2020-06-18 22:29 UTC (permalink / raw)
To: Amritha Nambiar
Cc: netdev, David Miller, Alexander Duyck, Eliezer Tamir,
Samudrala, Sridhar
On Thu, Jun 18, 2020 at 2:21 PM Amritha Nambiar
<amritha.nambiar@intel.com> wrote:
>
> This will be useful to allow busy poll for tunneled traffic. In case of
> busy poll for sessions over tunnels, the underlying physical device's
> queues need to be polled.
>
> Tunnels schedule NAPI either via netif_rx() for backlog queue or
> schedule the gro_cell_poll(). netif_rx() propagates the valid skb->napi_id
> to the socket. OTOH, gro_cell_poll() stamps the skb->napi_id again by
> calling skb_mark_napi_id() with the tunnel NAPI which is not a busy poll
> candidate.
Yes the tunnel NAPI id should be 0 really (look for NAPI_STATE_NO_BUSY_POLL)
> This was preventing tunneled traffic to use busy poll. A valid
> NAPI ID in the skb indicates it was already marked for busy poll by a
> NAPI driver and hence needs to be copied into the socket.
>
> Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
> ---
> include/net/busy_poll.h | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h
> index 86e028388bad..b001fa91c14e 100644
> --- a/include/net/busy_poll.h
> +++ b/include/net/busy_poll.h
> @@ -114,7 +114,11 @@ static inline void skb_mark_napi_id(struct sk_buff *skb,
> struct napi_struct *napi)
> {
> #ifdef CONFIG_NET_RX_BUSY_POLL
> - skb->napi_id = napi->napi_id;
> + /* If the skb was already marked with a valid NAPI ID, avoid overwriting
> + * it.
> + */
> + if (skb->napi_id < MIN_NAPI_ID)
> + skb->napi_id = napi->napi_id;
It should be faster to not depend on MIN_NAPI_ID (aka NR_CPUS + 1)
if (napi->napi_id)
skb->napi_id = napi->napi_id;
Probably not a big deal.
Reviewed-by: Eric Dumazet <edumazet@google.com>
>
> #endif
> }
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [net-next PATCH] net: Avoid overwriting valid skb->napi_id
2020-06-18 22:29 ` Eric Dumazet
@ 2020-06-18 23:44 ` Nambiar, Amritha
2020-06-18 23:53 ` Eric Dumazet
0 siblings, 1 reply; 5+ messages in thread
From: Nambiar, Amritha @ 2020-06-18 23:44 UTC (permalink / raw)
To: Eric Dumazet
Cc: netdev, David Miller, Alexander Duyck, Eliezer Tamir,
Samudrala, Sridhar
On 6/18/2020 3:29 PM, Eric Dumazet wrote:
> On Thu, Jun 18, 2020 at 2:21 PM Amritha Nambiar
> <amritha.nambiar@intel.com> wrote:
>>
>> This will be useful to allow busy poll for tunneled traffic. In case of
>> busy poll for sessions over tunnels, the underlying physical device's
>> queues need to be polled.
>>
>> Tunnels schedule NAPI either via netif_rx() for backlog queue or
>> schedule the gro_cell_poll(). netif_rx() propagates the valid skb->napi_id
>> to the socket. OTOH, gro_cell_poll() stamps the skb->napi_id again by
>> calling skb_mark_napi_id() with the tunnel NAPI which is not a busy poll
>> candidate.
>
>
> Yes the tunnel NAPI id should be 0 really (look for NAPI_STATE_NO_BUSY_POLL)
>
>> This was preventing tunneled traffic to use busy poll. A valid
>> NAPI ID in the skb indicates it was already marked for busy poll by a
>> NAPI driver and hence needs to be copied into the socket.
>>
>> Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
>> ---
>> include/net/busy_poll.h | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h
>> index 86e028388bad..b001fa91c14e 100644
>> --- a/include/net/busy_poll.h
>> +++ b/include/net/busy_poll.h
>> @@ -114,7 +114,11 @@ static inline void skb_mark_napi_id(struct sk_buff *skb,
>> struct napi_struct *napi)
>> {
>> #ifdef CONFIG_NET_RX_BUSY_POLL
>> - skb->napi_id = napi->napi_id;
>> + /* If the skb was already marked with a valid NAPI ID, avoid overwriting
>> + * it.
>> + */
>> + if (skb->napi_id < MIN_NAPI_ID)
>> + skb->napi_id = napi->napi_id;
>
>
> It should be faster to not depend on MIN_NAPI_ID (aka NR_CPUS + 1)
>
> if (napi->napi_id)
> skb->napi_id = napi->napi_id;
>
> Probably not a big deal.
>
> Reviewed-by: Eric Dumazet <edumazet@google.com>
>
Thanks for the review. Should I send a v2 with this change?
>
>
>
>
>
>>
>> #endif
>> }
>>
>>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [net-next PATCH] net: Avoid overwriting valid skb->napi_id
2020-06-18 23:44 ` Nambiar, Amritha
@ 2020-06-18 23:53 ` Eric Dumazet
0 siblings, 0 replies; 5+ messages in thread
From: Eric Dumazet @ 2020-06-18 23:53 UTC (permalink / raw)
To: Nambiar, Amritha
Cc: netdev, David Miller, Alexander Duyck, Eliezer Tamir,
Samudrala, Sridhar
On Thu, Jun 18, 2020 at 4:44 PM Nambiar, Amritha
<amritha.nambiar@intel.com> wrote:
>
> Thanks for the review. Should I send a v2 with this change?
No, this is really a matter of taste ;)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [net-next PATCH] net: Avoid overwriting valid skb->napi_id
2020-06-18 21:22 [net-next PATCH] net: Avoid overwriting valid skb->napi_id Amritha Nambiar
2020-06-18 22:29 ` Eric Dumazet
@ 2020-06-21 0:31 ` David Miller
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2020-06-21 0:31 UTC (permalink / raw)
To: amritha.nambiar
Cc: netdev, edumazet, alexander.h.duyck, eliezer.tamir,
sridhar.samudrala
From: Amritha Nambiar <amritha.nambiar@intel.com>
Date: Thu, 18 Jun 2020 14:22:15 -0700
> This will be useful to allow busy poll for tunneled traffic. In case of
> busy poll for sessions over tunnels, the underlying physical device's
> queues need to be polled.
>
> Tunnels schedule NAPI either via netif_rx() for backlog queue or
> schedule the gro_cell_poll(). netif_rx() propagates the valid skb->napi_id
> to the socket. OTOH, gro_cell_poll() stamps the skb->napi_id again by
> calling skb_mark_napi_id() with the tunnel NAPI which is not a busy poll
> candidate. This was preventing tunneled traffic to use busy poll. A valid
> NAPI ID in the skb indicates it was already marked for busy poll by a
> NAPI driver and hence needs to be copied into the socket.
>
> Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
Applied, thank you.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-06-21 0:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-18 21:22 [net-next PATCH] net: Avoid overwriting valid skb->napi_id Amritha Nambiar
2020-06-18 22:29 ` Eric Dumazet
2020-06-18 23:44 ` Nambiar, Amritha
2020-06-18 23:53 ` Eric Dumazet
2020-06-21 0:31 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox