Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2476309pxb; Mon, 11 Jan 2021 10:32:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdWsZTN/HbzFSP6bSKU6E0C5YTUfbvE71/NDOFN0JyP9saMDNmztJ9C5jfd9Pr9yFgCreP X-Received: by 2002:a17:906:a008:: with SMTP id p8mr542980ejy.117.1610389929939; Mon, 11 Jan 2021 10:32:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610389929; cv=none; d=google.com; s=arc-20160816; b=NEVpGyDpQxL7E7vT5hE6klHXPzSbuTHN/dGms5a1rG4VnLMdKUaNmru9ah+0Pp6DN0 cnjxWXWb2/Nux34VcUr5Br3o+bFJwP2Qm0QiCAixddTdxEaa1Bj37KpXRc8dm2VcZHHO 0YvtiOWWoeDelE/b0qz5EzmrdmAxjzGNGm+UpGXH+gqdr7pyNsVXlgY5ayi/BQ6PVxrE V5qatswHkXmkYpxQW6rBtuSPDslplkQHkrN2n64UwCU/GU145VP05D5GjK+Em9PYos0w YIZILz2avt9fvw5J80ORyqE2DGJRFwRGUh6GC2jkZi8MLXrE7jIE8RgILnjntJj8Ny+S Z4mg== 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=wgAyaFE6+C7VTIm9g+ku7OzpbV9LwSqwPAVdcpq7pZ8=; b=EtSv78RgjN3EoOQD6le6aHZes6oULEVt+QRVIJlUYon4uHqqoh2h8ABlYrTckzm94b QyXqpa4sYiIF9XmqEs7Dy6QzwpG0Hm0t8dw7ckjZuuU3IGo5YMxw/j4LeMNQxnFoveyL 6PQVrzqofMgQbmGYq2H6uMq2aO2+++GMiQAQXBVyxqmmQOuGRogLME7DgJnIyOsX3xAz 9V9NY+HUaYKpQOVjqQYHqyab6cTNLrSN6W6VXiPzkZk2dAZhbXpVUok+FUFd/FHrGH3F IBE4EovAsPTjdjF25+lyzSuaxNBzGU/h7tv3ZzJD5vK4IqfGcByHRwSPAw+8+MkqFOP2 gW3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=AhjGxmKQ; 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 x27si95060ejb.485.2021.01.11.10.31.46; Mon, 11 Jan 2021 10:32:09 -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=AhjGxmKQ; 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 S2390150AbhAKS3b (ORCPT + 99 others); Mon, 11 Jan 2021 13:29:31 -0500 Received: from mail2.protonmail.ch ([185.70.40.22]:28794 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726668AbhAKS3b (ORCPT ); Mon, 11 Jan 2021 13:29:31 -0500 Date: Mon, 11 Jan 2021 18:28:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1610389728; bh=wgAyaFE6+C7VTIm9g+ku7OzpbV9LwSqwPAVdcpq7pZ8=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=AhjGxmKQHyvF2E4xiqqIqCFUsuLzpVSXaHzJEzzRAa58Jh4jWuPX31RmZrVuRqCkt l0mN5G7wsjERejFECaBZOIQqkw0vIlB4cGIuOoCJ4mlnSDUfcEJ3FLlhsL581K+KQz d8bKmziPh85KIOGiDBwm5/xKmG0mNBaY0ISJr1eWF3EYC9ibKJ+0mN3KOpAZdOKJZ6 YYEIfyk5KE6gRqpD1RIkBzY80e9f1uS2QUI8MBHYimYpYU+omq1YiryVZZdyCGBSyp w16VtEW4hCyc977oeRFIiKodw+mdH6PP0sLrW4UnSmxPW92pe54bGS7nlkWoPnk278 8zmPQD8injf5w== 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 2/5] skbuff: open-code __build_skb() inside __napi_alloc_skb() Message-ID: <20210111182801.12609-2-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 In preparation for skbuff_heads caching and reusing, open-code __build_skb() inside __napi_alloc_skb() with factoring out the skbbuff_head allocation itself. Note that the return value of __build_skb_around() is not checked since it never returns anything except the given skb. Signed-off-by: Alexander Lobakin --- net/core/skbuff.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 17ae5e90f103..3c904c29efbb 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -485,6 +485,11 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *= dev, unsigned int len, } EXPORT_SYMBOL(__netdev_alloc_skb); =20 +static struct sk_buff *__napi_decache_skb(struct napi_alloc_cache *nc) +{ +=09return kmem_cache_alloc(skbuff_head_cache, GFP_ATOMIC); +} + /** *=09__napi_alloc_skb - allocate skbuff for rx in a specific NAPI instance *=09@napi: napi instance this buffer was allocated for @@ -525,12 +530,15 @@ struct sk_buff *__napi_alloc_skb(struct napi_struct *= napi, unsigned int len, =09if (unlikely(!data)) =09=09return NULL; =20 -=09skb =3D __build_skb(data, len); +=09skb =3D __napi_decache_skb(nc); =09if (unlikely(!skb)) { =09=09skb_free_frag(data); =09=09return NULL; =09} =20 +=09memset(skb, 0, offsetof(struct sk_buff, tail)); +=09__build_skb_around(skb, data, len); + =09if (nc->page.pfmemalloc) =09=09skb->pfmemalloc =3D 1; =09skb->head_frag =3D 1; --=20 2.30.0