Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2905901pxb; Tue, 12 Jan 2021 01:14:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxk4nwMWLxyhLvx+tz8s7o9rLymaLUCNhXXbK1sHbvPX0TzcOnn7FbzyoTD/2sBLFV1HQf0 X-Received: by 2002:a50:b742:: with SMTP id g60mr2553569ede.113.1610442861822; Tue, 12 Jan 2021 01:14:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610442861; cv=none; d=google.com; s=arc-20160816; b=GoGfM/7Sc2XvGTMntexYWoZizUTjbGerEHpF3cDb274FzN5A0AlS5I8nDBYncSWx+w 0hRB7YXXOD2hVqLsCMLaqvnP8hUtI8WPtJmmbTxSUMrYBYfN/HeVOoAzQW8Hi5CZWgM8 XnmJ13/nnoSVjJBo6fozh+AhzRL1T4Raz7nLWJaqmgAiUO7NDcInGQVK4UEbKR72X8KC EJXHfta7uehbnIz1jRnbcHwKuJ/ceZcGtCofxrMFoo4xi6oAf5f+ve3b5qlm/zGRtkYU AhppXK0aDWFsB48nQsLFvVICFXabmlSDrNOvQbno5XpCQR/bilzhCiYTnKWcHA8dYHlG HbeA== 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=zMoAhzMpBXRXHs8lVx+DOgiDZHIU73jEHLkoY9JLnro=; b=hvgZRIbbWtNS4ajtP5rY1yQFAsHLeYMiFIkePJtvyfaowkVb0FrQ8Yodkc/L2e/VYy oGaoWOXRnCqJ8ih9B0iYZ2dH+bghY+8zkv/w962jTw+1qiuiLHLL9vxeXqeNFi/3y8Qr y5gZksz9x3wVmiN93WvCkQZPRbEUPho/FooFA0GPw1JMchtyiG6FddRMQMGQJ0aLBq5z SlkE809K+QlYqe5XqVOyt/iPz2zhyj2RVEBkNIlzcc8ZnRuh9rEyMoAlVf7FEums6WZC reN2tOBMR4iUBfE/QQCJu3gvceOBSLGBTuybqfZrAfwOOHBpI/4urUErsvRr+FwXB6ms fWYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=SWUU5ht8; 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 q21si891932ejd.515.2021.01.12.01.13.57; Tue, 12 Jan 2021 01:14:21 -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=SWUU5ht8; 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 S2389849AbhAKS2J (ORCPT + 99 others); Mon, 11 Jan 2021 13:28:09 -0500 Received: from mail-40131.protonmail.ch ([185.70.40.131]:57984 "EHLO mail-40131.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728056AbhAKS2I (ORCPT ); Mon, 11 Jan 2021 13:28:08 -0500 Date: Mon, 11 Jan 2021 18:27:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1610389644; bh=zMoAhzMpBXRXHs8lVx+DOgiDZHIU73jEHLkoY9JLnro=; h=Date:To:From:Cc:Reply-To:Subject:From; b=SWUU5ht8L8ZEe+kq1pnXCVazfDuj3E0bZwUcIqz3GWofA9V1xwnen3KkUeccl6/fa hrf9LP2PYE31fih+pPVTs6RjWESZV+Xak2qqPWcRy07faCTzdAy/xxJBRomecvoVM0 7lncmRkMYZn7DP0Sp3mld9wsKupMLOpWImge9tifNRaFoXSIqk9k85bGvkql4uwXjk Lj+lOuLb948PHi7PLXlulZwOB8hKh6+q3S0yBS2treuFPzeVJK0exjyak7ZXbnuhmF roHG4aC0whxt+38tbw5/IoruCAJMcVvJQ1Pih7rjaD7MJ9Nnsdp16sv51w1liXSzGE nutOmEIKsmpmg== 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 net-next 0/5] skbuff: introduce skbuff_heads bulking and reusing Message-ID: <20210111182655.12159-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 Inspired by cpu_map_kthread_run() and _kfree_skb_defer() logics. 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 struct to cache and bulk not only freeing, but also allocation of new skbuff_heads, as well as to reuse cached-to-free heads instead of allocating the new ones. 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 a nice bump from 910 to 935 Mbits while performing UDP 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. Patches 1-2 are preparation steps, while 3-5 do the real work. Alexander Lobakin (5): skbuff: rename fields of struct napi_alloc_cache to be more intuitive skbuff: open-code __build_skb() inside __napi_alloc_skb() skbuff: reuse skbuff_heads from flush_skb_cache if available skbuff: allocate skbuff_heads by bulks instead of one by one skbuff: refill skb_cache early from deferred-to-consume entries net/core/skbuff.c | 62 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 14 deletions(-) --=20 2.30.0