Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3695424pxb; Sat, 13 Feb 2021 06:16:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVVv0lQPg5dMRPoiLJyI+b6pIbU/yY4WmeS+oZeZO/ZmGGHhH175CZ81EpKTLNJdrZmAVo X-Received: by 2002:aa7:da19:: with SMTP id r25mr7931399eds.1.1613225817078; Sat, 13 Feb 2021 06:16:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613225817; cv=none; d=google.com; s=arc-20160816; b=wxBgxPXkf8ifuDlK8OKFtSDMW/akyjboTjU+8L/t8H3uEMz48otA1bNbHPn9+2e5la TMNkDIvA/aRVLPbZH6vmkKqqzttdPW2y2ry4Hv1vJHYjsMiQlay/lTujxkuxGum7zlqB R0sVGjTNPDnr6OhGsexl8YnVIg3ddP0rOs5loWpumnCYUagSjFbnSJclW3fOvz4Tf5FO 9LyNTx4BU0gAqLLiQCLet+lRxxI5fp/XIsH7bH5lp6P86s2/UFzg4O9b5dAUrUNbwe2v qOdI34sisa38DuJxiXJ2GU/dD8SIVF2HjIbum+zvXZaREwljz3MVERRa7COKSLj01EEs KtXQ== 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=nyns8Yb/+W5NtYGEGHzDdHwffFv3sCD+if912UTIDpciWDmgsBS+WlzvzylljLxr22 lFlDt15bJze7EG53M/EW7OuZLuQqvaAqsMcO0sedNDh7vs73JeSHB77mqbXivWjovuR7 x+l5Hs2iHKsXsi1bwAH03PHxRChJq9UUfd8o7HVeu0EBIf9EcqNXdU5wmKD3aqSn5QZq szL+FVYLeeopdU+RIQBJNFoSjLiQrq7B9qh1qS4VNvXMUEjTkcluCdXGi1T8cccR3qDS NExPLUsf7asL22Yp7PdrrLEe3JvB8wlKSM435Js9APoq0nCMZ+/+0ZOVj1knrr8CD2n9 3ptg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=BX8yXvWi; 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 w12si8680128eji.480.2021.02.13.06.16.33; Sat, 13 Feb 2021 06:16:57 -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=BX8yXvWi; 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 S229848AbhBMONA (ORCPT + 99 others); Sat, 13 Feb 2021 09:13:00 -0500 Received: from mail1.protonmail.ch ([185.70.40.18]:39517 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229773AbhBMOMb (ORCPT ); Sat, 13 Feb 2021 09:12:31 -0500 Date: Sat, 13 Feb 2021 14:11:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1613225508; bh=vHu/tYcVI950QN5Rrw2gSn3oUyiXAKr/E1pyrHPMHnU=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=BX8yXvWipAjRu6ustrMOHvWuctrR3gXwwszkh1tmaxGLke488HMm+GJkeet8X1PlD jItxCGYvmlDq3J3lqK9vNySvmChWtd2xX8Dt5LJCKfAV5fOn/cdlQjS48Ba3gD/PR9 ICRmFJ6xeMax3igE3yRJM7W1Qm1pP9Z75NpK0flPT7EppQbKHls3OpX8VQjOgsGuOE AE+z0LY0nrIVijwjycRRqOJXKWZyQLykIn9SLCB8wpA62KDRG5Uc4bh2xlMdGPARs5 E+U3HlXRk3MOMSJON8lsd16WMZroOwK7B/NqBWySpGaWPXwQzZwdKPqffesIoBsJBO rXTPoR9uTMD3w== 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 04/11] skbuff: simplify __alloc_skb() a bit Message-ID: <20210213141021.87840-5-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 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