Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3696979pxb; Sat, 13 Feb 2021 06:19:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwc0DA3/WoP3ajbKoAVkVk+8v/3pdhDK2Dw/s35D/pA3cvwj8wWfVDH7Mg+54+LslZpvldd X-Received: by 2002:a17:906:43d7:: with SMTP id j23mr7639686ejn.519.1613225986540; Sat, 13 Feb 2021 06:19:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613225986; cv=none; d=google.com; s=arc-20160816; b=k8di2jBU+bhY+qzrBgfTkgzZj39N0NcSjqlqJ8401sNqREzHCfe5GIXoaDCZt31W39 6MCQGB508iuUHp8gsT1mTSg3ZVn9Ky6pipYEoGIRh6UqH5jLXWPvcthUlBrrgRaTOsMy U+eyQ1Vk/J5AhWDBZCpRv45PI38duFYJdmab7qnaOQ9WADvl650W88ekeeTyQKbP/r0v 4BOvRF5mwMElktMXqvYnqAK6REpmIzUTsaZiqb0qB97CUlXlQcMSZL2IfSEJwGQiyMlZ MEZB6zjFBl87SXHI8dck5MdfqEbiI7z3fhjbZ6kDypMh/DIXrYczg9pxVOuN2lfrRrlz oFHw== 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=HLAVfjIlwGNW478FWp4tyY59eFbEvOz5vX71ZQBVijk=; b=RUEVUnnmRQ/Zl//uiY9gl79BYUL9IeUYxeguWREvMFpckkY1f8fBGfycCKhEVkTKgW HdUA+GoFqTQxnylRdU1Xs+0EPPomWFlh/29PmKy9Bi3romO3F1ypWNsw3B7j39lpJkep 4V2dW6GjMcCiiFDvcO5/o1lpDioZ7E4KZZhTY305UsEB6rTV/RtnG0ILuHvG0BD5dGh8 gxI/yZh8wTtqwliGkxTmBUHFOB/+iCBwgnsiQQmaSrfy3WhvqAqtLwf8GtDqGB3l01q+ U1WYoGJ0q41XHUKx/d6PZFOLU6KnbUIXpd/CqJ8ob/5EOzaFRmFb8ofZ9TbsqpYpK1Mb D0LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=OX2dhEc9; 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 d26si2754207ejb.754.2021.02.13.06.19.23; Sat, 13 Feb 2021 06:19:46 -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=OX2dhEc9; 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 S229706AbhBMOP6 (ORCPT + 99 others); Sat, 13 Feb 2021 09:15:58 -0500 Received: from mail-40131.protonmail.ch ([185.70.40.131]:24691 "EHLO mail-40131.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229803AbhBMONh (ORCPT ); Sat, 13 Feb 2021 09:13:37 -0500 Date: Sat, 13 Feb 2021 14:12:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1613225574; bh=HLAVfjIlwGNW478FWp4tyY59eFbEvOz5vX71ZQBVijk=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=OX2dhEc9PulcqcVVekXlCqwMCvOCBQJU+xltx3p2J181V/lZ2211AdiQihOqP6gd0 o4rv90C/zI7jaWCvNdMaCTs6OTq9UIHEi6pRaVOO60tk83d+HlNK68l7jIl40PVxAy LOON0Hdhvm9OJz7VQgie2Au+6IpzDYOT2gu8F/1CcVUwFIQZI+ZUSDFg+Q3sIIRIfB yX7x2SpHplFN7UhwRyh38JOSsVib+EXwrHjs3+NK+ZvysCbnXbLiJ0ErnbPb7/Cy94 poIC6l8hRSK3JQb8vD7tiCTMjliBKFys1ZYH5oDatMtz813RNCCLmy3V+CVZY0uBsN 8ldqkdAyJVmCQ== To: "David S. Miller" , Jakub Kicinski From: Alexander Lobakin Cc: Jonathan Lemon , Eric Dumazet , Dmitry Vyukov , Willem de Bruijn , Alexander Lobakin , Randy Dunlap , Kevin Hao , Pablo Neira Ayuso , Jakub Sitnicki , Marco Elver , Dexuan Cui , Paolo Abeni , Jesper Dangaard Brouer , Alexander Duyck , Alexander Duyck , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Taehee Yoo , Wei Wang , Cong Wang , =?utf-8?Q?Bj=C3=B6rn_T=C3=B6pel?= , Miaohe Lin , Guillaume Nault , Florian Westphal , Edward Cree , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Reply-To: Alexander Lobakin Subject: [PATCH v6 net-next 10/11] skbuff: allow to use NAPI cache from __napi_alloc_skb() Message-ID: <20210213141021.87840-11-alobakin@pm.me> In-Reply-To: <20210213141021.87840-1-alobakin@pm.me> References: <20210213141021.87840-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 {,__}napi_alloc_skb() is mostly used either for optional non-linear receive methods (usually controlled via Ethtool private flags and off by default) and/or for Rx copybreaks. Use __napi_build_skb() here for obtaining skbuff_heads from NAPI cache instead of inplace allocations. This includes both kmalloc and page frag paths. Signed-off-by: Alexander Lobakin --- net/core/skbuff.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index a80581eed7fc..875e1a453f7e 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -562,7 +562,8 @@ struct sk_buff *__napi_alloc_skb(struct napi_struct *na= pi, unsigned int len, =09if (len <=3D SKB_WITH_OVERHEAD(1024) || =09 len > SKB_WITH_OVERHEAD(PAGE_SIZE) || =09 (gfp_mask & (__GFP_DIRECT_RECLAIM | GFP_DMA))) { -=09=09skb =3D __alloc_skb(len, gfp_mask, SKB_ALLOC_RX, NUMA_NO_NODE); +=09=09skb =3D __alloc_skb(len, gfp_mask, SKB_ALLOC_RX | SKB_ALLOC_NAPI, +=09=09=09=09 NUMA_NO_NODE); =09=09if (!skb) =09=09=09goto skb_fail; =09=09goto skb_success; @@ -579,7 +580,7 @@ struct sk_buff *__napi_alloc_skb(struct napi_struct *na= pi, unsigned int len, =09if (unlikely(!data)) =09=09return NULL; =20 -=09skb =3D __build_skb(data, len); +=09skb =3D __napi_build_skb(data, len); =09if (unlikely(!skb)) { =09=09skb_free_frag(data); =09=09return NULL; --=20 2.30.1