Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp909248pxb; Tue, 9 Feb 2021 16:20:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmnnL2AzGNU6bFgaulqBRmUg2xju2DyxdgypbSxntijY4E2lv3CCVhSYQ8yYDcBELbhq1Z X-Received: by 2002:a17:906:5043:: with SMTP id e3mr305756ejk.260.1612916430611; Tue, 09 Feb 2021 16:20:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612916430; cv=none; d=google.com; s=arc-20160816; b=cpW/BCRkATEZpoFQbTVHQCfOg8HAccxgyy+GOGDwTMIP9+keHAPiGDoHn4yvdYArvr hmld1h8ZAy/3R+JRpDk/RDKi3ehYr3txXjGlPOzGrdSULgPqZgn78q40SVUyexskDPZk b7X4m3GGSFYGmvqQd9GN8RXr0zJ53+P3oArrjxnFx+eLfGTicoKpCTJ7rmN8oW2BZzNt qE5+uWqQ0c6vlNeql/0S0P4Go2gM2TeHTB1kFPYskr48mfIG1BNAZbC0Co94G4wq39PW dCLsYbO50Jpp8/pZMXVxhp87SGO6JTCJ+mwRZI96Pa03d6gL9c9KpCaMHvzJ+Z+AnD5O PJ4g== 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=2ZGDTP+U1Ebxj8vWtkJrsSoHhtkyLcBn7TvjRNc6gew=; b=ivjE8rGp0bAoXz8uFIG6ig3HHQ/2hJhpNDu7kp5yqkWzFeGYWXM9RiSvZdAP+YuK2j /s7RRuBuymR3wP3Hk8czX6j3UIkOtrf7eXn0MJEdK4y761fymAYOTlmvTIFpbBuT1hNI ecXgTmLSgCGds6o+d3UNuMdPOFm2Rsb5PygktawKojvSvMgb4K2uPy4oRfVQdF93fDPV 9BcIrpgmcYcNLtMNSgDuyjKJQuBfW+yc3TE3Me9FGmyOj+y8tNNtVQmDNE5r8PS3aqoX cvlPN9nORcJugSH1btvWm5JGmXJTD/asgmaO8gvj2BQKxyCAo7iNcZcLUX7Vt5dNf23/ 9pTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b="VlKfBN/r"; 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 jx12si156440ejc.173.2021.02.09.16.20.07; Tue, 09 Feb 2021 16:20:30 -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="VlKfBN/r"; 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 S234908AbhBJASW (ORCPT + 99 others); Tue, 9 Feb 2021 19:18:22 -0500 Received: from mail1.protonmail.ch ([185.70.40.18]:64982 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233871AbhBIUvI (ORCPT ); Tue, 9 Feb 2021 15:51:08 -0500 Date: Tue, 09 Feb 2021 20:48:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1612903727; bh=2ZGDTP+U1Ebxj8vWtkJrsSoHhtkyLcBn7TvjRNc6gew=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=VlKfBN/r+GewNxB0eXUx8LKYeZatc5GhKMZhyyw6gWk6e44G+zbpeQMgWe6f6wPCW hfzy4q2QMvXBU2xTq8yXZu+uQq4Jbk7Q9a6aXjxtcJ6Ks+boM30JzLw+3DXU1u83dn dI7hYcVSW89Kj87Ij/mnikLb+1TkI7nCXNlM+syGZMQI+sSt/N5jiQVWzVE1In8NVA mymbj9ASCWyyeJF0J5zK+JDn06Vje0YfHjdI4z6xoqI/hzLxx5HQp6dc9j8xXkWILH rEZdWWrRBETwcNKqUTe3uc1EIx996qJyQ0hXfcGZ2sWBusIjIP5J5BXTA2YMZNx7j2 Cgd4bUS4ALdzQ== 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 , 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 , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Reply-To: Alexander Lobakin Subject: [v3 net-next 07/10] skbuff: move NAPI cache declarations upper in the file Message-ID: <20210209204533.327360-8-alobakin@pm.me> In-Reply-To: <20210209204533.327360-1-alobakin@pm.me> References: <20210209204533.327360-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.0