Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp359904pxb; Wed, 13 Jan 2021 05:39:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3MchsShDzi17yM3jE+mazRac6QUtGinv2p4mZpYeiZxWkmkGwGIoX44zNOeoSEkAYmhXG X-Received: by 2002:a17:906:4e45:: with SMTP id g5mr1584699ejw.391.1610545179339; Wed, 13 Jan 2021 05:39:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610545179; cv=none; d=google.com; s=arc-20160816; b=XvrKeCwngg+WOYCzYnWF0Xl/3G9Aqg7gvpm3HyZh0DnQpbG0CGENdzDpspXm+K/t9V QPikC01hQBdPAme2utbryeTx5XUOHzT5pclmatGJdTLsEb29OI+vr7gmRCo3ZCF3Uren ALg351h0X3WzSPrVilUSlHS2hCKZVREW1HFigwMPPTOM99N/xRPo6coJd/vk4mQK64QJ To+H0Q7VS2lHswrYgjl3tcyUafDkNZGrl0s81YxFpzSWKWAShsp7ClL6KQdLjEzu6PdS g4u2Ehjq18jZCEk2WvfdpavHR1Zt8p/ir23h4KIlbQos5Za7cpgRu2lh5gpecaL+Sxx/ Lccg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:subject:reply-to:cc:from:to:dkim-signature:date; bh=guUtzNDokVjGcSR8AA0SShEy7FHBvKI0bc1oYHZ+ko0=; b=R+wxrRssszGCvEhmz5/IYznFWr1cYDC9R8UZj6mEic0S31noeA89YKm0eaEdqL5T3B f6kFROwDhJDy6cAQvzc07CCmW+FccwzdkeaSJ4uO5hZT2h00Ek+qCFGGjlZwrvsC6ZKG /yTLq5NwFSRoNGPUBVPpcAo+ZOwH6CS2S0Oy4nlPnioPY2o79pVd7pUBBuHj5q3g0VnA jA5HmaweE1ZUHsOi0rZt+6gNpyy3nJYxk3pzsD434tr6XWcAkIT+ANyhKxC/+XcULEpn iBnbKXx/yg0kcqI2lAyyWz2/jK7KPSYIb2HZsr8ajjJNHlD7YDQ8vzPBwe+bV916GyhV e14w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=NFFsPb8i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id no7si907448ejb.586.2021.01.13.05.39.08; Wed, 13 Jan 2021 05:39:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=NFFsPb8i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726543AbhAMNgq (ORCPT + 99 others); Wed, 13 Jan 2021 08:36:46 -0500 Received: from mail-40133.protonmail.ch ([185.70.40.133]:64402 "EHLO mail-40133.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725809AbhAMNgq (ORCPT ); Wed, 13 Jan 2021 08:36:46 -0500 Date: Wed, 13 Jan 2021 13:35:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1610544962; bh=guUtzNDokVjGcSR8AA0SShEy7FHBvKI0bc1oYHZ+ko0=; h=Date:To:From:Cc:Reply-To:Subject:From; b=NFFsPb8iE0f1jrEgSznqos49PDFv/v59FYBVsI70462JZWFAIjnfl4yIfWVjkK8u8 K9CqOBqfmYel+7/e0MOcZ4zUU0BnJLhWLfhR3RVZgb8yYmvHn7ZZmRanv3EE79ABoY lUKAFEwYT5wNl0kmE0aPYo00XfKIaLezJZrzZ1D1WEnWMRkPG7tbfjA2uuRxLNmKMP Q3tm/BkvAjocBLnE559AwyIpzixprfsDmjYjTpXeZa9INBNxoqWF1I7GwwzCYKPClG J+VpS5oPeDOLiu2mzNEVneShD0raUxfl3NraNLnCn1TgtTSTeepOkFOkKGKFcpz4En RzkYoE/jZ81KA== To: "David S. Miller" , Jakub Kicinski From: Alexander Lobakin Cc: Eric Dumazet , Edward Cree , Jonathan Lemon , Willem de Bruijn , Miaohe Lin , Alexander Lobakin , Steffen Klassert , Guillaume Nault , Yadu Kishore , Al Viro , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: Alexander Lobakin Subject: [PATCH v2 net-next 0/3] skbuff: introduce skbuff_heads reusing and bulking Message-ID: <20210113133523.39205-1-alobakin@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, all sorts of skb allocation always do allocate skbuff_heads one by one via kmem_cache_alloc(). On the other hand, we have percpu napi_alloc_cache to store skbuff_heads queued up for freeing and flush them by bulks. We can use this cache not only for bulk-wiping, but also to obtain heads for new skbs and avoid unconditional allocations, as well as for bulk-allocating. As accessing napi_alloc_cache implies NAPI softirq context, do this only for __napi_alloc_skb() and its derivatives (napi_alloc_skb() and napi_get_frags()). The rough amount of their call sites are 69, which is quite a number. iperf3 showed 35-50 Mbps bumps for both TCP and UDP while performing VLAN NAT on 1.2 GHz MIPS board. The boost is likely to be way bigger on more powerful hosts and NICs with tens of Mpps. Since v1 [0]: - use one unified cache instead of two separate to greatly simplify the logics and reduce hotpath overhead (Edward Cree); - new: recycle also GRO_MERGED_FREE skbs instead of immediate freeing; - correct performance numbers after optimizations and performing lots of tests for different use cases. [0] https://lore.kernel.org/netdev/20210111182655.12159-1-alobakin@pm.me Alexander Lobakin (3): skbuff: open-code __build_skb() inside __napi_alloc_skb() skbuff: (re)use NAPI skb cache on allocation path skbuff: recycle GRO_MERGED_FREE skbs into NAPI skb cache include/linux/skbuff.h | 1 + net/core/dev.c | 9 +---- net/core/skbuff.c | 74 +++++++++++++++++++++++++++++------------- 3 files changed, 54 insertions(+), 30 deletions(-) --=20 2.30.0