From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AED5C43381 for ; Sun, 24 Mar 2019 11:31:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C97F1222D0 for ; Sun, 24 Mar 2019 11:31:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727167AbfCXLbh (ORCPT ); Sun, 24 Mar 2019 07:31:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36898 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726160AbfCXLbg (ORCPT ); Sun, 24 Mar 2019 07:31:36 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5BF6581DE6; Sun, 24 Mar 2019 11:31:36 +0000 (UTC) Received: from carbon (ovpn-200-46.brq.redhat.com [10.40.200.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E4F91001DC8; Sun, 24 Mar 2019 11:31:31 +0000 (UTC) Date: Sun, 24 Mar 2019 12:31:30 +0100 From: Jesper Dangaard Brouer To: Felix Fietkau Cc: brouer@redhat.com, netdev@vger.kernel.org, davem@davemloft.net, Florian Westphal Subject: Re: [PATCH net-next] net: use bulk free in kfree_skb_list Message-ID: <20190324123130.7b86487a@carbon> In-Reply-To: <20190324065834.89272-1-nbd@nbd.name> References: <20190324065834.89272-1-nbd@nbd.name> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sun, 24 Mar 2019 11:31:36 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Sun, 24 Mar 2019 07:58:34 +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 Thanks for working on this, it's been on my todo list for a very long time. I just discussed this with Florian at NetDevconf. > --- > net/core/skbuff.c | 35 +++++++++++++++++++++++++++++++---- > 1 file changed, 31 insertions(+), 4 deletions(-) > > diff --git a/net/core/skbuff.c b/net/core/skbuff.c > index 2415d9cb9b89..ec030ab7f1e7 100644 > --- a/net/core/skbuff.c > +++ b/net/core/skbuff.c > @@ -666,12 +666,39 @@ 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 (segs->fclone != SKB_FCLONE_UNAVAILABLE || > + n_skbs >= ARRAY_SIZE(skbs)) { You could call kmem_cache_free_bulk() here and reset n_skbs=0. > + kfree_skb(segs); > + continue; > + } > + > + trace_kfree_skb(segs, __builtin_return_address(0)); > + > + /* drop skb->head and call any destructors for packet */ > + skb_release_all(segs); > + > +#ifdef CONFIG_SLUB > + /* SLUB writes into objects when freeing */ > + prefetchw(segs); > +#endif > + > + skbs[n_skbs++] = segs; > } > + > + if (!n_skbs) > + return; > + > + kmem_cache_free_bulk(skbuff_head_cache, n_skbs, skbs); > } > EXPORT_SYMBOL(kfree_skb_list); > -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer