Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2387274pxb; Thu, 11 Feb 2021 11:01:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWaMBZ8LCdATyIRu6V+xU0RtxZwtfn+1r/sfnC7tKLS53ZP0QTIFXWG0yqmLEAXpdWy5cN X-Received: by 2002:a50:d51d:: with SMTP id u29mr9580001edi.167.1613070081717; Thu, 11 Feb 2021 11:01:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613070081; cv=none; d=google.com; s=arc-20160816; b=QRxckmD+n/i9SNkILfHp8pN6wYwSM23nE4rZZJx85gDZAAMCoH/se88pQluTmN8Y29 zFTFV+npJzpU8rRMFwE+YcZIKRqlfWQ1dunlZAn7ddkU+kBgKkKV/RgKhMNGAw4aBGvX FAcgR7COuEJE68D2gyJVvi4i5Qy280fHu9B4G9lSCBgq6U1q6llMseuGEYW5JzjqrDHS UstLqdtYIOaSsLOsVM+/Byou1b538BAOt6oOsH0jGsH5vrDpOIgEzEu9qEseHfurGNQb 1AB1H/gG4jw57RdCV7kx79+NUUzg14pK6PdzvC+9XSUMzwZOkGpxsg2mMYSxeOhSODTs uP9w== 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=j1rk9bI8/1r3vSh+cqMep7Uk8zZoNgi08q3LmwT0PBBmKZuk2mDnfZoG/Lxeffj8GH e/tL2+RcMa41O7Ft8vgVgY6meZs/XmAHPrxs8aocAuD3zLFLCPlcEK2nW3KpDLZ/tYYb 2iRnsOU1Z3vsZBVZ77Yf1WjvL4yNbQ1UkWCqL2YN78qPOWgkm4fTl24Rr+UbtwnNGisP BxJUQxd84N3Yx3EajzIJ2MATlEvS7ea/+OukRSUcXPOMSAI/eterbYCywddx8OH8piVy mJQ9WO3waPtV2d0MI6EAcI2JsS6ABdxjQ77OC2LwTTJ+1c3vBAznZ5nTvkg/Oit889is CcPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=OcEKXvc9; 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 ku7si4357017ejc.143.2021.02.11.11.00.49; Thu, 11 Feb 2021 11:01:21 -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=OcEKXvc9; 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 S231355AbhBKS43 (ORCPT + 99 others); Thu, 11 Feb 2021 13:56:29 -0500 Received: from mail-40133.protonmail.ch ([185.70.40.133]:64080 "EHLO mail-40133.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230198AbhBKSyp (ORCPT ); Thu, 11 Feb 2021 13:54:45 -0500 Date: Thu, 11 Feb 2021 18:53:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1613069629; bh=vHu/tYcVI950QN5Rrw2gSn3oUyiXAKr/E1pyrHPMHnU=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=OcEKXvc9lB8MZ7pLpGYPZww1FfVTPZ9/MNWqTIsjPziumYZg3wMt5NpN/dGqCm66S 7JO8uX4vfg42nNGSI4/QicWPVC7jt1ztwi+ZrAG5FGazf+LOPNnHinkkgukPwM68Gc QS+jhR1W5act17EiDGsfoWTiYsPE/o1ij9kfoxxkuHYPLINrgcpfuZ82XXGbVdVjgr FE4yUYVGVAoULOLIFflu2lEs/bXN1mXi6OG3++6+4fZBrKxz/tqGj/R2f6dRGCA5U6 QCSsiELAPjC7KzQy3J0PcADTHXs7IQ1ZFaJhbwJeI44Q/yrnJmg+LFwRBoPpEMM5L3 hxx4+l8QAOzYA== 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 , 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 v5 net-next 04/11] skbuff: simplify __alloc_skb() a bit Message-ID: <20210211185220.9753-5-alobakin@pm.me> In-Reply-To: <20210211185220.9753-1-alobakin@pm.me> References: <20210211185220.9753-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