Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1650475pxj; Wed, 19 May 2021 10:37:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUNRNz9vaX+mH8ASK5cP3F6swInzARtbb6d44PKouMQ8JNcjP0j+Sm9ZlGSV0B5Kd1AZ+W X-Received: by 2002:a17:907:1007:: with SMTP id ox7mr346329ejb.82.1621445868903; Wed, 19 May 2021 10:37:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621445868; cv=none; d=google.com; s=arc-20160816; b=cNk5+2KgtQQMF2yPjPA80Ocd8zu3ATJBlRLLiIZD6st1C5GutLJLJG6W/LOswJCrlu DT3jX5AGUoHDxBR86mPtrrfapD7oHpk75rP8iZyO+XlVG22WOREMY5+1ROigdMbdAW+d 3BS6szecJL09t9SezRGdlqzHnlxlU4P9HZOZca2VxDLPvBBRrGixJYjJTuQRm9Vcn32q 0/IEWPCb4K2ZvFcTjHQMN15EVZeyP+WZA7J5LDXuMIZmlOqWekrkc05qwmNKR4N0fhWi KETvt6HAkpO7e2E/BRcUs0UBZGLJ+QRYy0ziYZgFuMD7Iq77feglPpWMuqOHm473MF95 Vkug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=Jf3oVauX5ah6pwCedZ+y7V++uaDTOFcSw4KA11z6FUg=; b=UZ/5vIjEtA2WCbPiiozXw/bmOd+oLTViUyXCyBzkwh1XfTyy9PoOauvwk/jaF/fdlQ HgglsO2MzrLY2y1i33r3ilNUc3sC2qWYSqQ2c8sab2/6dxehyzaHq1GxNDK0bbZQ/IOb 3/SANDkVxqeP93eEcG01BHGwUEQEaEOnp2hPNTR/rWtKX8TtoOAmyq5zS5Ml3NtQ1YLG xKb5gy/gaFHSamwLxMB9Hsszuj2U8VGhLcYUHnsN/AUt+PTzvpGp2JyAd6/XEpaTLII9 3E3G8LfyOPXHsOeYIQvEOtVDb10BAOg+hq++wx1Pt4ikhDYtKgU6fU7nF5jAZ7xhyFua 3SvQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ka15si349162ejc.148.2021.05.19.10.37.25; Wed, 19 May 2021 10:37:48 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347728AbhERJWA (ORCPT + 99 others); Tue, 18 May 2021 05:22:00 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:50484 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238036AbhERJV4 (ORCPT ); Tue, 18 May 2021 05:21:56 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0UZII4qy_1621329636; Received: from B-LB6YLVDL-0141.local(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0UZII4qy_1621329636) by smtp.aliyun-inc.com(127.0.0.1); Tue, 18 May 2021 17:20:37 +0800 Subject: Re: [PATCH] virtio_net: Use BUG_ON instead of if condition followed by BUG To: Andrew Lunn 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 References: <56270996-33a6-d71b-d935-452dad121df7@linux.alibaba.com> From: Xianting Tian Message-ID: <32044caf-8da4-8bbd-86d6-693ab284351c@linux.alibaba.com> Date: Tue, 18 May 2021 17:20:36 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org thanks for your comments, It is a good idea, I think we can follow the similar logic in function 'receive_buf': if (virtio_net_hdr_to_skb(skb, &hdr->hdr, virtio_is_little_endian(vi->vdev))) { net_warn_ratelimited("%s: bad gso: type: %u, size:%u\n", dev->name, hdr->hdr.gso_type, hdr->hdr.gso_size); goto frame_err; } I will summit a new patch later. ?? 2021/5/17 ????10:35, Andrew Lunn ะด??: > 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 >