Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2386285pxb; Thu, 11 Feb 2021 11:00:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIUM2Z/i6hGT4e8qxRG2BRZpIqzLDG7d8BGtLAcBI8s+SyUW8RzmU2Bv70Fdt9EmzgtFuO X-Received: by 2002:a17:906:27d8:: with SMTP id k24mr9586825ejc.339.1613070005809; Thu, 11 Feb 2021 11:00:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613070005; cv=none; d=google.com; s=arc-20160816; b=U3y/vIbPPMxGS3sTgwMm8nqPjjRs9enFA4A35Jp9frRXIFSG+vjxD+Hvan62nFxgc6 7aII2YO9+or9iAMLwl1AvCGdfZyamhxfuacXBECtWLtl6M8zEhyvwRhZTFh7uFou2HEu 728pwnMm6ofFV0oZOZDxZGXOTSMthZkk3aLCSC3T+M5SWXn4WrhSi9rM2hDcia4KXiE3 6iRgSSLWr09yVNbFaFbn+Ko6a8sK6zAU9NOIYHvHVQJjI0B1mrtJ7D49IxBYHTyidN74 56X3fjiO5B+t5GpM8FJQPSLJjRrXdmUGNRaHGZAISuEVEsgSntyDApOosZwSq8TO50mG JMFQ== 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=HZHaNJCAig0YSUt683wmcffffm0YebCE8doSL87HOwk=; b=IxR1TN9TmMTS9YAGerSMuBT1wODU3Eg27p4nzLzjH0IYq5p0imlOEFrFDAZJumzE3Z 57A9K4E8Q0+tQgetEg/LkA4eqD2P6gSlJprdhKJmg0BmTnlplnr5gnnruBEahkJea/OX Z47K/+AccxjWrAP+hQ9nSs6yBBOmn1Zlp9rcL2apPpKSbIM2Y86EmUE8seGpClwS8Hdn mNRImaD9SmkD/UQDlbzH9d+B7Kqr1G0TqIhnd5SmtRqSb9Cxq+Fnru5v7+b2a2dVIYo7 zNyLldYlLRFKTDqkG+GYs3LdncYeeAzkV1k5CFj3wcnKP7BNrohSuFWR67whCJLgPnM9 61tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=WFZYdhZ+; 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 c10si1960053ejx.332.2021.02.11.10.59.33; Thu, 11 Feb 2021 11:00:05 -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=WFZYdhZ+; 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 S230246AbhBKS6z (ORCPT + 99 others); Thu, 11 Feb 2021 13:58:55 -0500 Received: from mail-40136.protonmail.ch ([185.70.40.136]:39029 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230523AbhBKSzQ (ORCPT ); Thu, 11 Feb 2021 13:55:16 -0500 Date: Thu, 11 Feb 2021 18:54:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1613069669; bh=HZHaNJCAig0YSUt683wmcffffm0YebCE8doSL87HOwk=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=WFZYdhZ+QV9iTuY3nKJ8PTEk4Qdb7iPGcCIwp4KXl7plTZDEAhdlrbOfgvx+s+gCm 8vCwwSj/2/29NINeRzC0pwrojspe/wBBRLK1gcVhqABQzYbgTIREUL2OUza1+Y+5Tb WxCmPxbmkQkKWGFkC/esA5fjUmqCZ3bNO9vlyv2lwHYh4lV9W4772LqzdJWzXVNkfE R1/o7CxdB11y4HqaWqaMi+K13Al0St8JhTMoSnn9l7pAZJlNp+5Bpwv7mLnM4j465U xzfGGH3bJ6O6fdtTeUZAZBMSVzwbwG/u6twzcuHUmeYLVKmAeeCBRM4I8GyPBR73vX RfmDFCGgPRyVw== 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 07/11] skbuff: move NAPI cache declarations upper in the file Message-ID: <20210211185220.9753-8-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 cache structures will be used for allocating skbuff_heads, so move their declarations a bit upper. Signed-off-by: Alexander Lobakin --- net/core/skbuff.c | 90 +++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 4be2bb969535..860a9d4f752f 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -119,6 +119,51 @@ static void skb_under_panic(struct sk_buff *skb, unsig= ned int sz, void *addr) =09skb_panic(skb, sz, addr, __func__); } =20 +#define NAPI_SKB_CACHE_SIZE=0964 + +struct napi_alloc_cache { +=09struct page_frag_cache page; +=09unsigned int skb_count; +=09void *skb_cache[NAPI_SKB_CACHE_SIZE]; +}; + +static DEFINE_PER_CPU(struct page_frag_cache, netdev_alloc_cache); +static DEFINE_PER_CPU(struct napi_alloc_cache, napi_alloc_cache); + +static void *__alloc_frag_align(unsigned int fragsz, gfp_t gfp_mask, +=09=09=09=09unsigned int align_mask) +{ +=09struct napi_alloc_cache *nc =3D this_cpu_ptr(&napi_alloc_cache); + +=09return page_frag_alloc_align(&nc->page, fragsz, gfp_mask, align_mask); +} + +void *__napi_alloc_frag_align(unsigned int fragsz, unsigned int align_mask= ) +{ +=09fragsz =3D SKB_DATA_ALIGN(fragsz); + +=09return __alloc_frag_align(fragsz, GFP_ATOMIC, align_mask); +} +EXPORT_SYMBOL(__napi_alloc_frag_align); + +void *__netdev_alloc_frag_align(unsigned int fragsz, unsigned int align_ma= sk) +{ +=09struct page_frag_cache *nc; +=09void *data; + +=09fragsz =3D SKB_DATA_ALIGN(fragsz); +=09if (in_irq() || irqs_disabled()) { +=09=09nc =3D this_cpu_ptr(&netdev_alloc_cache); +=09=09data =3D page_frag_alloc_align(nc, fragsz, GFP_ATOMIC, align_mask); +=09} else { +=09=09local_bh_disable(); +=09=09data =3D __alloc_frag_align(fragsz, GFP_ATOMIC, align_mask); +=09=09local_bh_enable(); +=09} +=09return data; +} +EXPORT_SYMBOL(__netdev_alloc_frag_align); + /* Caller must provide SKB that is memset cleared */ static void __build_skb_around(struct sk_buff *skb, void *data, =09=09=09 unsigned int frag_size) @@ -220,51 +265,6 @@ struct sk_buff *build_skb_around(struct sk_buff *skb, } EXPORT_SYMBOL(build_skb_around); =20 -#define NAPI_SKB_CACHE_SIZE=0964 - -struct napi_alloc_cache { -=09struct page_frag_cache page; -=09unsigned int skb_count; -=09void *skb_cache[NAPI_SKB_CACHE_SIZE]; -}; - -static DEFINE_PER_CPU(struct page_frag_cache, netdev_alloc_cache); -static DEFINE_PER_CPU(struct napi_alloc_cache, napi_alloc_cache); - -static void *__alloc_frag_align(unsigned int fragsz, gfp_t gfp_mask, -=09=09=09=09unsigned int align_mask) -{ -=09struct napi_alloc_cache *nc =3D this_cpu_ptr(&napi_alloc_cache); - -=09return page_frag_alloc_align(&nc->page, fragsz, gfp_mask, align_mask); -} - -void *__napi_alloc_frag_align(unsigned int fragsz, unsigned int align_mask= ) -{ -=09fragsz =3D SKB_DATA_ALIGN(fragsz); - -=09return __alloc_frag_align(fragsz, GFP_ATOMIC, align_mask); -} -EXPORT_SYMBOL(__napi_alloc_frag_align); - -void *__netdev_alloc_frag_align(unsigned int fragsz, unsigned int align_ma= sk) -{ -=09struct page_frag_cache *nc; -=09void *data; - -=09fragsz =3D SKB_DATA_ALIGN(fragsz); -=09if (in_irq() || irqs_disabled()) { -=09=09nc =3D this_cpu_ptr(&netdev_alloc_cache); -=09=09data =3D page_frag_alloc_align(nc, fragsz, GFP_ATOMIC, align_mask); -=09} else { -=09=09local_bh_disable(); -=09=09data =3D __alloc_frag_align(fragsz, GFP_ATOMIC, align_mask); -=09=09local_bh_enable(); -=09} -=09return data; -} -EXPORT_SYMBOL(__netdev_alloc_frag_align); - /* * kmalloc_reserve is a wrapper around kmalloc_node_track_caller that tell= s * the caller if emergency pfmemalloc reserves are being used. If it is an= d --=20 2.30.1