Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2475832pxb; Mon, 11 Jan 2021 10:31:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCU03bshmyuCTCKCszYzCMfoA/mUfFArLwRwG+EkFzKYXXmUjElUAIxvIyrRUE0M775igu X-Received: by 2002:a17:906:9386:: with SMTP id l6mr514552ejx.425.1610389894685; Mon, 11 Jan 2021 10:31:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610389894; cv=none; d=google.com; s=arc-20160816; b=gJpHCrflXjBJgOffRd3h8XGQ447+tL+5RQ0LIcu165yFqhf2zXnkL75mm/Y0y/i8+f peQC1jNG8E5t3KIzzdsg8dP6I8jBhPrdEygHhFdMrbI2P/dcA79Iq4Mp39gctN1tqsq7 3AnJmCy08UHzEaTYjIyJ9hUEevQ8QQEV6GXc101K4gYPwZ3FFyw/XBWp6KVSKMYZylVa jRUMkCMtGmjgOFf3nN0jaxpCVTT2lSTWsGkClrS9L0CvJb3u3/Fg/h56vSje2HxAI6Ns tgFOAkdriparsFKp/N0krlYA2O92KK9yANWY8PVtgERQRkvMeHxSXmZWlyGGQ5jfGH7O KwSQ== 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 :references:in-reply-to:message-id:subject:reply-to:cc:from:to :dkim-signature:date; bh=uLN743u/wqC/gFFuGPFTwvMOdJ2kjErr9WqlX51ROd4=; b=Jadyfn0rx7PXoALb5AQ6YHpSfFsBeuZdnCsSm2HC86zFzXCf0a18MM4t+1IU1jdS50 MVBNeAKnxEwTWCPdrMKZbEA5R0e5M+yvZnWssG4A4zq6bceLcTFhE04VC+yMcTcuOq54 khuVBoevE4ajA/OoJwmY96tKBo2cIopsPpAYI+XO5WC33V85goTgpifcZziqxd8MQvCH UBNu0FQjS2ChdZdmhnMr9WENgVAmHOqwiV3g9gvN2VlGnleoDy8p5lHawc+LijL04Y5W tCzKVtpWkEVf4U0wYcEC46GcSyVwe/fiG/8Ns7fndjv876j+twAQ0Z6FPgOML+7DSbor ms+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b="nkuQl8J/"; 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 u22si214431edx.500.2021.01.11.10.31.10; Mon, 11 Jan 2021 10:31:34 -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="nkuQl8J/"; 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 S2390504AbhAKS3r (ORCPT + 99 others); Mon, 11 Jan 2021 13:29:47 -0500 Received: from mail-40131.protonmail.ch ([185.70.40.131]:56270 "EHLO mail-40131.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390296AbhAKS3r (ORCPT ); Mon, 11 Jan 2021 13:29:47 -0500 Date: Mon, 11 Jan 2021 18:29:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1610389745; bh=uLN743u/wqC/gFFuGPFTwvMOdJ2kjErr9WqlX51ROd4=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=nkuQl8J/da2u0Tmb+7OxCZKNk/wFExeqrMkX5jgpkqnU+jSg6DqQjd6fHnytlLjUZ Qq1kC/v0PSwTbZe+uPUjwnnrFgnV3xb9mIcRVucIkZaA5u6jAiuO3zKw1nS30pIFgx JhKH/V3eBxsc5KHmPKrKViFH0mRAjmD4hxD6mDzMrOPgf2JJzIdB9i5qM3jVvRvopq eqBFwDzQZYsk1pelTAGCJRLjb1STPtge7qU3qLsc6xxv8JfQeqBfT1aFAaWB6hU/Fq xdq383aD6ZHBBE9XLXWbWYrKRt+fTepkRePEZQBy/BUXTHTgf0dnrZerIjgHq2JTWr MB0QOp3VQR+KQ== 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 3/5] skbuff: reuse skbuff_heads from flush_skb_cache if available Message-ID: <20210111182801.12609-3-alobakin@pm.me> In-Reply-To: <20210111182801.12609-1-alobakin@pm.me> References: <20210111182655.12159-1-alobakin@pm.me> <20210111182801.12609-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 Instead of unconditional allocating a new skbuff_head and unconditional flushing of flush_skb_cache, reuse the ones queued up for flushing if there are any. skbuff_heads stored in flush_skb_cache are already unreferenced from any pages or extensions and almost ready for use. We perform zeroing in __napi_alloc_skb() anyway, regardless of where did our skbuff_head came from. Signed-off-by: Alexander Lobakin --- net/core/skbuff.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 3c904c29efbb..0e8c597ff6ce 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -487,6 +487,9 @@ EXPORT_SYMBOL(__netdev_alloc_skb); =20 static struct sk_buff *__napi_decache_skb(struct napi_alloc_cache *nc) { +=09if (nc->flush_skb_count) +=09=09return nc->flush_skb_cache[--nc->flush_skb_count]; + =09return kmem_cache_alloc(skbuff_head_cache, GFP_ATOMIC); } =20 --=20 2.30.0