Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3695462pxb; Sat, 13 Feb 2021 06:17:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+bPhfxvlk6jyS6qE31udicLPlryUp3drzZITV36C4G0jWqLxS/ByfUfgnlZ/tDnQZlW6g X-Received: by 2002:a17:906:a3d5:: with SMTP id ca21mr7838770ejb.192.1613225822118; Sat, 13 Feb 2021 06:17:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613225822; cv=none; d=google.com; s=arc-20160816; b=v20lO8SxLtiiUjVUGQ/Un0TeZGqo2b5bfcoqumWS6YsrD2cQW/VAofYNYgHTEPP4ST Qz9aZEgRiE38/FR+TM1jSDtX2vSwaKggj0H3a5EhpWlPbV6EhwxVEe27PZDBMsO2vcgw F0/e6wFDPoFo7TecLMtfS8QjQY11nutMLWpeL9/hwIrLO/XV7qulaqT7SfDZ4DnOHi09 sUy5i/lSumvg51JI+zcX48ckPTaAX/OQCseBhSm3CJ1hq65VHJDcd5usdPp9HgI0lz/n GmM/QQfb8mZLtzJQL64wmJuzDScz6YOkDaXVzCIFX9MEcDxV8zAAGB5AAFgFZg9Nlm0O g//A== 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=XcoeLd366G89wSm3eqWqLusLpIaiuDr+olYNvqLW1CCs33jQpap20XcKOtoRe37+8P xy2+fMHZZTJPeAVmS7SZNnJ9DP5yjbmGI2DBwx6z0o99GhJRzkbAqpfu/SG0OBAdZtuZ uN4ettmm+WChWParW7gXCiVpaoMNrMfiDrZdSvSCRM/r9WUQ0O23lMs99A+eWdWd3RRq 32eAT8w4SS8gX8MZvr9nBQqGQk4P2j/FwNrsIMqOrjbRah7isYUNLNkYnBGuidecXofj /gGnsXl6mLekj0U2OIuBVCPIU+K8pilaWqHJRAOoSuYDtPRKkITC3NWgY9VJ8h4aGXtY QaHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=S5c2D1RY; 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 h91si8865083edd.384.2021.02.13.06.16.38; Sat, 13 Feb 2021 06:17:02 -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=S5c2D1RY; 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 S229948AbhBMOOX (ORCPT + 99 others); Sat, 13 Feb 2021 09:14:23 -0500 Received: from mail1.protonmail.ch ([185.70.40.18]:15096 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229865AbhBMONF (ORCPT ); Sat, 13 Feb 2021 09:13:05 -0500 Date: Sat, 13 Feb 2021 14:12:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1613225542; bh=HZHaNJCAig0YSUt683wmcffffm0YebCE8doSL87HOwk=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=S5c2D1RYyY2ihUOqrHkc+DHB0YnrFkMvSb1xI0O4iX0q3O1RrEiDkq9kc08bnk1nM Ha0mxTrC3WTDynilSCnxOj8yfu7y1N7ynDhjkB6GZBz9899jHxd7bJgpnBZdpgezlZ LH5iH+n4Ze3nfhyx3h10jmzZJjVTK9vE53ORoGpml7y7i38vAnPSEC6/nRqMzoqGDe 4aFiH8h7EX51Yj/MjK5+qnAjKPCO6chvfh/RNohDhLfMve1R0uL71DtInOIJH3fgJh R2hp6/F/9d4ALUBm9JeWFoDXil6/CdxJNqIOqNuAmF66ENeENAu402/e+Nel8lt4Jl 9KZm60uoM/3vA== 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 07/11] skbuff: move NAPI cache declarations upper in the file Message-ID: <20210213141021.87840-8-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 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