Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1452309pxb; Wed, 10 Feb 2021 08:38:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxw/+87uA9y9Bo3o9FofXbLaNCiVA0a6ZsUP8xK2fzY4DOdk2cKHSypkB58upJ7Zpq57bVp X-Received: by 2002:a17:907:d25:: with SMTP id gn37mr3753486ejc.303.1612975105992; Wed, 10 Feb 2021 08:38:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612975105; cv=none; d=google.com; s=arc-20160816; b=vIW+KikciOmtl4yAi5rFap3uvshTNFtX87tmex8zi8zr5goIRTbp5gKUPwP0L5mw9k jl+Yjx+qU2Jd9zOgdd6WH1nPPn8IV2JwGnb9d5JCDnHow/WhO4wDRnfhMeqaJRzAoyzf jbMY4lpn0fqNSBJ4Mc/fFKPxZkKiNAqpAUiBXytYDyAYyxCLftwqqczCr6GKsV/vfS1I 7vuczYvuohAf233wBrhjSl4LUwjM1CFCuCjl0kT3YI/eDNobY22/AWEe/YcSy4cahv5V +ILyMNKaa16aqJ3tP0hAqcatb0xBdXTdQpzX7Vs0v4hF4JfEvTaNKa+smPGzF+1FsjzL pt+w== 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=dc++kGDTpe3XCTBAPmEcG2/TX7zpcf+/Bxeoau5z4Vs=; b=NsQeHQUL7yozbUJaTqPHSLMrjIpGxm/5GAG5X6TfSHzMEATvMc9heUEru/f6dkD6bO tVIrGLuIbdlZ/pXvtDhp4FTBeKjl6UJd6ZtFVARxJ+ytTKUqdGjlYskQGwo+c6Xt6TQO b8+XSU8pvyVulttE4Uvn6r4TO2eyaJUI3KaWrC8jem3P+xVzIl1T3dFYRQv3tRN3HKNe r+AuXYEkN/LDQVreTGbgNh4PfpRkIDuKgALh3QArStTEx4pkzTvS8R9U2i+r5+WDDLbw 4Zd/s880oeEIGKs+XsMnLg5MV1zRQcZHsDph9pj5t8XYBDplDYkOQpqNydHyhl6OCzCT ae0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=fy526hQg; 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 s15si1700220edj.492.2021.02.10.08.37.59; Wed, 10 Feb 2021 08:38:25 -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=fy526hQg; 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 S232490AbhBJQhT (ORCPT + 99 others); Wed, 10 Feb 2021 11:37:19 -0500 Received: from mail-40134.protonmail.ch ([185.70.40.134]:62507 "EHLO mail-40134.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232625AbhBJQcK (ORCPT ); Wed, 10 Feb 2021 11:32:10 -0500 Date: Wed, 10 Feb 2021 16:30:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1612974661; bh=dc++kGDTpe3XCTBAPmEcG2/TX7zpcf+/Bxeoau5z4Vs=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=fy526hQgcD9tBMZSjWCzYwbc1w9JdM2ekXfXImzYZTtgWlUn4MNvT+pUf2zBNKGlu TsupljStTtYQtZlP9cC75qljibTGygHEz76jjhzyXBzjo5ycwIdxb+U7FNg4P538ps 4usmr90oitiylq0ahX7ccB769N8pMQEKeuKpMjlmPafyv69SUQ2NLcU4G3aK+cSlYy 1JmJUcbQfgzF7QBh+EL6LtX9ScK2n3JSy0Y7eodCm9V9Y7vbyAeiDJZlB4I57J0kz6 WKHydjiv+XVhUuVz7g/4k81jEMYdbzfyK9sdq8WE5lWdA84NjhyWauRC7yVXZNCDkZ OcdNwYOhWmitA== 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 , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Taehee Yoo , Cong Wang , =?utf-8?Q?Bj=C3=B6rn_T=C3=B6pel?= , Miaohe Lin , Guillaume Nault , Yonghong Song , zhudi , Michal Kubecek , Marcelo Ricardo Leitner , Dmitry Safonov <0x7f454c46@gmail.com>, Yang Yingliang , Florian Westphal , Edward Cree , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Reply-To: Alexander Lobakin Subject: [PATCH v4 net-next 10/11] skbuff: allow to use NAPI cache from __napi_alloc_skb() Message-ID: <20210210162732.80467-11-alobakin@pm.me> In-Reply-To: <20210210162732.80467-1-alobakin@pm.me> References: <20210210162732.80467-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 750fa1825b28..ac6e0172f206 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -563,7 +563,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; @@ -580,7 +581,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