Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1450002pxb; Wed, 10 Feb 2021 08:35:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/zVgMecYkzyGkX7bwSw0rh4n0YOJUgohU3roqL+JZFjs/ou/JJ7Ar7P6XmctaiJLOm4PV X-Received: by 2002:a17:907:75c6:: with SMTP id jl6mr3611712ejc.243.1612974915799; Wed, 10 Feb 2021 08:35:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612974915; cv=none; d=google.com; s=arc-20160816; b=J6xKGs7Ql2M5VR7fn9O3psZfr6qFS0T+6DZGIiAn9lPOORivmCx9L6aC5XpcOvBMHR W4PkIcFCzH0gOJilqU/lljewaUTl7N635kM+NYOrOTDKhYIJhwpPA4dimy6HLnSjXP8S ijKQfrzF+nBOef125EARkgaVE12t49UBD/7YsqrLb2V7ZoTPUpl95xmyyFZUkGjLmdLc HAbnGvzoDleAJ9rMNoQ2lwFgSsH+x/Y8XSNWX6MI2uMHty2Z+ZzuPc0fMiONAVTO51PD XgreEbrbE9UKG16m4NbErNYtXJX1xmUPydqvvspUxAwt757VRk821Rp+zLR/Fu4Rbb3L 06Qw== 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=vHu/tYcVI950QN5Rrw2gSn3oUyiXAKr/E1pyrHPMHnU=; b=B1QRp2S8IcURpdm12YzJZU+ARVp2GFYJxsGar2ft3RTO+7TK0bnk0f33XSwMChufZ+ nWKLrrH5UegW9C+VG7RErBMmOFnodKHmCcIXrnjQFDRVussdoX68JNRA0YWXMBmENv64 Blo+u/AG/qysPiJltGhyBSAjSv/gOjiuWshVZvtrlPA0P/Od6alhYQlhi+rbxfSpu41S uEbMJL65BaWmTwmjx+fcSYrGLQlrtQEfqkC6F3udpRvII2EuBr5FW49e3AEupCS4/xSZ 3PnAybXn54ybiYGVKsy7Qxqb+bMT48YCizzAzPya/11BN3PRt1GPp3nKMbRQqdYbI/hM tq8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=X2mB14Zr; 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 b4si1045993ejv.540.2021.02.10.08.34.52; Wed, 10 Feb 2021 08:35:15 -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=X2mB14Zr; 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 S232468AbhBJQdq (ORCPT + 99 others); Wed, 10 Feb 2021 11:33:46 -0500 Received: from mail-40136.protonmail.ch ([185.70.40.136]:20594 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232537AbhBJQae (ORCPT ); Wed, 10 Feb 2021 11:30:34 -0500 Date: Wed, 10 Feb 2021 16:29:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1612974568; bh=vHu/tYcVI950QN5Rrw2gSn3oUyiXAKr/E1pyrHPMHnU=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=X2mB14Zre1cBumX33fMkvOTJrgIUhnlZlMNHlZEncYmFJReS5ErVDr0Bp9B0D3mGO 7H+gj7Gpe1uh3P+QB8yv5oSLYY2z4oW3xM2BdrpOxRZ5uyZ1S+PiG5dWknocuaqhqJ lUr0uH2xWyo0z8AiHzONnplhpbtJAm0CHHgSimMq+jYz8eFsskMee/B9+HebJe/qYM ArD4Z1m7p06IOoQOeEgSgmzerc9pVnwQjakxYyL7sMkrCvE0sW5cNiS8hhc+g2juD3 3p5cU5hh/AoLLWVWAQJn1ae4ciutBOzwdM4DW2p6ao6UylqERj9GDe9G4KCbenhagN TfaNWejyoMgPA== 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 , 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 v4 net-next 04/11] skbuff: simplify __alloc_skb() a bit Message-ID: <20210210162732.80467-5-alobakin@pm.me> In-Reply-To: <20210210162732.80467-1-alobakin@pm.me> References: <20210210162732.80467-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.1