Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp908727pxb; Tue, 9 Feb 2021 16:19:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCeMwBz/2joqagDFOYKBbXohAWwCkEUOUGvhw3PSRa+Kz//hTcTMH6nFHqvIDzL65Dy0hv X-Received: by 2002:a17:906:eddd:: with SMTP id sb29mr240058ejb.383.1612916360023; Tue, 09 Feb 2021 16:19:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612916360; cv=none; d=google.com; s=arc-20160816; b=PUe8435sORJwNdHs0fdIxIkr6dq7RbuviMsb968H40Rm2zM9xE60Xqj8/NJi2LeK4a 9o9HPZq54ddzKinO17iF7gxVT/VYDmeO57xTgV10yLWuI7ep/rOZ2modzpHoCvPoEfbY sCEK4AnJkaMJp/V3tyaGwkgb/E2QJ5QHY529t7iepe7IGv4FQ+OqnBjhnNMeiUbPm+sZ 6lZas6rLn+hWWebBVEV34ww1Dra4jgN8UkMgEo6pYvujJoreUwa3c8yiDFrI4mRu51wZ HSGfSMO2jtZgQjaZyOVjRHssWB2ipaxDgD9ZlCCuWkVx8Y2lpXRU559VnQqml6N7BAqU 1DkA== 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=b/V72/ecFuIE5O8hexSZT3uuOukgCm1wtsY9SYdVkY0=; b=CqbdmKiDyGwufIrEyd2rU1tqUqKXAzZBfsolGX79eJhbj7QeEM1mUQvuki4MUMacT5 REZH/QelSM96KSCYj8IE6ObvlRzVohKXjfxsmTEAosy3FC1CXcNxdneciR3SEkX+NDSm lKf9Y49bNIV98s+WH/DbetKPifzrRZVcwVvGdlDqwNN35SQTIZbNxhgnt5yEs9H3NpIJ hf9/efKnNv5W5kUReAEc/PU7D9HAwB/uHcHc7G0euXMntGBYpDcyKi2yNWJpdoTW+qsI WOSSKC0mg0Ny8MFVI/prvj4g8yuOE/DyDw65nvuXmI2SoMVH9kSP4R/o/B61/3Eh6+dO 2GTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=JnuH+cQZ; 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 bl4si188633ejb.47.2021.02.09.16.18.54; Tue, 09 Feb 2021 16:19:20 -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=JnuH+cQZ; 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 S234284AbhBJARi (ORCPT + 99 others); Tue, 9 Feb 2021 19:17:38 -0500 Received: from mail-40134.protonmail.ch ([185.70.40.134]:35503 "EHLO mail-40134.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233483AbhBIUtJ (ORCPT ); Tue, 9 Feb 2021 15:49:09 -0500 Date: Tue, 09 Feb 2021 20:48:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1612903687; bh=b/V72/ecFuIE5O8hexSZT3uuOukgCm1wtsY9SYdVkY0=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=JnuH+cQZfyOm/8T7Ha9GM8GYAketexyUteS/Kgj1numcPsfdWlVErX3JaIYy6i5hL 0UG/IdexzfKUFpDpI6vYEOYxYlZFx+sMHpZkm4wIVJ4Bh5g6tiOjr74aGjtt6C1bJw Hd5/BI5Ny24LNouxRZb9Jcm2cVFuLqvoIpiUAaRHZDKfYquSicoNxNoCnNQlew4XJ1 H+cYt9y+agPAkH5G4F5s6cP4Q8W1njpGYxR/wGCuTuj/Hy9hZMJQ/32PBVJRcyrthX 28fxyVik5JpQByp/XeCVDSZJtkgK/hyg1/oMPQSybffYMmIyNXXQBX+wBtMDs5BfQ7 TOVYoo5Brq6pw== 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 04/10] skbuff: simplify __alloc_skb() a bit Message-ID: <20210209204533.327360-5-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 Use unlikely() annotations for skbuff_head and data similarly to the two other allocation functions and remove totally redundant goto. Signed-off-by: Alexander Lobakin --- net/core/skbuff.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index c7d184e11547..88566de26cd1 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -339,8 +339,8 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gf= p_mask, =20 =09/* Get the HEAD */ =09skb =3D kmem_cache_alloc_node(cache, gfp_mask & ~__GFP_DMA, node); -=09if (!skb) -=09=09goto out; +=09if (unlikely(!skb)) +=09=09return NULL; =09prefetchw(skb); =20 =09/* We do our best to align skb_shared_info on a separate cache @@ -351,7 +351,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gf= p_mask, =09size =3D SKB_DATA_ALIGN(size); =09size +=3D SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); =09data =3D kmalloc_reserve(size, gfp_mask, node, &pfmemalloc); -=09if (!data) +=09if (unlikely(!data)) =09=09goto nodata; =09/* kmalloc(size) might give us more room than requested. =09 * Put skb_shared_info exactly at the end of allocated zone, @@ -395,12 +395,11 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t = gfp_mask, =20 =09skb_set_kcov_handle(skb, kcov_common_handle()); =20 -out: =09return skb; + nodata: =09kmem_cache_free(cache, skb); -=09skb =3D NULL; -=09goto out; +=09return NULL; } EXPORT_SYMBOL(__alloc_skb); =20 --=20 2.30.0