Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp87331pxj; Mon, 17 May 2021 21:44:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzweLdR3Hhwav/ezCVa4b+G5RzTgAf5Cbx8dVV6VGWqaWrlbzPaNO3i3fZqKIwxCs84aRN8 X-Received: by 2002:a05:6638:32a8:: with SMTP id f40mr3549004jav.84.1621313059963; Mon, 17 May 2021 21:44:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621313059; cv=none; d=google.com; s=arc-20160816; b=pwHakiAh4bGknc84mFWdNmHs5gh+UdSWqNNmljDuENwmsvO104GZ9Es2x+M6ww4He/ j6jVtp/Cfagwusmu9ZqizwkfuM8kXT52evto+l5umKFodFniyuLTsHqtRqIP01vc9Dvp wNq7YXxnXwVYRQgDHw1cwvbHjEQPRa93fqUzScTWCckqa/tNfWbHE/kXVJNS55W0T9Up PwrONiGLvZOHgy7Dvs5PKw5dshaf02UX87iSvq+rKk2t/7O7XK1VHt7kAz/UXkF54POh v3A3FmvWIIstk9jgevrx7M0HYSkbg6/bVuQPq2lRzrIEJQxP8y5Gi/9MZPndap8hG9J/ Ccsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+etklaO9vkFUBnNppWvW4wT/pFgZKsFAvZPj7+HIov0=; b=IK9F8sb1HHsj7bBMsCpw2OCjoeJKCMAB4xQybezOOdBTyJvFJRgyKYXab59Qqlp/+p 6Ak50jm7cmbfohpvH0OrOdkI+V//f+mfhUgmDOkjHvLmP+BF3+OPWnC6vgrZA8nIZPh1 w4gBeqKJBQ2H4BsAapTYMmwLIQQfWi9nW7DmQ46Jch7L/Cd5ScjpKbeGRwGM7GaZ1BTi J0lM9tXAOeshNWLU+a19gxKxGyN42PSU50d/AcBAsdM+kp/L4XwdBkKXRm0erKL1ptPq SFaJzmSue/Ma/gtLRBsACQv1NvHhIzMJDBh2sNCR6NBd4hxtqmvGy8EgulZ+46sCuSVc OPFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=zpD4UKF6; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s18si20568511ilh.102.2021.05.17.21.44.05; Mon, 17 May 2021 21:44:18 -0700 (PDT) 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=@lunn.ch header.s=20171124 header.b=zpD4UKF6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240205AbhEQOmn (ORCPT + 99 others); Mon, 17 May 2021 10:42:43 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:43896 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240959AbhEQOgz (ORCPT ); Mon, 17 May 2021 10:36:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=+etklaO9vkFUBnNppWvW4wT/pFgZKsFAvZPj7+HIov0=; b=zpD4UKF6csA6gWp48EJrtM/Jcv pr7Ed12Me36Es1mhkIPUQI9CBD7Sqd6mSIVYVSGi4JtlVUhHPk+SPqr9NxuKQqsIUg4vi4+ynw3Ix AEGn9kD+0a4htguaZTizw+/0CSrCsLhA+setHgH0Fm4heqTWKbybbmOQVAzf+DhTgPj8=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1lieL2-004ZSU-Np; Mon, 17 May 2021 16:35:20 +0200 Date: Mon, 17 May 2021 16:35:20 +0200 From: Andrew Lunn To: Xianting Tian Cc: mst@redhat.com, jasowang@redhat.com, davem@davemloft.net, kuba@kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] virtio_net: Use BUG_ON instead of if condition followed by BUG Message-ID: References: <56270996-33a6-d71b-d935-452dad121df7@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56270996-33a6-d71b-d935-452dad121df7@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 17, 2021 at 09:31:19PM +0800, Xianting Tian wrote: > BUG_ON() uses unlikely in if(), which can be optimized at compile time. > > Signed-off-by: Xianting Tian > --- > drivers/net/virtio_net.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index c921ebf3ae82..212d52204884 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -1646,10 +1646,9 @@ static int xmit_skb(struct send_queue *sq, struct > sk_buff *skb) > else > hdr = skb_vnet_hdr(skb); > > - if (virtio_net_hdr_from_skb(skb, &hdr->hdr, How fatal is it not being able to get the header from the skb? There has been push back on the use of BUG() or its variants, since it kills the machine dead. Would it be possible to turn this into a WARN_ON and return -EPROTO or something? Andrew