Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85CDEC433FE for ; Thu, 16 Dec 2021 03:12:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233276AbhLPDMq (ORCPT ); Wed, 15 Dec 2021 22:12:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233259AbhLPDMp (ORCPT ); Wed, 15 Dec 2021 22:12:45 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32B9FC061574 for ; Wed, 15 Dec 2021 19:12:45 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id a11-20020a17090a854b00b001b11aae38d6so1805556pjw.2 for ; Wed, 15 Dec 2021 19:12:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dBM19LcQ01EOL1teiqLVNHuwJHdfmzghxMPx2TADl7I=; b=OP3oyNjPWr8trMDrWnkDU+KR7+tT1Od1ZsR8zIVi042GshUO1hw+MVnNpKz8oYDYYy j2rAXpYp3GBUagy+biiiXk88h7WmHleCqjBvGWddtOnPonCFYr0NUx09ew6Wk9D1AvkB gFnGZ28j+fqHEiV8wMeXrI/CkZaPoHJuZ0Jabuu4m1uisO3sYbevEoPjjv3zLWyS7hHY 1YKyBI9vN6lhMgsBdrk9+RYvFXSjSY03X2nh5VP0QPycERWRiVJqSX6DVdpShpIy/+X9 9A4zBm6I0O4qXXvmpgOzIVutPCO0SyLe5cjMuOeOtQJsHWI+gINn3N9foI5jgWP2jpaB zQfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dBM19LcQ01EOL1teiqLVNHuwJHdfmzghxMPx2TADl7I=; b=H+mcBgvRf+2VABvVZAlY++zeDiPpc4KbczqFGlKwsnBZHWrASSoo29g1K7OwUVXDVA YplhWek+oDWU30CawyXMFbIAsiiJWtmYralHyo1bykINIEP8VeIAVNkPcl5SEvdt0/a2 YsUKTXfhfA+2revCG/1JedSoNY8sXLCAdw+X8bv4So/djIkYF79rh/pooEqrCg9duqpN mIq/IFFdY+Y80v++RdMdVLzMajtcqZDXiTbA/bHGHue00uxk/CVBGb6+Epe2e79bqGkp ecRm4GU3rMMJ3/8VAigj9y6DWfgziEc5TXHxPV7iy0hbKnRc/fFPFcFLTynLgqF34eRw gh0g== X-Gm-Message-State: AOAM531icoT0AwXwV5SdfIWdmj3+OKK6cEi7wjfP+JAFh53mdZMpio1w 8nai0ERCavbfiEAiNjcXSOmrog== X-Google-Smtp-Source: ABdhPJyLtXGTudGYZIMvvzM5tjz/tVxh+mNzS7Uy0YKouhZVbCQJ7m6zFXkRoCWaCABWI5CtPSVfmA== X-Received: by 2002:a17:902:bb87:b0:148:a2e7:fb52 with SMTP id m7-20020a170902bb8700b00148a2e7fb52mr7613675pls.147.1639624364736; Wed, 15 Dec 2021 19:12:44 -0800 (PST) Received: from debian.bytedance.net ([61.120.150.72]) by smtp.gmail.com with ESMTPSA id p49sm3777823pfw.43.2021.12.15.19.12.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 19:12:44 -0800 (PST) From: Wenliang Wang To: mst@redhat.com, jasowang@redhat.com, davem@davemloft.net, kuba@kernel.org Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Wenliang Wang Subject: [PATCH] virtio_net: fix rx_drops stat for small pkts Date: Thu, 16 Dec 2021 11:11:35 +0800 Message-Id: <20211216031135.3182660-1-wangwenliang.1995@bytedance.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We found the stat of rx drops for small pkts does not increment when build_skb fail, it's not coherent with other mode's rx drops stat. Signed-off-by: Wenliang Wang --- drivers/net/virtio_net.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 55db6a336f7e..b107835242ad 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -733,7 +733,7 @@ static struct sk_buff *receive_small(struct net_device *dev, pr_debug("%s: rx error: len %u exceeds max size %d\n", dev->name, len, GOOD_PACKET_LEN); dev->stats.rx_length_errors++; - goto err_len; + goto err; } if (likely(!vi->xdp_enabled)) { @@ -825,10 +825,8 @@ static struct sk_buff *receive_small(struct net_device *dev, skip_xdp: skb = build_skb(buf, buflen); - if (!skb) { - put_page(page); + if (!skb) goto err; - } skb_reserve(skb, headroom - delta); skb_put(skb, len); if (!xdp_prog) { @@ -839,13 +837,12 @@ static struct sk_buff *receive_small(struct net_device *dev, if (metasize) skb_metadata_set(skb, metasize); -err: return skb; err_xdp: rcu_read_unlock(); stats->xdp_drops++; -err_len: +err: stats->drops++; put_page(page); xdp_xmit: -- 2.30.2