From: Paolo Abeni <pabeni@redhat.com>
To: Felix Fietkau <nbd@nbd.name>, netdev@vger.kernel.org
Cc: davem@davemloft.net, brouer@redhat.com, fw@strlen.de
Subject: Re: [PATCH v2] net: use bulk free in kfree_skb_list
Date: Mon, 25 Mar 2019 09:54:14 +0100 [thread overview]
Message-ID: <b33625370d39453edf8f981aef13a7a18a747b0a.camel@redhat.com> (raw)
In-Reply-To: <20190324165644.21303-1-nbd@nbd.name>
Hi,
On Sun, 2019-03-24 at 17:56 +0100, Felix Fietkau wrote:
> Since we're freeing multiple skbs, we might as well use bulk free to save a
> few cycles. Use the same conditions for bulk free as in napi_consume_skb.
>
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
> ---
> v2: call kmem_cache_free_bulk once the skb array is full instead of
> falling back to kfree_skb
> net/core/skbuff.c | 40 ++++++++++++++++++++++++++++++++++++----
> 1 file changed, 36 insertions(+), 4 deletions(-)
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 2415d9cb9b89..1eeaa264d2a4 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -666,12 +666,44 @@ EXPORT_SYMBOL(kfree_skb);
>
> void kfree_skb_list(struct sk_buff *segs)
> {
> - while (segs) {
> - struct sk_buff *next = segs->next;
> + struct sk_buff *next = segs;
> + void *skbs[16];
> + int n_skbs = 0;
>
> - kfree_skb(segs);
> - segs = next;
> + while ((segs = next) != NULL) {
> + next = segs->next;
> +
> + if (!skb_unref(segs))
> + continue;
> +
> + if (fclone != SKB_FCLONE_UNAVAILABLE) {
> + kfree_skb(segs);
> + continue;
> + }
I think you should swap the order of skb_unref() and the above check,
or skbs with 'fclone != SKB_FCLONE_UNAVAILABLE' will go twice in
skb_unref() (kfree_skb() calls skb_unref(), too).
Other than that LGTM,
Thanks,
Paolo
prev parent reply other threads:[~2019-03-25 8:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-24 16:56 [PATCH v2] net: use bulk free in kfree_skb_list Felix Fietkau
2019-03-24 18:23 ` Jesper Dangaard Brouer
2019-03-25 8:51 ` Eric Dumazet
2019-03-25 9:09 ` Felix Fietkau
2019-03-25 9:31 ` Eric Dumazet
2019-03-25 9:35 ` Felix Fietkau
2019-03-25 16:03 ` Jesper Dangaard Brouer
2019-03-25 8:54 ` Paolo Abeni [this message]
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=b33625370d39453edf8f981aef13a7a18a747b0a.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=brouer@redhat.com \
--cc=davem@davemloft.net \
--cc=fw@strlen.de \
--cc=nbd@nbd.name \
--cc=netdev@vger.kernel.org \
/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).