From patchwork Tue Aug 3 16:42:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 12416807 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60918C4338F for ; Tue, 3 Aug 2021 16:42:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4558A60555 for ; Tue, 3 Aug 2021 16:42:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234425AbhHCQmu (ORCPT ); Tue, 3 Aug 2021 12:42:50 -0400 Received: from mga17.intel.com ([192.55.52.151]:63276 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234271AbhHCQms (ORCPT ); Tue, 3 Aug 2021 12:42:48 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10065"; a="194014685" X-IronPort-AV: E=Sophos;i="5.84,292,1620716400"; d="scan'208";a="194014685" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2021 09:42:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,292,1620716400"; d="scan'208";a="419722331" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by orsmga003.jf.intel.com with ESMTP; 03 Aug 2021 09:42:23 -0700 Received: from alobakin-mobl.ger.corp.intel.com (lkalica-MOBL.ger.corp.intel.com [10.213.13.182]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 173GgIOK032342; Tue, 3 Aug 2021 17:42:18 +0100 From: Alexander Lobakin To: "David S. Miller" , Jakub Kicinski Cc: Alexander Lobakin , Jesse Brandeburg , Lukasz Czapnik , Marcin Kubiak , Michal Kubiak , Michal Swiatkowski , Jonathan Corbet , Netanel Belgazal , Arthur Kiyanovski , Guy Tzalik , Saeed Bishara , Ioana Ciornei , Claudiu Manoil , Thomas Petazzoni , Marcin Wojtas , Russell King , Edward Cree , Martin Habets , "Michael S. Tsirkin" , Jason Wang , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Shay Agroskin , Sameeh Jubran , Alexander Duyck , Danielle Ratson , Ido Schimmel , Andrew Lunn , Vladyslav Tarasiuk , Arnd Bergmann , Andrew Morton , Jian Shen , Petr Vorel , Dan Murphy , Yangbo Lu , Michal Kubecek , Zheng Yongjun , Heiner Kallweit , YueHaibing , Johannes Berg , netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, bpf@vger.kernel.org Subject: [PATCH net-next 19/21] virtio-net: don't mix error-caused drops with XDP_DROP cases Date: Tue, 3 Aug 2021 18:42:17 +0200 Message-Id: <20210803164217.4202-1-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210803163641.3743-1-alexandr.lobakin@intel.com> References: <20210803163641.3743-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org It's pretty confusing to have just one field for tracking both XDP_DROP cases and various errors which lead to the frame being dropped. Add a new field, xdp_errors, to separate error paths, and leave xdp_drops purely for counting frames with the XDP_DROP verdict. Signed-off-by: Alexander Lobakin Reviewed-by: Jesse Brandeburg --- drivers/net/virtio_net.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 8cbb4651ed75..acad099006cd 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -91,6 +91,7 @@ struct virtnet_rq_stats { u64 xdp_tx; u64 xdp_redirects; u64 xdp_drops; + u64 xdp_errors; u64 kicks; }; @@ -113,6 +114,7 @@ static const struct virtnet_stat_desc virtnet_rq_stats_desc[] = { { "xdp_tx", VIRTNET_RQ_STAT(xdp_tx) }, { "xdp_redirects", VIRTNET_RQ_STAT(xdp_redirects) }, { "xdp_drops", VIRTNET_RQ_STAT(xdp_drops) }, + { "xdp_errors", VIRTNET_RQ_STAT(xdp_errors) }, { "kicks", VIRTNET_RQ_STAT(kicks) }, }; @@ -804,7 +806,8 @@ static struct sk_buff *receive_small(struct net_device *dev, trace_xdp_exception(vi->dev, xdp_prog, act); goto err_xdp; case XDP_DROP: - goto err_xdp; + stats->xdp_drops++; + goto xdp_drop; } } rcu_read_unlock(); @@ -828,8 +831,9 @@ static struct sk_buff *receive_small(struct net_device *dev, return skb; err_xdp: + stats->xdp_errors++; +xdp_drop: rcu_read_unlock(); - stats->xdp_drops++; err_len: stats->drops++; put_page(page); @@ -1012,7 +1016,12 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, case XDP_DROP: if (unlikely(xdp_page != page)) __free_pages(xdp_page, 0); - goto err_xdp; + + if (unlikely(act != XDP_DROP)) + goto err_xdp; + + stats->xdp_drops++; + goto xdp_drop; } } rcu_read_unlock(); @@ -1081,8 +1090,9 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, return head_skb; err_xdp: + stats->xdp_errors++; +xdp_drop: rcu_read_unlock(); - stats->xdp_drops++; err_skb: put_page(page); while (num_buf-- > 1) {