From: Sebastian Andrzej Siewior Date: Thu, 20 Jun 2024 13:21:53 +0000 (+0200) Subject: net: Use __napi_alloc_frag_align() instead of open coding it. X-Git-Tag: v6.11-rc1~163^2~147^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=43d7ca2907cb0e8a23d73934a5cf000e24b0aa22;p=thirdparty%2Fkernel%2Flinux.git net: Use __napi_alloc_frag_align() instead of open coding it. The else condition within __netdev_alloc_frag_align() is an open coded __napi_alloc_frag_align(). Use __napi_alloc_frag_align() instead of open coding it. Move fragsz assignment before page_frag_alloc_align() invocation because __napi_alloc_frag_align() also contains this statement. Signed-off-by: Sebastian Andrzej Siewior Link: https://patch.msgid.link/20240620132727.660738-4-bigeasy@linutronix.de Signed-off-by: Jakub Kicinski --- diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 2315c088e91d0..1b52f69ad05e2 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -318,19 +318,15 @@ void *__netdev_alloc_frag_align(unsigned int fragsz, unsigned int align_mask) { void *data; - fragsz = SKB_DATA_ALIGN(fragsz); if (in_hardirq() || irqs_disabled()) { struct page_frag_cache *nc = this_cpu_ptr(&netdev_alloc_cache); + fragsz = SKB_DATA_ALIGN(fragsz); data = __page_frag_alloc_align(nc, fragsz, GFP_ATOMIC, align_mask); } else { - struct napi_alloc_cache *nc; - local_bh_disable(); - nc = this_cpu_ptr(&napi_alloc_cache); - data = __page_frag_alloc_align(&nc->page, fragsz, GFP_ATOMIC, - align_mask); + data = __napi_alloc_frag_align(fragsz, align_mask); local_bh_enable(); } return data;