Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2387986pxb; Thu, 11 Feb 2021 11:02:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTTu4wWzmm9iv2NJYh0X9LSMI7NzH4hsim+u7xwJC6laP3sAvSoREv/sp6EvrDqM3lEqtc X-Received: by 2002:a50:9dcd:: with SMTP id l13mr9735028edk.220.1613070130111; Thu, 11 Feb 2021 11:02:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613070130; cv=none; d=google.com; s=arc-20160816; b=V1EH6U1LkST4OsGTuOxibPy1SnmuPkdZ+CoUQUf+7zc0vh2hJYd3102Sjk4gOx64uz Fj3XJ/jqyalAOSZBde3xBktyikOdDAai6pr33l1nsPIbRx3U0FFSSMMxBslpG8E6Y8t7 zP0VLwr4o7JOmuO2dzA15AAYGXPBbAbXh5b7Pqw4K3EJGA0hiwvRVGP9iJCPsfbp9dUZ 03iX751MS4s7C+q2xSfqespBCp3CQUEquVuc5lVQ4e2OI2VhdECQKusBub4YkR8x6Zsy vMlo/+zmpxsVMOfDoj0jkWskvBIDetEqCWtvh8JufRyQ7wI9DKWHOPT8ukFpRrWfiA2Z SUIw== 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=wCw8cavtLqeebztLIscnnEE229I5U5y2doZiTxqDwrI=; b=Z9vT7r7dRtGkHkOQrpN9l7xH9B//BWXcTvzVbE3aOj7xEBUbzMskz4cXyUzp1/Is6Z XX31R3FkTK9SrnG9BjPV9I8EjtBw3vXrnc5RxJ7C0DxWz3gUmSbieHMobGjpCkvhBJhD nYC6IKsKbRyyQqMu4obkWnevqPEP+CU39A5vapMfMM84cfNeIcIk48mdzPFbM9cTGsp2 qR6i2GwVPFCQ8t/8h2fhrgeumjEhhr86ks+0j9VAeK/6AWNxCjAtx/5yerGr8wA9lYCb YmqauLa03P7rCX9sBR66B9Rl340B4ELb2r6mBGGGKUYkfbIa7EmeAgejfoJ2fF5dkJri cv1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=IutA6USn; 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 f7si5317750edd.595.2021.02.11.11.01.27; Thu, 11 Feb 2021 11:02:10 -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=IutA6USn; 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 S231616AbhBKTAN (ORCPT + 99 others); Thu, 11 Feb 2021 14:00:13 -0500 Received: from mail-40131.protonmail.ch ([185.70.40.131]:26746 "EHLO mail-40131.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231261AbhBKSz6 (ORCPT ); Thu, 11 Feb 2021 13:55:58 -0500 Date: Thu, 11 Feb 2021 18:55:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1613069716; bh=wCw8cavtLqeebztLIscnnEE229I5U5y2doZiTxqDwrI=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=IutA6USnGqplNzr+dTRVaNvChrYr47gEhWFo7H+RX68nTRzH+wJLQMxYt6H59KX/6 6VfbgF9bGDEjPg+z8QlBgvDwuNGwr/OGyV0qUaPsit7LtMI9eLyOr5qJz4e/izHYw3 PNwT700hI1K3Wb9Zp9edwI03AIyZJyjE8S4cvUOCelbWJeN153CviVwYlMljTHgck/ F8yeBU8xWjjYSgntMQe4LtX+qgpT+XAUHT91b0seU97euBmjHlqeYvEq8E9aV9W71R TCSE3yK3XI8Q3DEfS6CNufRxgG8d/S6t35wNhURixpKFixbyQpdfqXIFwWslvwmYQQ 7BBiRVGWA6v4Q== 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 , 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 v5 net-next 10/11] skbuff: allow to use NAPI cache from __napi_alloc_skb() Message-ID: <20210211185220.9753-11-alobakin@pm.me> In-Reply-To: <20210211185220.9753-1-alobakin@pm.me> References: <20210211185220.9753-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 a0b457ae87c2..c8f3ea1d9fbb 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