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 9FEBAC43381 for ; Mon, 25 Mar 2019 08:54:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B31820863 for ; Mon, 25 Mar 2019 08:54:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730069AbfCYIyT (ORCPT ); Mon, 25 Mar 2019 04:54:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36088 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726234AbfCYIyT (ORCPT ); Mon, 25 Mar 2019 04:54:19 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 040953082201; Mon, 25 Mar 2019 08:54:19 +0000 (UTC) Received: from localhost.localdomain (unknown [10.32.181.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id A9FFB5D9D5; Mon, 25 Mar 2019 08:54:15 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2] net: use bulk free in kfree_skb_list From: Paolo Abeni To: Felix Fietkau , netdev@vger.kernel.org Cc: davem@davemloft.net, brouer@redhat.com, fw@strlen.de Date: Mon, 25 Mar 2019 09:54:14 +0100 In-Reply-To: <20190324165644.21303-1-nbd@nbd.name> References: <20190324165644.21303-1-nbd@nbd.name> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5 (3.30.5-1.fc29) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 25 Mar 2019 08:54:19 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 > --- > 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