Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3696873pxb; Sat, 13 Feb 2021 06:19:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJy2RaFvK+hZI72+TRDX0vAjKYSmHsdKOW9lTE83A/PBjE1UA/mcADGebiteCHde8TxZDsZA X-Received: by 2002:a17:906:5e59:: with SMTP id b25mr7688334eju.536.1613225971180; Sat, 13 Feb 2021 06:19:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613225971; cv=none; d=google.com; s=arc-20160816; b=zbyc6pJ6Ywk6/L8UrB7sA6iofm7C+JdJukN6RwgJ2pVz3JDG84PSkB3cPLMC9VNEqZ XhFAEiPa74suzdOreUaMasSd3KufxmFXkD2ih0bL4OXmskVBfDQZhmzDLBY+sXaEpZbb KWxpddYubXAXAFScrgqqpMek8j7tLVELY62ISWtmsYMAY0E4m/rU9XKZZ5Hbw/aU1py5 g/vH7W68GR0eTy80PHKpN0n31hqczJM5Gq59bpIUvDh82AB4f8+mtpPuIM1xKVvf6t4i JRv4hjv9IaJMnkqvJhrQnrgL2s6qdVtX+R5t1IxPFRcIia3GNJl36WRcoHAprPtTDPXN 1T9A== 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=3aXvGlMYhjuYNoMv1QkUBlOKt06EtJNy+kSzarvpakw=; b=Lse+hen2ThIYXDCCwgu34sCBftZTJm/LfO4Amt+dZeG29ZGMC9AuIglw4ovGU7Danj /flBI8R//caRA56njXsKKNlWMup9LZn3WQhJmTFrEMG6eZMl1UJcbZd0++zP8xyX6d7b 65I+X4Nim/Si83wFKGeTvXFoFo9XC2sJJ44An96iaReEGxyGGKT8cZW0TbEaCnVaseEQ F6YbbB8x8DBo2YzYybsd2auJtGIBr5a7CJRoBoAg8RgtFhNxvyxteCws39vTd9NoeHTh x2MhMo5/9rlqgnKUjsO5LUdRRwJND7B4jWBvYX16IiwGQVObzNP3y49gYgvqQjqngo1E 3Cyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=B+oH2yjq; 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 c63si8152898edf.24.2021.02.13.06.19.08; Sat, 13 Feb 2021 06:19:31 -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=B+oH2yjq; 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 S229959AbhBMOPj (ORCPT + 99 others); Sat, 13 Feb 2021 09:15:39 -0500 Received: from mail-40136.protonmail.ch ([185.70.40.136]:43384 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbhBMON0 (ORCPT ); Sat, 13 Feb 2021 09:13:26 -0500 Date: Sat, 13 Feb 2021 14:12:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1613225563; bh=3aXvGlMYhjuYNoMv1QkUBlOKt06EtJNy+kSzarvpakw=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=B+oH2yjqSGCqjT4gu1JBuBQ9z3AMFtJCzINmCXl9TOdJyd3sGTxkbCuNRS0aHzaAz QoVolhWtkftZEfLL22/dzA5ggAoUpA7NPbEYkq6EPaNf0HPXaC37aWGM6o2zCl7oeO voObrpsn99pDwlXFUTRAcJMvFdjZo15IBjqoqRhtQCaEIff1a7Ah50hu9ZMc7dDPpw G1emoWviDy2PQs7IkGUOq5n119g8PBqH+zLiLG0srBl8Rt+HyM+B/77P66IHEvBYgH Ps82QbhfkbexNWUC04QmsKno1MgSDjNVAdG1n2ZEzbFxa0O1R+5CuZmbMQdQzuR3Gt TzW/4Tt8eTrhQ== 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 09/11] skbuff: allow to optionally use NAPI cache from __alloc_skb() Message-ID: <20210213141021.87840-10-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 Reuse the old and forgotten SKB_ALLOC_NAPI to add an option to get an skbuff_head from the NAPI cache instead of inplace allocation inside __alloc_skb(). This implies that the function is called from softirq or BH-off context, not for allocating a clone or from a distant node. Cc: Alexander Duyck # Simplified flags check Signed-off-by: Alexander Lobakin --- net/core/skbuff.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 9e1a8ded4acc..a80581eed7fc 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -405,7 +405,11 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t g= fp_mask, =09=09gfp_mask |=3D __GFP_MEMALLOC; =20 =09/* Get the HEAD */ -=09skb =3D kmem_cache_alloc_node(cache, gfp_mask & ~__GFP_DMA, node); +=09if ((flags & (SKB_ALLOC_FCLONE | SKB_ALLOC_NAPI)) =3D=3D SKB_ALLOC_NAPI= && +=09 likely(node =3D=3D NUMA_NO_NODE || node =3D=3D numa_mem_id())) +=09=09skb =3D napi_skb_cache_get(); +=09else +=09=09skb =3D kmem_cache_alloc_node(cache, gfp_mask & ~GFP_DMA, node); =09if (unlikely(!skb)) =09=09return NULL; =09prefetchw(skb); --=20 2.30.1