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=-8.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT 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 AE56CC43381 for ; Sun, 24 Mar 2019 06:58:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 55E8921741 for ; Sun, 24 Mar 2019 06:58:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b="lWGrj+pe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728293AbfCXG6l (ORCPT ); Sun, 24 Mar 2019 02:58:41 -0400 Received: from nbd.name ([46.4.11.11]:57784 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726160AbfCXG6k (ORCPT ); Sun, 24 Mar 2019 02:58:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=WjXfA1GnNHm50fhOUX6wEnSCaw6MwUTMeUaF4hhiJf4=; b=lWGrj+pebwXJJFQF6o9bk1mfwt G9tpOp8NZiquweJC/j5xycsorioS4Tjh/ya6mnUHlsfUVwfGMX+IDh60NrosFK4nWoTyUB3hsiPUc G2KPQ/1hYaucm5+/vJ1ugv58jtt5ABB4eHmiR7c0g7jkBNo4b/Ue2Q1dOWysxq2a6BBk=; Received: from p4ff13c7c.dip0.t-ipconnect.de ([79.241.60.124] helo=maeck.lan) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h7x5X-0002Bn-UM; Sun, 24 Mar 2019 07:58:36 +0100 Received: by maeck.lan (Postfix, from userid 501) id DEE4C54B1218; Sun, 24 Mar 2019 07:58:34 +0100 (CET) From: Felix Fietkau To: netdev@vger.kernel.org Cc: davem@davemloft.net Subject: [PATCH net-next] net: use bulk free in kfree_skb_list Date: Sun, 24 Mar 2019 07:58:34 +0100 Message-Id: <20190324065834.89272-1-nbd@nbd.name> X-Mailer: git-send-email 2.17.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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)) { + 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); -- 2.17.0