From: Jesper Dangaard Brouer <brouer@redhat.com>
To: David Miller <davem@davemloft.net>
Cc: alexander.duyck@gmail.com, netdev@vger.kernel.org,
eugenia@mellanox.com, alexei.starovoitov@gmail.com,
saeedm@mellanox.com, gerlitz.or@gmail.com, brouer@redhat.com
Subject: Re: [net-next PATCH 2/7] mlx4: use napi_consume_skb API to get bulk free operations
Date: Wed, 9 Mar 2016 22:36:07 +0100 [thread overview]
Message-ID: <20160309223607.0ab4d61d@redhat.com> (raw)
In-Reply-To: <20160309.160320.1535201013338177802.davem@davemloft.net>
On Wed, 09 Mar 2016 16:03:20 -0500 (EST)
David Miller <davem@davemloft.net> wrote:
> From: Alexander Duyck <alexander.duyck@gmail.com>
> Date: Wed, 9 Mar 2016 08:47:58 -0800
>
> > On Wed, Mar 9, 2016 at 3:00 AM, Jesper Dangaard Brouer
> > <brouer@redhat.com> wrote:
> >> Passing the budget down was Alex'es design. Axel any thoughts?
> >
> > I'd say just use dev_consume_skb_any in the bulk free instead of
> > dev_consume_skb_irq. This is slow path, as you said, so it shouldn't
> > come up often.
>
> Agreed.
>
> >> I do wonder how expensive this check is... as it goes into a code
> >> hotpath, which is very unlikely. The good thing would be, that we
> >> handle if buggy drivers call this function from a none softirq context
> >> (as these bugs could be hard to catch).
> >>
> >> Can netpoll ever be called from softirq or with BH disabled? (It
> >> disables IRQs, which would break calling kmem_cache_free_bulk).
> >
> > It is better for us to switch things out so that the napi_consume_skb
> > is the fast path with dev_consume_skb_any as the slow. There are too
> > many scenarios where we could be invoking something that makes use of
> > this within the Tx path so it is probably easiest to just solve it
> > that way so we don't have to deal with it again in the future.
>
> Indeed.
So, if I understand you correctly, then we drop the budget parameter
and check for in_softirq(), like:
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 7af7ec635d90..a3c61a9b65d2 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -796,14 +796,14 @@ void __kfree_skb_defer(struct sk_buff *skb)
_kfree_skb_defer(skb);
}
-void napi_consume_skb(struct sk_buff *skb, int budget)
+void napi_consume_skb(struct sk_buff *skb)
{
if (unlikely(!skb))
return;
- /* if budget is 0 assume netpoll w/ IRQs disabled */
- if (unlikely(!budget)) {
- dev_consume_skb_irq(skb);
+ /* Handle if not called from NAPI context, and netpoll invocation */
+ if (unlikely(!in_softirq())) {
+ dev_consume_skb_any(skb);
return;
}
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
Author of http://www.iptv-analyzer.org
LinkedIn: http://www.linkedin.com/in/brouer
next prev parent reply other threads:[~2016-03-09 21:36 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-04 13:01 [net-next PATCH 0/7] net: bulk alloc side and more bulk free drivers Jesper Dangaard Brouer
2016-03-04 13:01 ` [net-next PATCH 1/7] mlx5: use napi_consume_skb API to get bulk free operations Jesper Dangaard Brouer
2016-03-04 13:01 ` [net-next PATCH 2/7] mlx4: " Jesper Dangaard Brouer
2016-03-08 19:24 ` David Miller
2016-03-09 11:00 ` Jesper Dangaard Brouer
2016-03-09 16:47 ` Alexander Duyck
2016-03-09 21:03 ` David Miller
2016-03-09 21:36 ` Jesper Dangaard Brouer [this message]
2016-03-09 21:43 ` Alexander Duyck
2016-03-09 21:47 ` Jesper Dangaard Brouer
2016-03-09 22:07 ` Alexander Duyck
2016-03-10 12:15 ` [net-next PATCH V2 0/3] net: bulk free adjustment and two driver use-cases Jesper Dangaard Brouer
2016-03-10 12:15 ` [net-next PATCH V2 1/3] net: adjust napi_consume_skb to handle none-NAPI callers Jesper Dangaard Brouer
2016-03-10 12:15 ` [net-next PATCH V2 2/3] mlx4: use napi_consume_skb API to get bulk free operations Jesper Dangaard Brouer
2016-03-10 13:59 ` Sergei Shtylyov
2016-03-10 14:59 ` [net-next PATCH V3 0/3] net: bulk free adjustment and two driver use-cases Jesper Dangaard Brouer
2016-03-10 14:59 ` [net-next PATCH V3 1/3] net: adjust napi_consume_skb to handle none-NAPI callers Jesper Dangaard Brouer
2016-03-10 17:21 ` Sergei Shtylyov
2016-03-11 7:45 ` Jesper Dangaard Brouer
2016-03-11 8:43 ` [net-next PATCH V4 0/3] net: bulk free adjustment and two driver use-cases Jesper Dangaard Brouer
2016-03-11 8:43 ` [net-next PATCH V4 1/3] net: adjust napi_consume_skb to handle non-NAPI callers Jesper Dangaard Brouer
2016-03-11 8:44 ` [net-next PATCH V4 2/3] mlx4: use napi_consume_skb API to get bulk free operations Jesper Dangaard Brouer
2016-03-11 8:44 ` [net-next PATCH V4 3/3] mlx5: " Jesper Dangaard Brouer
2016-03-14 2:35 ` [net-next PATCH V4 0/3] net: bulk free adjustment and two driver use-cases David Miller
2016-03-10 14:59 ` [net-next PATCH V3 2/3] mlx4: use napi_consume_skb API to get bulk free operations Jesper Dangaard Brouer
2016-03-10 14:59 ` [net-next PATCH V3 3/3] mlx5: " Jesper Dangaard Brouer
2016-03-10 12:15 ` [net-next PATCH V2 " Jesper Dangaard Brouer
2016-03-04 13:01 ` [net-next PATCH 3/7] net: bulk alloc and reuse of SKBs in NAPI context Jesper Dangaard Brouer
2016-03-13 14:06 ` Rana Shahout
2016-03-14 6:55 ` Jesper Dangaard Brouer
2016-03-04 13:01 ` [net-next PATCH 4/7] mlx5: use napi_alloc_skb API to get SKB bulk allocations Jesper Dangaard Brouer
2016-03-04 13:02 ` [net-next PATCH 5/7] mlx4: " Jesper Dangaard Brouer
2016-03-04 13:02 ` [net-next PATCH 6/7] net: introduce napi_alloc_skb_hint() for more use-cases Jesper Dangaard Brouer
2016-03-04 13:02 ` [net-next PATCH 7/7] mlx5: hint the NAPI alloc skb API about the expected bulk size Jesper Dangaard Brouer
2016-03-04 16:36 ` [net-next PATCH 0/7] net: bulk alloc side and more bulk free drivers Alexei Starovoitov
2016-03-04 19:15 ` Jesper Dangaard Brouer
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=20160309223607.0ab4d61d@redhat.com \
--to=brouer@redhat.com \
--cc=alexander.duyck@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=davem@davemloft.net \
--cc=eugenia@mellanox.com \
--cc=gerlitz.or@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=saeedm@mellanox.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 NNTP newsgroup(s).