All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/6] virtio_net: Add ethtool stat items
@ 2018-07-23 14:36 Toshiaki Makita
  2018-07-23 14:36 ` [PATCH net-next 1/6] virtio_net: Fix incosistent received bytes counter Toshiaki Makita
                   ` (8 more replies)
  0 siblings, 9 replies; 15+ messages in thread
From: Toshiaki Makita @ 2018-07-23 14:36 UTC (permalink / raw)
  To: Michael S. Tsirkin, Jason Wang, David S. Miller
  Cc: Toshiaki Makita, netdev, virtualization

From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>

Add some ethtool stat items useful for performance analysis.

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>

Toshiaki Makita (6):
  virtio_net: Fix incosistent received bytes counter
  virtio_net: Use temporary storage for accounting rx stats
  virtio_net: Make drop counter per-queue
  virtio_net: Factor out the logic to determine xdp sq
  virtio_net: Add XDP related stats
  virtio_net: Add kick stats

 drivers/net/virtio_net.c | 221 +++++++++++++++++++++++++++++++++--------------
 1 file changed, 158 insertions(+), 63 deletions(-)

-- 
2.14.3

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH net-next 1/6] virtio_net: Fix incosistent received bytes counter
  2018-07-23 14:36 [PATCH net-next 0/6] virtio_net: Add ethtool stat items Toshiaki Makita
@ 2018-07-23 14:36 ` Toshiaki Makita
  2018-07-23 14:36 ` [PATCH net-next 2/6] virtio_net: Use temporary storage for accounting rx stats Toshiaki Makita
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Toshiaki Makita @ 2018-07-23 14:36 UTC (permalink / raw)
  To: Michael S. Tsirkin, Jason Wang, David S. Miller
  Cc: Toshiaki Makita, netdev, virtualization

From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>

When received packets are dropped in virtio_net driver, received packets
counter is incremented but bytes counter is not.
As a result, for instance if we drop all packets by XDP, only received
is counted and bytes stays 0, which looks inconsistent.
IMHO received packets/bytes should be counted if packets are produced by
the hypervisor, like what common NICs on physical machines are doing.
So fix the bytes counter.

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
---
 drivers/net/virtio_net.c | 41 +++++++++++++++++++++++------------------
 1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 2ff08bc103a9..abbd3bc83b62 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -586,7 +586,8 @@ static struct sk_buff *receive_small(struct net_device *dev,
 				     struct receive_queue *rq,
 				     void *buf, void *ctx,
 				     unsigned int len,
-				     unsigned int *xdp_xmit)
+				     unsigned int *xdp_xmit,
+				     unsigned int *rbytes)
 {
 	struct sk_buff *skb;
 	struct bpf_prog *xdp_prog;
@@ -601,6 +602,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
 	int err;
 
 	len -= vi->hdr_len;
+	*rbytes += len;
 
 	rcu_read_lock();
 	xdp_prog = rcu_dereference(rq->xdp_prog);
@@ -705,11 +707,13 @@ static struct sk_buff *receive_big(struct net_device *dev,
 				   struct virtnet_info *vi,
 				   struct receive_queue *rq,
 				   void *buf,
-				   unsigned int len)
+				   unsigned int len,
+				   unsigned int *rbytes)
 {
 	struct page *page = buf;
 	struct sk_buff *skb = page_to_skb(vi, rq, page, 0, len, PAGE_SIZE);
 
+	*rbytes += len - vi->hdr_len;
 	if (unlikely(!skb))
 		goto err;
 
@@ -727,7 +731,8 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 					 void *buf,
 					 void *ctx,
 					 unsigned int len,
-					 unsigned int *xdp_xmit)
+					 unsigned int *xdp_xmit,
+					 unsigned int *rbytes)
 {
 	struct virtio_net_hdr_mrg_rxbuf *hdr = buf;
 	u16 num_buf = virtio16_to_cpu(vi->vdev, hdr->num_buffers);
@@ -740,6 +745,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 	int err;
 
 	head_skb = NULL;
+	*rbytes += len - vi->hdr_len;
 
 	rcu_read_lock();
 	xdp_prog = rcu_dereference(rq->xdp_prog);
@@ -877,6 +883,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 			goto err_buf;
 		}
 
+		*rbytes += len;
 		page = virt_to_head_page(buf);
 
 		truesize = mergeable_ctx_to_truesize(ctx);
@@ -932,6 +939,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 			dev->stats.rx_length_errors++;
 			break;
 		}
+		*rbytes += len;
 		page = virt_to_head_page(buf);
 		put_page(page);
 	}
@@ -942,14 +950,13 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 	return NULL;
 }
 
-static int receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
-		       void *buf, unsigned int len, void **ctx,
-		       unsigned int *xdp_xmit)
+static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
+			void *buf, unsigned int len, void **ctx,
+			unsigned int *xdp_xmit, unsigned int *rbytes)
 {
 	struct net_device *dev = vi->dev;
 	struct sk_buff *skb;
 	struct virtio_net_hdr_mrg_rxbuf *hdr;
-	int ret;
 
 	if (unlikely(len < vi->hdr_len + ETH_HLEN)) {
 		pr_debug("%s: short packet %i\n", dev->name, len);
@@ -961,23 +968,22 @@ static int receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
 		} else {
 			put_page(virt_to_head_page(buf));
 		}
-		return 0;
+		return;
 	}
 
 	if (vi->mergeable_rx_bufs)
-		skb = receive_mergeable(dev, vi, rq, buf, ctx, len, xdp_xmit);
+		skb = receive_mergeable(dev, vi, rq, buf, ctx, len, xdp_xmit,
+					rbytes);
 	else if (vi->big_packets)
-		skb = receive_big(dev, vi, rq, buf, len);
+		skb = receive_big(dev, vi, rq, buf, len, rbytes);
 	else
-		skb = receive_small(dev, vi, rq, buf, ctx, len, xdp_xmit);
+		skb = receive_small(dev, vi, rq, buf, ctx, len, xdp_xmit, rbytes);
 
 	if (unlikely(!skb))
-		return 0;
+		return;
 
 	hdr = skb_vnet_hdr(skb);
 
-	ret = skb->len;
-
 	if (hdr->hdr.flags & VIRTIO_NET_HDR_F_DATA_VALID)
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 
@@ -994,12 +1000,11 @@ static int receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
 		 ntohs(skb->protocol), skb->len, skb->pkt_type);
 
 	napi_gro_receive(&rq->napi, skb);
-	return ret;
+	return;
 
 frame_err:
 	dev->stats.rx_frame_errors++;
 	dev_kfree_skb(skb);
-	return 0;
 }
 
 /* Unlike mergeable buffers, all buffers are allocated to the
@@ -1249,13 +1254,13 @@ static int virtnet_receive(struct receive_queue *rq, int budget,
 
 		while (received < budget &&
 		       (buf = virtqueue_get_buf_ctx(rq->vq, &len, &ctx))) {
-			bytes += receive_buf(vi, rq, buf, len, ctx, xdp_xmit);
+			receive_buf(vi, rq, buf, len, ctx, xdp_xmit, &bytes);
 			received++;
 		}
 	} else {
 		while (received < budget &&
 		       (buf = virtqueue_get_buf(rq->vq, &len)) != NULL) {
-			bytes += receive_buf(vi, rq, buf, len, NULL, xdp_xmit);
+			receive_buf(vi, rq, buf, len, NULL, xdp_xmit, &bytes);
 			received++;
 		}
 	}
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 2/6] virtio_net: Use temporary storage for accounting rx stats
  2018-07-23 14:36 [PATCH net-next 0/6] virtio_net: Add ethtool stat items Toshiaki Makita
  2018-07-23 14:36 ` [PATCH net-next 1/6] virtio_net: Fix incosistent received bytes counter Toshiaki Makita
@ 2018-07-23 14:36 ` Toshiaki Makita
  2018-07-23 14:36 ` [PATCH net-next 3/6] virtio_net: Make drop counter per-queue Toshiaki Makita
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Toshiaki Makita @ 2018-07-23 14:36 UTC (permalink / raw)
  To: Michael S. Tsirkin, Jason Wang, David S. Miller
  Cc: Toshiaki Makita, netdev, virtualization

From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>

The purpose is to keep receive_buf arguments simple when more per-queue
counter items are added later.
Also XDP_TX related sq counters will be updated in the following changes
so create a container struct virtnet_rx_stats which will includes both
rq and sq statistics. For now it only covers rq stats.

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
---
 drivers/net/virtio_net.c | 72 +++++++++++++++++++++++++++++-------------------
 1 file changed, 44 insertions(+), 28 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index abbd3bc83b62..d03bfc4fce8e 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -84,14 +84,22 @@ struct virtnet_sq_stats {
 	u64 bytes;
 };
 
-struct virtnet_rq_stats {
-	struct u64_stats_sync syncp;
+struct virtnet_rq_stat_items {
 	u64 packets;
 	u64 bytes;
 };
 
+struct virtnet_rq_stats {
+	struct u64_stats_sync syncp;
+	struct virtnet_rq_stat_items items;
+};
+
+struct virtnet_rx_stats {
+	struct virtnet_rq_stat_items rx;
+};
+
 #define VIRTNET_SQ_STAT(m)	offsetof(struct virtnet_sq_stats, m)
-#define VIRTNET_RQ_STAT(m)	offsetof(struct virtnet_rq_stats, m)
+#define VIRTNET_RQ_STAT(m)	offsetof(struct virtnet_rq_stat_items, m)
 
 static const struct virtnet_stat_desc virtnet_sq_stats_desc[] = {
 	{ "packets",	VIRTNET_SQ_STAT(packets) },
@@ -587,7 +595,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
 				     void *buf, void *ctx,
 				     unsigned int len,
 				     unsigned int *xdp_xmit,
-				     unsigned int *rbytes)
+				     struct virtnet_rx_stats *stats)
 {
 	struct sk_buff *skb;
 	struct bpf_prog *xdp_prog;
@@ -602,7 +610,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
 	int err;
 
 	len -= vi->hdr_len;
-	*rbytes += len;
+	stats->rx.bytes += len;
 
 	rcu_read_lock();
 	xdp_prog = rcu_dereference(rq->xdp_prog);
@@ -708,12 +716,12 @@ static struct sk_buff *receive_big(struct net_device *dev,
 				   struct receive_queue *rq,
 				   void *buf,
 				   unsigned int len,
-				   unsigned int *rbytes)
+				   struct virtnet_rx_stats *stats)
 {
 	struct page *page = buf;
 	struct sk_buff *skb = page_to_skb(vi, rq, page, 0, len, PAGE_SIZE);
 
-	*rbytes += len - vi->hdr_len;
+	stats->rx.bytes += len - vi->hdr_len;
 	if (unlikely(!skb))
 		goto err;
 
@@ -732,7 +740,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 					 void *ctx,
 					 unsigned int len,
 					 unsigned int *xdp_xmit,
-					 unsigned int *rbytes)
+					 struct virtnet_rx_stats *stats)
 {
 	struct virtio_net_hdr_mrg_rxbuf *hdr = buf;
 	u16 num_buf = virtio16_to_cpu(vi->vdev, hdr->num_buffers);
@@ -745,7 +753,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 	int err;
 
 	head_skb = NULL;
-	*rbytes += len - vi->hdr_len;
+	stats->rx.bytes += len - vi->hdr_len;
 
 	rcu_read_lock();
 	xdp_prog = rcu_dereference(rq->xdp_prog);
@@ -883,7 +891,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 			goto err_buf;
 		}
 
-		*rbytes += len;
+		stats->rx.bytes += len;
 		page = virt_to_head_page(buf);
 
 		truesize = mergeable_ctx_to_truesize(ctx);
@@ -939,7 +947,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 			dev->stats.rx_length_errors++;
 			break;
 		}
-		*rbytes += len;
+		stats->rx.bytes += len;
 		page = virt_to_head_page(buf);
 		put_page(page);
 	}
@@ -952,7 +960,8 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 
 static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
 			void *buf, unsigned int len, void **ctx,
-			unsigned int *xdp_xmit, unsigned int *rbytes)
+			unsigned int *xdp_xmit,
+			struct virtnet_rx_stats *stats)
 {
 	struct net_device *dev = vi->dev;
 	struct sk_buff *skb;
@@ -973,11 +982,11 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
 
 	if (vi->mergeable_rx_bufs)
 		skb = receive_mergeable(dev, vi, rq, buf, ctx, len, xdp_xmit,
-					rbytes);
+					stats);
 	else if (vi->big_packets)
-		skb = receive_big(dev, vi, rq, buf, len, rbytes);
+		skb = receive_big(dev, vi, rq, buf, len, stats);
 	else
-		skb = receive_small(dev, vi, rq, buf, ctx, len, xdp_xmit, rbytes);
+		skb = receive_small(dev, vi, rq, buf, ctx, len, xdp_xmit, stats);
 
 	if (unlikely(!skb))
 		return;
@@ -1246,22 +1255,24 @@ static int virtnet_receive(struct receive_queue *rq, int budget,
 			   unsigned int *xdp_xmit)
 {
 	struct virtnet_info *vi = rq->vq->vdev->priv;
-	unsigned int len, received = 0, bytes = 0;
+	struct virtnet_rx_stats stats = {};
+	unsigned int len;
 	void *buf;
+	int i;
 
 	if (!vi->big_packets || vi->mergeable_rx_bufs) {
 		void *ctx;
 
-		while (received < budget &&
+		while (stats.rx.packets < budget &&
 		       (buf = virtqueue_get_buf_ctx(rq->vq, &len, &ctx))) {
-			receive_buf(vi, rq, buf, len, ctx, xdp_xmit, &bytes);
-			received++;
+			receive_buf(vi, rq, buf, len, ctx, xdp_xmit, &stats);
+			stats.rx.packets++;
 		}
 	} else {
-		while (received < budget &&
+		while (stats.rx.packets < budget &&
 		       (buf = virtqueue_get_buf(rq->vq, &len)) != NULL) {
-			receive_buf(vi, rq, buf, len, NULL, xdp_xmit, &bytes);
-			received++;
+			receive_buf(vi, rq, buf, len, NULL, xdp_xmit, &stats);
+			stats.rx.packets++;
 		}
 	}
 
@@ -1271,11 +1282,16 @@ static int virtnet_receive(struct receive_queue *rq, int budget,
 	}
 
 	u64_stats_update_begin(&rq->stats.syncp);
-	rq->stats.bytes += bytes;
-	rq->stats.packets += received;
+	for (i = 0; i < VIRTNET_RQ_STATS_LEN; i++) {
+		size_t offset = virtnet_rq_stats_desc[i].offset;
+		u64 *item;
+
+		item = (u64 *)((u8 *)&rq->stats.items + offset);
+		*item += *(u64 *)((u8 *)&stats.rx + offset);
+	}
 	u64_stats_update_end(&rq->stats.syncp);
 
-	return received;
+	return stats.rx.packets;
 }
 
 static void free_old_xmit_skbs(struct send_queue *sq)
@@ -1628,8 +1644,8 @@ static void virtnet_stats(struct net_device *dev,
 
 		do {
 			start = u64_stats_fetch_begin_irq(&rq->stats.syncp);
-			rpackets = rq->stats.packets;
-			rbytes   = rq->stats.bytes;
+			rpackets = rq->stats.items.packets;
+			rbytes   = rq->stats.items.bytes;
 		} while (u64_stats_fetch_retry_irq(&rq->stats.syncp, start));
 
 		tot->rx_packets += rpackets;
@@ -2019,7 +2035,7 @@ static void virtnet_get_ethtool_stats(struct net_device *dev,
 	for (i = 0; i < vi->curr_queue_pairs; i++) {
 		struct receive_queue *rq = &vi->rq[i];
 
-		stats_base = (u8 *)&rq->stats;
+		stats_base = (u8 *)&rq->stats.items;
 		do {
 			start = u64_stats_fetch_begin_irq(&rq->stats.syncp);
 			for (j = 0; j < VIRTNET_RQ_STATS_LEN; j++) {
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 3/6] virtio_net: Make drop counter per-queue
  2018-07-23 14:36 [PATCH net-next 0/6] virtio_net: Add ethtool stat items Toshiaki Makita
  2018-07-23 14:36 ` [PATCH net-next 1/6] virtio_net: Fix incosistent received bytes counter Toshiaki Makita
  2018-07-23 14:36 ` [PATCH net-next 2/6] virtio_net: Use temporary storage for accounting rx stats Toshiaki Makita
@ 2018-07-23 14:36 ` Toshiaki Makita
  2018-07-23 14:36 ` [PATCH net-next 4/6] virtio_net: Factor out the logic to determine xdp sq Toshiaki Makita
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Toshiaki Makita @ 2018-07-23 14:36 UTC (permalink / raw)
  To: Michael S. Tsirkin, Jason Wang, David S. Miller
  Cc: Toshiaki Makita, netdev, virtualization

From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>

Since when XDP was introduced, drop counter has been able to be updated
much more frequently than before, as XDP_DROP increments the counter.
Thus for performance analysis per-queue drop counter would be useful.

Also this avoids cache contention and race on updating the counter. It
is currently racy because napi handlers read-modify-write it without any
locks.

There are more counters in dev->stats that are racy, but I left them
per-device, because they are rarely updated and does not worth being
per-queue counters IMHO. To fix them we need atomic ops or some kind of
locks.

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
---
 drivers/net/virtio_net.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index d03bfc4fce8e..7a47ce750a43 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -87,6 +87,7 @@ struct virtnet_sq_stats {
 struct virtnet_rq_stat_items {
 	u64 packets;
 	u64 bytes;
+	u64 drops;
 };
 
 struct virtnet_rq_stats {
@@ -109,6 +110,7 @@ static const struct virtnet_stat_desc virtnet_sq_stats_desc[] = {
 static const struct virtnet_stat_desc virtnet_rq_stats_desc[] = {
 	{ "packets",	VIRTNET_RQ_STAT(packets) },
 	{ "bytes",	VIRTNET_RQ_STAT(bytes) },
+	{ "drops",	VIRTNET_RQ_STAT(drops) },
 };
 
 #define VIRTNET_SQ_STATS_LEN	ARRAY_SIZE(virtnet_sq_stats_desc)
@@ -705,7 +707,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
 
 err_xdp:
 	rcu_read_unlock();
-	dev->stats.rx_dropped++;
+	stats->rx.drops++;
 	put_page(page);
 xdp_xmit:
 	return NULL;
@@ -728,7 +730,7 @@ static struct sk_buff *receive_big(struct net_device *dev,
 	return skb;
 
 err:
-	dev->stats.rx_dropped++;
+	stats->rx.drops++;
 	give_pages(rq, page);
 	return NULL;
 }
@@ -952,7 +954,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 		put_page(page);
 	}
 err_buf:
-	dev->stats.rx_dropped++;
+	stats->rx.drops++;
 	dev_kfree_skb(head_skb);
 xdp_xmit:
 	return NULL;
@@ -1632,7 +1634,7 @@ static void virtnet_stats(struct net_device *dev,
 	int i;
 
 	for (i = 0; i < vi->max_queue_pairs; i++) {
-		u64 tpackets, tbytes, rpackets, rbytes;
+		u64 tpackets, tbytes, rpackets, rbytes, rdrops;
 		struct receive_queue *rq = &vi->rq[i];
 		struct send_queue *sq = &vi->sq[i];
 
@@ -1646,17 +1648,18 @@ static void virtnet_stats(struct net_device *dev,
 			start = u64_stats_fetch_begin_irq(&rq->stats.syncp);
 			rpackets = rq->stats.items.packets;
 			rbytes   = rq->stats.items.bytes;
+			rdrops   = rq->stats.items.drops;
 		} while (u64_stats_fetch_retry_irq(&rq->stats.syncp, start));
 
 		tot->rx_packets += rpackets;
 		tot->tx_packets += tpackets;
 		tot->rx_bytes   += rbytes;
 		tot->tx_bytes   += tbytes;
+		tot->rx_dropped += rdrops;
 	}
 
 	tot->tx_dropped = dev->stats.tx_dropped;
 	tot->tx_fifo_errors = dev->stats.tx_fifo_errors;
-	tot->rx_dropped = dev->stats.rx_dropped;
 	tot->rx_length_errors = dev->stats.rx_length_errors;
 	tot->rx_frame_errors = dev->stats.rx_frame_errors;
 }
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 4/6] virtio_net: Factor out the logic to determine xdp sq
  2018-07-23 14:36 [PATCH net-next 0/6] virtio_net: Add ethtool stat items Toshiaki Makita
                   ` (2 preceding siblings ...)
  2018-07-23 14:36 ` [PATCH net-next 3/6] virtio_net: Make drop counter per-queue Toshiaki Makita
@ 2018-07-23 14:36 ` Toshiaki Makita
  2018-07-23 14:36 ` [PATCH net-next 5/6] virtio_net: Add XDP related stats Toshiaki Makita
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Toshiaki Makita @ 2018-07-23 14:36 UTC (permalink / raw)
  To: Michael S. Tsirkin, Jason Wang, David S. Miller
  Cc: Toshiaki Makita, netdev, virtualization

From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>

Make sure to use the same logic in all places to determine xdp sq. This
is useful for xdp counters which the following commit will introduce as
well.

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
---
 drivers/net/virtio_net.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 7a47ce750a43..eca9b13b859e 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -457,16 +457,22 @@ static int __virtnet_xdp_xmit_one(struct virtnet_info *vi,
 	return 0;
 }
 
+static struct send_queue *virtnet_xdp_sq(struct virtnet_info *vi)
+{
+	unsigned int qp;
+
+	qp = vi->curr_queue_pairs - vi->xdp_queue_pairs + smp_processor_id();
+	return &vi->sq[qp];
+}
+
 static int __virtnet_xdp_tx_xmit(struct virtnet_info *vi,
 				   struct xdp_frame *xdpf)
 {
 	struct xdp_frame *xdpf_sent;
 	struct send_queue *sq;
 	unsigned int len;
-	unsigned int qp;
 
-	qp = vi->curr_queue_pairs - vi->xdp_queue_pairs + smp_processor_id();
-	sq = &vi->sq[qp];
+	sq = virtnet_xdp_sq(vi);
 
 	/* Free up any pending old buffers before queueing new ones. */
 	while ((xdpf_sent = virtqueue_get_buf(sq->vq, &len)) != NULL)
@@ -484,7 +490,6 @@ static int virtnet_xdp_xmit(struct net_device *dev,
 	struct bpf_prog *xdp_prog;
 	struct send_queue *sq;
 	unsigned int len;
-	unsigned int qp;
 	int drops = 0;
 	int err;
 	int i;
@@ -492,8 +497,7 @@ static int virtnet_xdp_xmit(struct net_device *dev,
 	if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
 		return -EINVAL;
 
-	qp = vi->curr_queue_pairs - vi->xdp_queue_pairs + smp_processor_id();
-	sq = &vi->sq[qp];
+	sq = virtnet_xdp_sq(vi);
 
 	/* Only allow ndo_xdp_xmit if XDP is loaded on dev, as this
 	 * indicate XDP resources have been successfully allocated.
@@ -1349,7 +1353,7 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
 		container_of(napi, struct receive_queue, napi);
 	struct virtnet_info *vi = rq->vq->vdev->priv;
 	struct send_queue *sq;
-	unsigned int received, qp;
+	unsigned int received;
 	unsigned int xdp_xmit = 0;
 
 	virtnet_poll_cleantx(rq);
@@ -1364,9 +1368,7 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
 		xdp_do_flush_map();
 
 	if (xdp_xmit & VIRTIO_XDP_TX) {
-		qp = vi->curr_queue_pairs - vi->xdp_queue_pairs +
-		     smp_processor_id();
-		sq = &vi->sq[qp];
+		sq = virtnet_xdp_sq(vi);
 		virtqueue_kick(sq->vq);
 	}
 
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 5/6] virtio_net: Add XDP related stats
  2018-07-23 14:36 [PATCH net-next 0/6] virtio_net: Add ethtool stat items Toshiaki Makita
                   ` (3 preceding siblings ...)
  2018-07-23 14:36 ` [PATCH net-next 4/6] virtio_net: Factor out the logic to determine xdp sq Toshiaki Makita
@ 2018-07-23 14:36 ` Toshiaki Makita
  2018-07-23 14:36 ` [PATCH net-next 6/6] virtio_net: Add kick stats Toshiaki Makita
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Toshiaki Makita @ 2018-07-23 14:36 UTC (permalink / raw)
  To: Michael S. Tsirkin, Jason Wang, David S. Miller
  Cc: Toshiaki Makita, netdev, virtualization

From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>

Add counters below:
* Tx
 - xdp_tx: frames sent by ndo_xdp_xmit or XDP_TX.
 - xdp_tx_drops: dropped frames out of xdp_tx ones.
* Rx
 - xdp_packets: frames went through xdp program.
 - xdp_tx: XDP_TX frames.
 - xdp_redirects: XDP_REDIRECT frames.
 - xdp_drops: any dropped frames out of xdp_packets ones.

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
---
 drivers/net/virtio_net.c | 71 ++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 59 insertions(+), 12 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index eca9b13b859e..cb4ef331567c 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -82,12 +82,18 @@ struct virtnet_sq_stats {
 	struct u64_stats_sync syncp;
 	u64 packets;
 	u64 bytes;
+	u64 xdp_tx;
+	u64 xdp_tx_drops;
 };
 
 struct virtnet_rq_stat_items {
 	u64 packets;
 	u64 bytes;
 	u64 drops;
+	u64 xdp_packets;
+	u64 xdp_tx;
+	u64 xdp_redirects;
+	u64 xdp_drops;
 };
 
 struct virtnet_rq_stats {
@@ -97,20 +103,30 @@ struct virtnet_rq_stats {
 
 struct virtnet_rx_stats {
 	struct virtnet_rq_stat_items rx;
+	struct {
+		unsigned int xdp_tx;
+		unsigned int xdp_tx_drops;
+	} tx;
 };
 
 #define VIRTNET_SQ_STAT(m)	offsetof(struct virtnet_sq_stats, m)
 #define VIRTNET_RQ_STAT(m)	offsetof(struct virtnet_rq_stat_items, m)
 
 static const struct virtnet_stat_desc virtnet_sq_stats_desc[] = {
-	{ "packets",	VIRTNET_SQ_STAT(packets) },
-	{ "bytes",	VIRTNET_SQ_STAT(bytes) },
+	{ "packets",		VIRTNET_SQ_STAT(packets) },
+	{ "bytes",		VIRTNET_SQ_STAT(bytes) },
+	{ "xdp_tx",		VIRTNET_SQ_STAT(xdp_tx) },
+	{ "xdp_tx_drops",	VIRTNET_SQ_STAT(xdp_tx_drops) },
 };
 
 static const struct virtnet_stat_desc virtnet_rq_stats_desc[] = {
-	{ "packets",	VIRTNET_RQ_STAT(packets) },
-	{ "bytes",	VIRTNET_RQ_STAT(bytes) },
-	{ "drops",	VIRTNET_RQ_STAT(drops) },
+	{ "packets",		VIRTNET_RQ_STAT(packets) },
+	{ "bytes",		VIRTNET_RQ_STAT(bytes) },
+	{ "drops",		VIRTNET_RQ_STAT(drops) },
+	{ "xdp_packets",	VIRTNET_RQ_STAT(xdp_packets) },
+	{ "xdp_tx",		VIRTNET_RQ_STAT(xdp_tx) },
+	{ "xdp_redirects",	VIRTNET_RQ_STAT(xdp_redirects) },
+	{ "xdp_drops",		VIRTNET_RQ_STAT(xdp_drops) },
 };
 
 #define VIRTNET_SQ_STATS_LEN	ARRAY_SIZE(virtnet_sq_stats_desc)
@@ -491,20 +507,26 @@ static int virtnet_xdp_xmit(struct net_device *dev,
 	struct send_queue *sq;
 	unsigned int len;
 	int drops = 0;
-	int err;
+	int ret, err;
 	int i;
 
-	if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
-		return -EINVAL;
-
 	sq = virtnet_xdp_sq(vi);
 
+	if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK)) {
+		ret = -EINVAL;
+		drops = n;
+		goto out;
+	}
+
 	/* Only allow ndo_xdp_xmit if XDP is loaded on dev, as this
 	 * indicate XDP resources have been successfully allocated.
 	 */
 	xdp_prog = rcu_dereference(rq->xdp_prog);
-	if (!xdp_prog)
-		return -ENXIO;
+	if (!xdp_prog) {
+		ret = -ENXIO;
+		drops = n;
+		goto out;
+	}
 
 	/* Free up any pending old buffers before queueing new ones. */
 	while ((xdpf_sent = virtqueue_get_buf(sq->vq, &len)) != NULL)
@@ -519,11 +541,17 @@ static int virtnet_xdp_xmit(struct net_device *dev,
 			drops++;
 		}
 	}
+	ret = n - drops;
 
 	if (flags & XDP_XMIT_FLUSH)
 		virtqueue_kick(sq->vq);
+out:
+	u64_stats_update_begin(&sq->stats.syncp);
+	sq->stats.xdp_tx += n;
+	sq->stats.xdp_tx_drops += drops;
+	u64_stats_update_end(&sq->stats.syncp);
 
-	return n - drops;
+	return ret;
 }
 
 static unsigned int virtnet_get_headroom(struct virtnet_info *vi)
@@ -658,6 +686,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
 		xdp.rxq = &rq->xdp_rxq;
 		orig_data = xdp.data;
 		act = bpf_prog_run_xdp(xdp_prog, &xdp);
+		stats->rx.xdp_packets++;
 
 		switch (act) {
 		case XDP_PASS:
@@ -666,11 +695,14 @@ static struct sk_buff *receive_small(struct net_device *dev,
 			len = xdp.data_end - xdp.data;
 			break;
 		case XDP_TX:
+			stats->rx.xdp_tx++;
 			xdpf = convert_to_xdp_frame(&xdp);
 			if (unlikely(!xdpf))
 				goto err_xdp;
+			stats->tx.xdp_tx++;
 			err = __virtnet_xdp_tx_xmit(vi, xdpf);
 			if (unlikely(err)) {
+				stats->tx.xdp_tx_drops++;
 				trace_xdp_exception(vi->dev, xdp_prog, act);
 				goto err_xdp;
 			}
@@ -678,6 +710,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
 			rcu_read_unlock();
 			goto xdp_xmit;
 		case XDP_REDIRECT:
+			stats->rx.xdp_redirects++;
 			err = xdp_do_redirect(dev, &xdp, xdp_prog);
 			if (err)
 				goto err_xdp;
@@ -711,6 +744,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
 
 err_xdp:
 	rcu_read_unlock();
+	stats->rx.xdp_drops++;
 	stats->rx.drops++;
 	put_page(page);
 xdp_xmit:
@@ -808,6 +842,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 		xdp.rxq = &rq->xdp_rxq;
 
 		act = bpf_prog_run_xdp(xdp_prog, &xdp);
+		stats->rx.xdp_packets++;
 
 		switch (act) {
 		case XDP_PASS:
@@ -832,11 +867,14 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 			}
 			break;
 		case XDP_TX:
+			stats->rx.xdp_tx++;
 			xdpf = convert_to_xdp_frame(&xdp);
 			if (unlikely(!xdpf))
 				goto err_xdp;
+			stats->tx.xdp_tx++;
 			err = __virtnet_xdp_tx_xmit(vi, xdpf);
 			if (unlikely(err)) {
+				stats->tx.xdp_tx_drops++;
 				trace_xdp_exception(vi->dev, xdp_prog, act);
 				if (unlikely(xdp_page != page))
 					put_page(xdp_page);
@@ -848,6 +886,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 			rcu_read_unlock();
 			goto xdp_xmit;
 		case XDP_REDIRECT:
+			stats->rx.xdp_redirects++;
 			err = xdp_do_redirect(dev, &xdp, xdp_prog);
 			if (err) {
 				if (unlikely(xdp_page != page))
@@ -943,6 +982,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 
 err_xdp:
 	rcu_read_unlock();
+	stats->rx.xdp_drops++;
 err_skb:
 	put_page(page);
 	while (num_buf-- > 1) {
@@ -1262,6 +1302,7 @@ static int virtnet_receive(struct receive_queue *rq, int budget,
 {
 	struct virtnet_info *vi = rq->vq->vdev->priv;
 	struct virtnet_rx_stats stats = {};
+	struct send_queue *sq;
 	unsigned int len;
 	void *buf;
 	int i;
@@ -1297,6 +1338,12 @@ static int virtnet_receive(struct receive_queue *rq, int budget,
 	}
 	u64_stats_update_end(&rq->stats.syncp);
 
+	sq = virtnet_xdp_sq(vi);
+	u64_stats_update_begin(&sq->stats.syncp);
+	sq->stats.xdp_tx += stats.tx.xdp_tx;
+	sq->stats.xdp_tx_drops += stats.tx.xdp_tx_drops;
+	u64_stats_update_end(&sq->stats.syncp);
+
 	return stats.rx.packets;
 }
 
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 6/6] virtio_net: Add kick stats
  2018-07-23 14:36 [PATCH net-next 0/6] virtio_net: Add ethtool stat items Toshiaki Makita
                   ` (4 preceding siblings ...)
  2018-07-23 14:36 ` [PATCH net-next 5/6] virtio_net: Add XDP related stats Toshiaki Makita
@ 2018-07-23 14:36 ` Toshiaki Makita
  2018-07-25  2:06 ` [PATCH net-next 0/6] virtio_net: Add ethtool stat items David Miller
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Toshiaki Makita @ 2018-07-23 14:36 UTC (permalink / raw)
  To: Michael S. Tsirkin, Jason Wang, David S. Miller
  Cc: Toshiaki Makita, netdev, virtualization

From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>

So we can infer the number of VM-Exits.

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
---
 drivers/net/virtio_net.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index cb4ef331567c..1880c86e84b4 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -84,6 +84,7 @@ struct virtnet_sq_stats {
 	u64 bytes;
 	u64 xdp_tx;
 	u64 xdp_tx_drops;
+	u64 kicks;
 };
 
 struct virtnet_rq_stat_items {
@@ -94,6 +95,7 @@ struct virtnet_rq_stat_items {
 	u64 xdp_tx;
 	u64 xdp_redirects;
 	u64 xdp_drops;
+	u64 kicks;
 };
 
 struct virtnet_rq_stats {
@@ -117,6 +119,7 @@ static const struct virtnet_stat_desc virtnet_sq_stats_desc[] = {
 	{ "bytes",		VIRTNET_SQ_STAT(bytes) },
 	{ "xdp_tx",		VIRTNET_SQ_STAT(xdp_tx) },
 	{ "xdp_tx_drops",	VIRTNET_SQ_STAT(xdp_tx_drops) },
+	{ "kicks",		VIRTNET_SQ_STAT(kicks) },
 };
 
 static const struct virtnet_stat_desc virtnet_rq_stats_desc[] = {
@@ -127,6 +130,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) },
+	{ "kicks",		VIRTNET_RQ_STAT(kicks) },
 };
 
 #define VIRTNET_SQ_STATS_LEN	ARRAY_SIZE(virtnet_sq_stats_desc)
@@ -507,6 +511,7 @@ static int virtnet_xdp_xmit(struct net_device *dev,
 	struct send_queue *sq;
 	unsigned int len;
 	int drops = 0;
+	int kicks = 0;
 	int ret, err;
 	int i;
 
@@ -543,12 +548,15 @@ static int virtnet_xdp_xmit(struct net_device *dev,
 	}
 	ret = n - drops;
 
-	if (flags & XDP_XMIT_FLUSH)
-		virtqueue_kick(sq->vq);
+	if (flags & XDP_XMIT_FLUSH) {
+		if (virtqueue_kick_prepare(sq->vq) && virtqueue_notify(sq->vq))
+			kicks = 1;
+	}
 out:
 	u64_stats_update_begin(&sq->stats.syncp);
 	sq->stats.xdp_tx += n;
 	sq->stats.xdp_tx_drops += drops;
+	sq->stats.kicks += kicks;
 	u64_stats_update_end(&sq->stats.syncp);
 
 	return ret;
@@ -1226,7 +1234,12 @@ static bool try_fill_recv(struct virtnet_info *vi, struct receive_queue *rq,
 		if (err)
 			break;
 	} while (rq->vq->num_free);
-	virtqueue_kick(rq->vq);
+	if (virtqueue_kick_prepare(rq->vq) && virtqueue_notify(rq->vq)) {
+		u64_stats_update_begin(&rq->stats.syncp);
+		rq->stats.items.kicks++;
+		u64_stats_update_end(&rq->stats.syncp);
+	}
+
 	return !oom;
 }
 
@@ -1416,7 +1429,11 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
 
 	if (xdp_xmit & VIRTIO_XDP_TX) {
 		sq = virtnet_xdp_sq(vi);
-		virtqueue_kick(sq->vq);
+		if (virtqueue_kick_prepare(sq->vq) && virtqueue_notify(sq->vq)) {
+			u64_stats_update_begin(&sq->stats.syncp);
+			sq->stats.kicks++;
+			u64_stats_update_end(&sq->stats.syncp);
+		}
 	}
 
 	return received;
@@ -1578,8 +1595,13 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
 		}
 	}
 
-	if (kick || netif_xmit_stopped(txq))
-		virtqueue_kick(sq->vq);
+	if (kick || netif_xmit_stopped(txq)) {
+		if (virtqueue_kick_prepare(sq->vq) && virtqueue_notify(sq->vq)) {
+			u64_stats_update_begin(&sq->stats.syncp);
+			sq->stats.kicks++;
+			u64_stats_update_end(&sq->stats.syncp);
+		}
+	}
 
 	return NETDEV_TX_OK;
 }
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next 0/6] virtio_net: Add ethtool stat items
  2018-07-23 14:36 [PATCH net-next 0/6] virtio_net: Add ethtool stat items Toshiaki Makita
                   ` (5 preceding siblings ...)
  2018-07-23 14:36 ` [PATCH net-next 6/6] virtio_net: Add kick stats Toshiaki Makita
@ 2018-07-25  2:06 ` David Miller
  2018-07-25  9:40 ` Michael S. Tsirkin
  2018-07-25  9:40 ` Michael S. Tsirkin
  8 siblings, 0 replies; 15+ messages in thread
From: David Miller @ 2018-07-25  2:06 UTC (permalink / raw)
  To: toshiaki.makita1; +Cc: netdev, virtualization, mst

From: Toshiaki Makita <toshiaki.makita1@gmail.com>
Date: Mon, 23 Jul 2018 23:36:03 +0900

> From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
> 
> Add some ethtool stat items useful for performance analysis.
> 
> Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>

Michael and Jason, any objections to these new stats?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next 0/6] virtio_net: Add ethtool stat items
  2018-07-23 14:36 [PATCH net-next 0/6] virtio_net: Add ethtool stat items Toshiaki Makita
                   ` (7 preceding siblings ...)
  2018-07-25  9:40 ` Michael S. Tsirkin
@ 2018-07-25  9:40 ` Michael S. Tsirkin
  2018-07-25 19:59   ` David Miller
  2018-07-25 19:59   ` David Miller
  8 siblings, 2 replies; 15+ messages in thread
From: Michael S. Tsirkin @ 2018-07-25  9:40 UTC (permalink / raw)
  To: Toshiaki Makita
  Cc: Jason Wang, David S. Miller, Toshiaki Makita, netdev, virtualization

On Mon, Jul 23, 2018 at 11:36:03PM +0900, Toshiaki Makita wrote:
> From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
> 
> Add some ethtool stat items useful for performance analysis.
> 
> Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>

Series:

Acked-by: Michael S. Tsirkin <mst@redhat.com>

Patch 1 seems appropriate for stable, even though it's minor.

> Toshiaki Makita (6):
>   virtio_net: Fix incosistent received bytes counter
>   virtio_net: Use temporary storage for accounting rx stats
>   virtio_net: Make drop counter per-queue
>   virtio_net: Factor out the logic to determine xdp sq
>   virtio_net: Add XDP related stats
>   virtio_net: Add kick stats
> 
>  drivers/net/virtio_net.c | 221 +++++++++++++++++++++++++++++++++--------------
>  1 file changed, 158 insertions(+), 63 deletions(-)
> 
> -- 
> 2.14.3

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next 0/6] virtio_net: Add ethtool stat items
  2018-07-23 14:36 [PATCH net-next 0/6] virtio_net: Add ethtool stat items Toshiaki Makita
                   ` (6 preceding siblings ...)
  2018-07-25  2:06 ` [PATCH net-next 0/6] virtio_net: Add ethtool stat items David Miller
@ 2018-07-25  9:40 ` Michael S. Tsirkin
  2018-07-25  9:40 ` Michael S. Tsirkin
  8 siblings, 0 replies; 15+ messages in thread
From: Michael S. Tsirkin @ 2018-07-25  9:40 UTC (permalink / raw)
  To: Toshiaki Makita; +Cc: netdev, virtualization, David S. Miller

On Mon, Jul 23, 2018 at 11:36:03PM +0900, Toshiaki Makita wrote:
> From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
> 
> Add some ethtool stat items useful for performance analysis.
> 
> Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>

Series:

Acked-by: Michael S. Tsirkin <mst@redhat.com>

Patch 1 seems appropriate for stable, even though it's minor.

> Toshiaki Makita (6):
>   virtio_net: Fix incosistent received bytes counter
>   virtio_net: Use temporary storage for accounting rx stats
>   virtio_net: Make drop counter per-queue
>   virtio_net: Factor out the logic to determine xdp sq
>   virtio_net: Add XDP related stats
>   virtio_net: Add kick stats
> 
>  drivers/net/virtio_net.c | 221 +++++++++++++++++++++++++++++++++--------------
>  1 file changed, 158 insertions(+), 63 deletions(-)
> 
> -- 
> 2.14.3

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next 0/6] virtio_net: Add ethtool stat items
  2018-07-25  9:40 ` Michael S. Tsirkin
  2018-07-25 19:59   ` David Miller
@ 2018-07-25 19:59   ` David Miller
  2018-08-05 13:15     ` Tariq Toukan
  1 sibling, 1 reply; 15+ messages in thread
From: David Miller @ 2018-07-25 19:59 UTC (permalink / raw)
  To: mst; +Cc: toshiaki.makita1, jasowang, makita.toshiaki, netdev, virtualization

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Wed, 25 Jul 2018 12:40:12 +0300

> On Mon, Jul 23, 2018 at 11:36:03PM +0900, Toshiaki Makita wrote:
>> From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
>> 
>> Add some ethtool stat items useful for performance analysis.
>> 
>> Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
> 
> Series:
> 
> Acked-by: Michael S. Tsirkin <mst@redhat.com>

Series applied.

> Patch 1 seems appropriate for stable, even though it's minor.

Ok, I'll put patch #1 also into 'net' and queue it up for -stable.

Thanks.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next 0/6] virtio_net: Add ethtool stat items
  2018-07-25  9:40 ` Michael S. Tsirkin
@ 2018-07-25 19:59   ` David Miller
  2018-07-25 19:59   ` David Miller
  1 sibling, 0 replies; 15+ messages in thread
From: David Miller @ 2018-07-25 19:59 UTC (permalink / raw)
  To: mst; +Cc: netdev, toshiaki.makita1, virtualization

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Wed, 25 Jul 2018 12:40:12 +0300

> On Mon, Jul 23, 2018 at 11:36:03PM +0900, Toshiaki Makita wrote:
>> From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
>> 
>> Add some ethtool stat items useful for performance analysis.
>> 
>> Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
> 
> Series:
> 
> Acked-by: Michael S. Tsirkin <mst@redhat.com>

Series applied.

> Patch 1 seems appropriate for stable, even though it's minor.

Ok, I'll put patch #1 also into 'net' and queue it up for -stable.

Thanks.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next 0/6] virtio_net: Add ethtool stat items
  2018-07-25 19:59   ` David Miller
@ 2018-08-05 13:15     ` Tariq Toukan
  2018-08-05 13:45       ` Tariq Toukan
  0 siblings, 1 reply; 15+ messages in thread
From: Tariq Toukan @ 2018-08-05 13:15 UTC (permalink / raw)
  To: David Miller, mst, toshiaki.makita1, makita.toshiaki
  Cc: ranro, netdev, Eran Ben Elisha, virtualization, Maor Gottlieb



On 25/07/2018 10:59 PM, David Miller wrote:
> From: "Michael S. Tsirkin" <mst@redhat.com>
> Date: Wed, 25 Jul 2018 12:40:12 +0300
> 
>> On Mon, Jul 23, 2018 at 11:36:03PM +0900, Toshiaki Makita wrote:
>>> From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
>>>
>>> Add some ethtool stat items useful for performance analysis.
>>>
>>> Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
>>
>> Series:
>>
>> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> 
> Series applied.
> 
>> Patch 1 seems appropriate for stable, even though it's minor.
> 
> Ok, I'll put patch #1 also into 'net' and queue it up for -stable.
> 
> Thanks.
> 

Hi,
Our verification team encountered the following degradation, introduced 
by this series. Please check KASAN bug report below.

We tested before and after the series, but didn't bisect within it. We 
can do if necessary.

Thanks,
Tariq


[   46.166544] BUG: KASAN: use-after-free in virtnet_poll+0xd9c/0xfd1 
[virtio_net]
[   46.166593] Read of size 8 at addr ffff8803400da608 by task ip/1013

[   46.166603] CPU: 3 PID: 1013 Comm: ip Not tainted 
4.18.0-rc6-for-upstream-dbg-2018-07-26_19-45-52-64 #1
[   46.166606] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), 
BIOS 1.10.2-1ubuntu1 04/01/2014
[   46.166609] Call Trace:
[   46.166613]  <IRQ>
[   46.166624]  dump_stack+0xf0/0x17b
[   46.166647]  ? show_regs_print_info+0x5/0x5
[   46.166654]  ? printk+0x9c/0xc3
[   46.166661]  ? kmsg_dump_rewind_nolock+0xf5/0xf5
[   46.166677]  ? virtnet_poll+0xd9c/0xfd1 [virtio_net]
[   46.166685]  print_address_description+0xea/0x380
[   46.166701]  ? virtnet_poll+0xd9c/0xfd1 [virtio_net]
[   46.166711]  kasan_report+0x1dd/0x460
[   46.166727]  ? virtnet_poll+0xd9c/0xfd1 [virtio_net]
[   46.166743]  virtnet_poll+0xd9c/0xfd1 [virtio_net]
[   46.166767]  ? receive_buf+0x2e30/0x2e30 [virtio_net]
[   46.166796]  ? sched_clock_cpu+0x18/0x2b0
[   46.166809]  ? print_irqtrace_events+0x280/0x280
[   46.166817]  ? print_irqtrace_events+0x280/0x280
[   46.166830]  ? rcu_process_callbacks+0xc5e/0x12d0
[   46.166838]  ? kvm_clock_read+0x1f/0x30
[   46.166857]  ? mark_held_locks+0xd5/0x170
[   46.166867]  ? net_rx_action+0x2aa/0x10e0
[   46.166882]  net_rx_action+0x4bc/0x10e0
[   46.166906]  ? napi_complete_done+0x480/0x480
[   46.166925]  ? print_irqtrace_events+0x280/0x280
[   46.166935]  ? sched_clock+0x5/0x10
[   46.166952]  ? __lock_is_held+0xcb/0x1a0
[   46.166982]  __do_softirq+0x2c4/0xdf4
[   46.167010]  do_softirq_own_stack+0x2a/0x40
[   46.167031]  </IRQ>
[   46.167038]  ? virtnet_napi_enable+0x37/0xa0 [virtio_net]
[   46.167044]  do_softirq.part.11+0x69/0x70
[   46.167065]  __local_bh_enable_ip+0x1d9/0x250
[   46.167076]  virtnet_open+0x13c/0x440 [virtio_net]
[   46.167099]  __dev_open+0x1cf/0x390
[   46.167108]  ? dev_set_rx_mode+0x30/0x30
[   46.167113]  ? __local_bh_enable_ip+0xf7/0x250
[   46.167124]  ? trace_hardirqs_on_caller+0x38d/0x6c0
[   46.167130]  ? __dev_change_flags+0x18d/0x630
[   46.167142]  __dev_change_flags+0x469/0x630
[   46.167152]  ? dev_set_allmulti+0x10/0x10
[   46.167157]  ? __lock_acquire+0x9c1/0x4b50
[   46.167166]  ? print_irqtrace_events+0x280/0x280
[   46.167174]  ? kvm_clock_read+0x1f/0x30
[   46.167191]  ? rtnetlink_put_metrics+0x530/0x530
[   46.167205]  dev_change_flags+0x8b/0x160
[   46.167236]  do_setlink+0xa17/0x39f0
[   46.167248]  ? sched_clock_cpu+0x18/0x2b0
[   46.167267]  ? rtnl_dump_ifinfo+0xd20/0xd20
[   46.167277]  ? print_irqtrace_events+0x280/0x280
[   46.167285]  ? kvm_clock_read+0x1f/0x30
[   46.167316]  ? debug_show_all_locks+0x3b0/0x3b0
[   46.167321]  ? kvm_sched_clock_read+0x5/0x10
[   46.167327]  ? sched_clock+0x5/0x10
[   46.167333]  ? sched_clock_cpu+0x18/0x2b0
[   46.167382]  ? memset+0x1f/0x40
[   46.167408]  ? nla_parse+0x8c/0x3f0
[   46.167419]  ? rtnetlink_put_metrics+0x530/0x530
[   46.167427]  ? kvm_sched_clock_read+0x5/0x10
[   46.167433]  ? sched_clock+0x5/0x10
[   46.167439]  ? sched_clock_cpu+0x18/0x2b0
[   46.167457]  rtnl_newlink+0x9dc/0x13a0
[   46.167484]  ? rtnl_link_unregister+0x2b0/0x2b0
[   46.167513]  ? kvm_clock_read+0x1f/0x30
[   46.167538]  ? print_irqtrace_events+0x280/0x280
[   46.167546]  ? kvm_clock_read+0x1f/0x30
[   46.167551]  ? kvm_sched_clock_read+0x5/0x10
[   46.167557]  ? sched_clock+0x5/0x10
[   46.167562]  ? sched_clock_cpu+0x18/0x2b0
[   46.167567]  ? kvm_clock_read+0x1f/0x30
[   46.167598]  ? __lock_acquire+0x9c1/0x4b50
[   46.167640]  ? debug_show_all_locks+0x3b0/0x3b0
[   46.167646]  ? kvm_clock_read+0x1f/0x30
[   46.167651]  ? kvm_sched_clock_read+0x5/0x10
[   46.167673]  ? debug_show_all_locks+0x3b0/0x3b0
[   46.167698]  ? is_bpf_text_address+0x87/0x130
[   46.167707]  ? print_irqtrace_events+0x280/0x280
[   46.167714]  ? kvm_clock_read+0x1f/0x30
[   46.167718]  ? kvm_sched_clock_read+0x5/0x10
[   46.167723]  ? sched_clock+0x5/0x10
[   46.167728]  ? sched_clock_cpu+0x18/0x2b0
[   46.167753]  ? get_lock_stats+0x18/0x160
[   46.167877]  ? __lock_is_held+0xcb/0x1a0
[   46.167908]  rtnetlink_rcv_msg+0x575/0xaa0
[   46.167913]  ? kvm_clock_read+0x1f/0x30
[   46.167925]  ? validate_linkmsg+0x900/0x900
[   46.167945]  ? netlink_deliver_tap+0x1cc/0xf30
[   46.167950]  ? kvm_clock_read+0x1f/0x30
[   46.167965]  netlink_rcv_skb+0x13c/0x3a0
[   46.167972]  ? validate_linkmsg+0x900/0x900
[   46.167984]  ? netlink_ack+0xcd0/0xcd0
[   46.168030]  netlink_unicast+0x45a/0x6a0
[   46.168061]  ? netlink_attachskb+0x770/0x770
[   46.168075]  ? import_iovec+0xa8/0x460
[   46.168093]  netlink_sendmsg+0x68e/0xdf0
[   46.168127]  ? netlink_unicast+0x6a0/0x6a0
[   46.168133]  ? copy_msghdr_from_user+0x216/0x350
[   46.168160]  ? netlink_unicast+0x6a0/0x6a0
[   46.168168]  sock_sendmsg+0xdb/0x160
[   46.168193]  ___sys_sendmsg+0x6b3/0xbd0
[   46.168207]  ? copy_msghdr_from_user+0x350/0x350
[   46.168221]  ? do_raw_spin_unlock+0xae/0x310
[   46.168248]  ? _raw_spin_unlock+0x2e/0x50
[   46.168257]  ? __handle_mm_fault+0xb65/0x2e90
[   46.168278]  ? handle_mm_fault+0x28f/0xa70
[   46.168284]  ? kvm_clock_read+0x1f/0x30
[   46.168289]  ? kvm_sched_clock_read+0x5/0x10
[   46.168303]  ? __do_page_fault+0x549/0xd00
[   46.168308]  ? kvm_clock_read+0x1f/0x30
[   46.168313]  ? kvm_sched_clock_read+0x5/0x10
[   46.168318]  ? sched_clock+0x5/0x10
[   46.168324]  ? sched_clock_cpu+0x18/0x2b0
[   46.168336]  ? __fget_light+0x5c/0x280
[   46.168357]  ? __sys_sendmsg+0xd2/0x170
[   46.168362]  __sys_sendmsg+0xd2/0x170
[   46.168371]  ? __ia32_sys_shutdown+0x90/0x90
[   46.168382]  ? handle_mm_fault+0x363/0xa70
[   46.168397]  ? up_read+0x1c/0x130
[   46.168403]  ? __do_page_fault+0x549/0xd00
[   46.168443]  ? do_syscall_64+0x18/0x540
[   46.168459]  do_syscall_64+0xa4/0x540
[   46.168470]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
[   46.168477] RIP: 0033:0x7fa59e680087
[   46.168481] Code: 64 89 02 48 c7 c0 ff ff ff ff eb b9 0f 1f 80 00 00 
00 00 8b 05 aa 97 2c 00 48 63 d2 48 63 ff 85 c0 75 18 b8 2e 00 00 00 0f 
05 <48> 3d 00 f0 ff ff 77 59 f3 c3 0f 1f 80 00 00 00 00 53 48 89 f3 48
[   46.168717] RSP: 002b:00007ffe83f2fef8 EFLAGS: 00000246 ORIG_RAX: 
000000000000002e
[   46.168726] RAX: ffffffffffffffda RBX: 00000000006744c0 RCX: 
00007fa59e680087
[   46.168731] RDX: 0000000000000000 RSI: 00007ffe83f2ff40 RDI: 
0000000000000003
[   46.168735] RBP: 000000005b5d727c R08: 0000000000000001 R09: 
fefefeff77686d74
[   46.168740] R10: 0000000000000006 R11: 0000000000000246 R12: 
00007ffe83f38000
[   46.168744] R13: 0000000000000000 R14: 00007ffe83f38728 R15: 
00007ffe83f37fd8

[   46.168778] Allocated by task 499:
[   46.168784]  kasan_kmalloc+0xa0/0xd0
[   46.168789]  __kmalloc+0x191/0x3a0
[   46.168795]  mpi_powm+0x956/0x2360
[   46.168801]  rsa_enc+0x1f0/0x3a0
[   46.168806]  pkcs1pad_verify+0x4c4/0x750
[   46.168815]  public_key_verify_signature+0x58b/0xac0
[   46.168821]  pkcs7_validate_trust+0x3bd/0x710
[   46.168830]  verify_pkcs7_signature+0xe8/0x1b0
[   46.168837]  mod_verify_sig+0x1d4/0x2a0
[   46.168842]  load_module+0x1689/0x6590
[   46.168847]  __do_sys_finit_module+0x192/0x1c0
[   46.168852]  do_syscall_64+0xa4/0x540
[   46.168857]  entry_SYSCALL_64_after_hwframe+0x49/0xbe

[   46.168864] Freed by task 499:
[   46.168869]  __kasan_slab_free+0x11d/0x160
[   46.168874]  kfree+0x151/0x650
[   46.168878]  mpi_powm+0x621/0x2360
[   46.168883]  rsa_enc+0x1f0/0x3a0
[   46.168887]  pkcs1pad_verify+0x4c4/0x750
[   46.168892]  public_key_verify_signature+0x58b/0xac0
[   46.168897]  pkcs7_validate_trust+0x3bd/0x710
[   46.168902]  verify_pkcs7_signature+0xe8/0x1b0
[   46.168906]  mod_verify_sig+0x1d4/0x2a0
[   46.168911]  load_module+0x1689/0x6590
[   46.168916]  __do_sys_finit_module+0x192/0x1c0
[   46.168921]  do_syscall_64+0xa4/0x540
[   46.168925]  entry_SYSCALL_64_after_hwframe+0x49/0xbe

[   46.168933] The buggy address belongs to the object at ffff8803400da588
                 which belongs to the cache kmalloc-2048 of size 2048
[   46.168938] The buggy address is located 128 bytes inside of
                 2048-byte region [ffff8803400da588, ffff8803400dad88)
[   46.168942] The buggy address belongs to the page:
[   46.168947] page:ffffea000d003600 count:1 mapcount:0 
mapping:ffff880355011540 index:0x0 compound_mapcount: 0
[   46.169272] flags: 0x2fffff80008100(slab|head)
[   46.169358] raw: 002fffff80008100 ffffea000d13a608 ffffea000d43e608 
ffff880355011540
[   46.169364] raw: 0000000000000000 00000000000d000d 00000001ffffffff 
0000000000000000
[   46.169369] page dumped because: kasan: bad access detected

[   46.169377] Memory state around the buggy address:
[   46.169383]  ffff8803400da500: fc fc fc fc fc fc fc fc fc fc fc fc fc 
fc fc fc
[   46.169388]  ffff8803400da580: fc fb fb fb fb fb fb fb fb fb fb fb fb 
fb fb fb
[   46.169394] >ffff8803400da600: fb fb fb fb fb fb fb fb fb fb fb fb fb 
fb fb fb
[   46.169398]                       ^
[   46.169403]  ffff8803400da680: fb fb fb fb fb fb fb fb fb fb fb fb fb 
fb fb fb
[   46.169408]  ffff8803400da700: fb fb fb fb fb fb fb fb fb fb fb fb fb 
fb fb fb
[   46.169427] 
==================================================================
[   46.169431] Disabling lock debugging due to kernel taint

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next 0/6] virtio_net: Add ethtool stat items
  2018-08-05 13:15     ` Tariq Toukan
@ 2018-08-05 13:45       ` Tariq Toukan
  2018-08-05 14:22         ` Tariq Toukan
  0 siblings, 1 reply; 15+ messages in thread
From: Tariq Toukan @ 2018-08-05 13:45 UTC (permalink / raw)
  To: David Miller, mst, toshiaki.makita1, makita.toshiaki
  Cc: ranro, netdev, Eran Ben Elisha, virtualization, Maor Gottlieb



On 05/08/2018 4:15 PM, Tariq Toukan wrote:
> 
> 
> On 25/07/2018 10:59 PM, David Miller wrote:
>> From: "Michael S. Tsirkin" <mst@redhat.com>
>> Date: Wed, 25 Jul 2018 12:40:12 +0300
>>
>>> On Mon, Jul 23, 2018 at 11:36:03PM +0900, Toshiaki Makita wrote:
>>>> From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
>>>>
>>>> Add some ethtool stat items useful for performance analysis.
>>>>
>>>> Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
>>>
>>> Series:
>>>
>>> Acked-by: Michael S. Tsirkin <mst@redhat.com>
>>
>> Series applied.
>>
>>> Patch 1 seems appropriate for stable, even though it's minor.
>>
>> Ok, I'll put patch #1 also into 'net' and queue it up for -stable.
>>
>> Thanks.
>>
> 
> Hi,
> Our verification team encountered the following degradation, introduced 
> by this series. Please check KASAN bug report below.
> 
> We tested before and after the series, but didn't bisect within it. We 
> can do if necessary.
> 
> Thanks,
> Tariq
> 

I see this might already be fixed, here:
https://marc.info/?l=linux-netdev&m=153335713407532&w=2

Verifying...

> 
> [   46.166544] BUG: KASAN: use-after-free in virtnet_poll+0xd9c/0xfd1 
> [virtio_net]
> [   46.166593] Read of size 8 at addr ffff8803400da608 by task ip/1013
> 
> [   46.166603] CPU: 3 PID: 1013 Comm: ip Not tainted 
> 4.18.0-rc6-for-upstream-dbg-2018-07-26_19-45-52-64 #1
> [   46.166606] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), 
> BIOS 1.10.2-1ubuntu1 04/01/2014
> [   46.166609] Call Trace:
> [   46.166613]  <IRQ>
> [   46.166624]  dump_stack+0xf0/0x17b
> [   46.166647]  ? show_regs_print_info+0x5/0x5
> [   46.166654]  ? printk+0x9c/0xc3
> [   46.166661]  ? kmsg_dump_rewind_nolock+0xf5/0xf5
> [   46.166677]  ? virtnet_poll+0xd9c/0xfd1 [virtio_net]
> [   46.166685]  print_address_description+0xea/0x380
> [   46.166701]  ? virtnet_poll+0xd9c/0xfd1 [virtio_net]
> [   46.166711]  kasan_report+0x1dd/0x460
> [   46.166727]  ? virtnet_poll+0xd9c/0xfd1 [virtio_net]
> [   46.166743]  virtnet_poll+0xd9c/0xfd1 [virtio_net]
> [   46.166767]  ? receive_buf+0x2e30/0x2e30 [virtio_net]
> [   46.166796]  ? sched_clock_cpu+0x18/0x2b0
> [   46.166809]  ? print_irqtrace_events+0x280/0x280
> [   46.166817]  ? print_irqtrace_events+0x280/0x280
> [   46.166830]  ? rcu_process_callbacks+0xc5e/0x12d0
> [   46.166838]  ? kvm_clock_read+0x1f/0x30
> [   46.166857]  ? mark_held_locks+0xd5/0x170
> [   46.166867]  ? net_rx_action+0x2aa/0x10e0
> [   46.166882]  net_rx_action+0x4bc/0x10e0
> [   46.166906]  ? napi_complete_done+0x480/0x480
> [   46.166925]  ? print_irqtrace_events+0x280/0x280
> [   46.166935]  ? sched_clock+0x5/0x10
> [   46.166952]  ? __lock_is_held+0xcb/0x1a0
> [   46.166982]  __do_softirq+0x2c4/0xdf4
> [   46.167010]  do_softirq_own_stack+0x2a/0x40
> [   46.167031]  </IRQ>
> [   46.167038]  ? virtnet_napi_enable+0x37/0xa0 [virtio_net]
> [   46.167044]  do_softirq.part.11+0x69/0x70
> [   46.167065]  __local_bh_enable_ip+0x1d9/0x250
> [   46.167076]  virtnet_open+0x13c/0x440 [virtio_net]
> [   46.167099]  __dev_open+0x1cf/0x390
> [   46.167108]  ? dev_set_rx_mode+0x30/0x30
> [   46.167113]  ? __local_bh_enable_ip+0xf7/0x250
> [   46.167124]  ? trace_hardirqs_on_caller+0x38d/0x6c0
> [   46.167130]  ? __dev_change_flags+0x18d/0x630
> [   46.167142]  __dev_change_flags+0x469/0x630
> [   46.167152]  ? dev_set_allmulti+0x10/0x10
> [   46.167157]  ? __lock_acquire+0x9c1/0x4b50
> [   46.167166]  ? print_irqtrace_events+0x280/0x280
> [   46.167174]  ? kvm_clock_read+0x1f/0x30
> [   46.167191]  ? rtnetlink_put_metrics+0x530/0x530
> [   46.167205]  dev_change_flags+0x8b/0x160
> [   46.167236]  do_setlink+0xa17/0x39f0
> [   46.167248]  ? sched_clock_cpu+0x18/0x2b0
> [   46.167267]  ? rtnl_dump_ifinfo+0xd20/0xd20
> [   46.167277]  ? print_irqtrace_events+0x280/0x280
> [   46.167285]  ? kvm_clock_read+0x1f/0x30
> [   46.167316]  ? debug_show_all_locks+0x3b0/0x3b0
> [   46.167321]  ? kvm_sched_clock_read+0x5/0x10
> [   46.167327]  ? sched_clock+0x5/0x10
> [   46.167333]  ? sched_clock_cpu+0x18/0x2b0
> [   46.167382]  ? memset+0x1f/0x40
> [   46.167408]  ? nla_parse+0x8c/0x3f0
> [   46.167419]  ? rtnetlink_put_metrics+0x530/0x530
> [   46.167427]  ? kvm_sched_clock_read+0x5/0x10
> [   46.167433]  ? sched_clock+0x5/0x10
> [   46.167439]  ? sched_clock_cpu+0x18/0x2b0
> [   46.167457]  rtnl_newlink+0x9dc/0x13a0
> [   46.167484]  ? rtnl_link_unregister+0x2b0/0x2b0
> [   46.167513]  ? kvm_clock_read+0x1f/0x30
> [   46.167538]  ? print_irqtrace_events+0x280/0x280
> [   46.167546]  ? kvm_clock_read+0x1f/0x30
> [   46.167551]  ? kvm_sched_clock_read+0x5/0x10
> [   46.167557]  ? sched_clock+0x5/0x10
> [   46.167562]  ? sched_clock_cpu+0x18/0x2b0
> [   46.167567]  ? kvm_clock_read+0x1f/0x30
> [   46.167598]  ? __lock_acquire+0x9c1/0x4b50
> [   46.167640]  ? debug_show_all_locks+0x3b0/0x3b0
> [   46.167646]  ? kvm_clock_read+0x1f/0x30
> [   46.167651]  ? kvm_sched_clock_read+0x5/0x10
> [   46.167673]  ? debug_show_all_locks+0x3b0/0x3b0
> [   46.167698]  ? is_bpf_text_address+0x87/0x130
> [   46.167707]  ? print_irqtrace_events+0x280/0x280
> [   46.167714]  ? kvm_clock_read+0x1f/0x30
> [   46.167718]  ? kvm_sched_clock_read+0x5/0x10
> [   46.167723]  ? sched_clock+0x5/0x10
> [   46.167728]  ? sched_clock_cpu+0x18/0x2b0
> [   46.167753]  ? get_lock_stats+0x18/0x160
> [   46.167877]  ? __lock_is_held+0xcb/0x1a0
> [   46.167908]  rtnetlink_rcv_msg+0x575/0xaa0
> [   46.167913]  ? kvm_clock_read+0x1f/0x30
> [   46.167925]  ? validate_linkmsg+0x900/0x900
> [   46.167945]  ? netlink_deliver_tap+0x1cc/0xf30
> [   46.167950]  ? kvm_clock_read+0x1f/0x30
> [   46.167965]  netlink_rcv_skb+0x13c/0x3a0
> [   46.167972]  ? validate_linkmsg+0x900/0x900
> [   46.167984]  ? netlink_ack+0xcd0/0xcd0
> [   46.168030]  netlink_unicast+0x45a/0x6a0
> [   46.168061]  ? netlink_attachskb+0x770/0x770
> [   46.168075]  ? import_iovec+0xa8/0x460
> [   46.168093]  netlink_sendmsg+0x68e/0xdf0
> [   46.168127]  ? netlink_unicast+0x6a0/0x6a0
> [   46.168133]  ? copy_msghdr_from_user+0x216/0x350
> [   46.168160]  ? netlink_unicast+0x6a0/0x6a0
> [   46.168168]  sock_sendmsg+0xdb/0x160
> [   46.168193]  ___sys_sendmsg+0x6b3/0xbd0
> [   46.168207]  ? copy_msghdr_from_user+0x350/0x350
> [   46.168221]  ? do_raw_spin_unlock+0xae/0x310
> [   46.168248]  ? _raw_spin_unlock+0x2e/0x50
> [   46.168257]  ? __handle_mm_fault+0xb65/0x2e90
> [   46.168278]  ? handle_mm_fault+0x28f/0xa70
> [   46.168284]  ? kvm_clock_read+0x1f/0x30
> [   46.168289]  ? kvm_sched_clock_read+0x5/0x10
> [   46.168303]  ? __do_page_fault+0x549/0xd00
> [   46.168308]  ? kvm_clock_read+0x1f/0x30
> [   46.168313]  ? kvm_sched_clock_read+0x5/0x10
> [   46.168318]  ? sched_clock+0x5/0x10
> [   46.168324]  ? sched_clock_cpu+0x18/0x2b0
> [   46.168336]  ? __fget_light+0x5c/0x280
> [   46.168357]  ? __sys_sendmsg+0xd2/0x170
> [   46.168362]  __sys_sendmsg+0xd2/0x170
> [   46.168371]  ? __ia32_sys_shutdown+0x90/0x90
> [   46.168382]  ? handle_mm_fault+0x363/0xa70
> [   46.168397]  ? up_read+0x1c/0x130
> [   46.168403]  ? __do_page_fault+0x549/0xd00
> [   46.168443]  ? do_syscall_64+0x18/0x540
> [   46.168459]  do_syscall_64+0xa4/0x540
> [   46.168470]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
> [   46.168477] RIP: 0033:0x7fa59e680087
> [   46.168481] Code: 64 89 02 48 c7 c0 ff ff ff ff eb b9 0f 1f 80 00 00 
> 00 00 8b 05 aa 97 2c 00 48 63 d2 48 63 ff 85 c0 75 18 b8 2e 00 00 00 0f 
> 05 <48> 3d 00 f0 ff ff 77 59 f3 c3 0f 1f 80 00 00 00 00 53 48 89 f3 48
> [   46.168717] RSP: 002b:00007ffe83f2fef8 EFLAGS: 00000246 ORIG_RAX: 
> 000000000000002e
> [   46.168726] RAX: ffffffffffffffda RBX: 00000000006744c0 RCX: 
> 00007fa59e680087
> [   46.168731] RDX: 0000000000000000 RSI: 00007ffe83f2ff40 RDI: 
> 0000000000000003
> [   46.168735] RBP: 000000005b5d727c R08: 0000000000000001 R09: 
> fefefeff77686d74
> [   46.168740] R10: 0000000000000006 R11: 0000000000000246 R12: 
> 00007ffe83f38000
> [   46.168744] R13: 0000000000000000 R14: 00007ffe83f38728 R15: 
> 00007ffe83f37fd8
> 
> [   46.168778] Allocated by task 499:
> [   46.168784]  kasan_kmalloc+0xa0/0xd0
> [   46.168789]  __kmalloc+0x191/0x3a0
> [   46.168795]  mpi_powm+0x956/0x2360
> [   46.168801]  rsa_enc+0x1f0/0x3a0
> [   46.168806]  pkcs1pad_verify+0x4c4/0x750
> [   46.168815]  public_key_verify_signature+0x58b/0xac0
> [   46.168821]  pkcs7_validate_trust+0x3bd/0x710
> [   46.168830]  verify_pkcs7_signature+0xe8/0x1b0
> [   46.168837]  mod_verify_sig+0x1d4/0x2a0
> [   46.168842]  load_module+0x1689/0x6590
> [   46.168847]  __do_sys_finit_module+0x192/0x1c0
> [   46.168852]  do_syscall_64+0xa4/0x540
> [   46.168857]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
> 
> [   46.168864] Freed by task 499:
> [   46.168869]  __kasan_slab_free+0x11d/0x160
> [   46.168874]  kfree+0x151/0x650
> [   46.168878]  mpi_powm+0x621/0x2360
> [   46.168883]  rsa_enc+0x1f0/0x3a0
> [   46.168887]  pkcs1pad_verify+0x4c4/0x750
> [   46.168892]  public_key_verify_signature+0x58b/0xac0
> [   46.168897]  pkcs7_validate_trust+0x3bd/0x710
> [   46.168902]  verify_pkcs7_signature+0xe8/0x1b0
> [   46.168906]  mod_verify_sig+0x1d4/0x2a0
> [   46.168911]  load_module+0x1689/0x6590
> [   46.168916]  __do_sys_finit_module+0x192/0x1c0
> [   46.168921]  do_syscall_64+0xa4/0x540
> [   46.168925]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
> 
> [   46.168933] The buggy address belongs to the object at ffff8803400da588
>                  which belongs to the cache kmalloc-2048 of size 2048
> [   46.168938] The buggy address is located 128 bytes inside of
>                  2048-byte region [ffff8803400da588, ffff8803400dad88)
> [   46.168942] The buggy address belongs to the page:
> [   46.168947] page:ffffea000d003600 count:1 mapcount:0 
> mapping:ffff880355011540 index:0x0 compound_mapcount: 0
> [   46.169272] flags: 0x2fffff80008100(slab|head)
> [   46.169358] raw: 002fffff80008100 ffffea000d13a608 ffffea000d43e608 
> ffff880355011540
> [   46.169364] raw: 0000000000000000 00000000000d000d 00000001ffffffff 
> 0000000000000000
> [   46.169369] page dumped because: kasan: bad access detected
> 
> [   46.169377] Memory state around the buggy address:
> [   46.169383]  ffff8803400da500: fc fc fc fc fc fc fc fc fc fc fc fc fc 
> fc fc fc
> [   46.169388]  ffff8803400da580: fc fb fb fb fb fb fb fb fb fb fb fb fb 
> fb fb fb
> [   46.169394] >ffff8803400da600: fb fb fb fb fb fb fb fb fb fb fb fb fb 
> fb fb fb
> [   46.169398]                       ^
> [   46.169403]  ffff8803400da680: fb fb fb fb fb fb fb fb fb fb fb fb fb 
> fb fb fb
> [   46.169408]  ffff8803400da700: fb fb fb fb fb fb fb fb fb fb fb fb fb 
> fb fb fb
> [   46.169427] 
> ==================================================================
> [   46.169431] Disabling lock debugging due to kernel taint
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next 0/6] virtio_net: Add ethtool stat items
  2018-08-05 13:45       ` Tariq Toukan
@ 2018-08-05 14:22         ` Tariq Toukan
  0 siblings, 0 replies; 15+ messages in thread
From: Tariq Toukan @ 2018-08-05 14:22 UTC (permalink / raw)
  To: David Miller, mst, toshiaki.makita1, makita.toshiaki
  Cc: ranro, netdev, Eran Ben Elisha, virtualization, Maor Gottlieb



On 05/08/2018 4:45 PM, Tariq Toukan wrote:
> 
> 
> On 05/08/2018 4:15 PM, Tariq Toukan wrote:
>>
>>
>> On 25/07/2018 10:59 PM, David Miller wrote:
>>> From: "Michael S. Tsirkin" <mst@redhat.com>
>>> Date: Wed, 25 Jul 2018 12:40:12 +0300
>>>
>>>> On Mon, Jul 23, 2018 at 11:36:03PM +0900, Toshiaki Makita wrote:
>>>>> From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
>>>>>
>>>>> Add some ethtool stat items useful for performance analysis.
>>>>>
>>>>> Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
>>>>
>>>> Series:
>>>>
>>>> Acked-by: Michael S. Tsirkin <mst@redhat.com>
>>>
>>> Series applied.
>>>
>>>> Patch 1 seems appropriate for stable, even though it's minor.
>>>
>>> Ok, I'll put patch #1 also into 'net' and queue it up for -stable.
>>>
>>> Thanks.
>>>
>>
>> Hi,
>> Our verification team encountered the following degradation, 
>> introduced by this series. Please check KASAN bug report below.
>>
>> We tested before and after the series, but didn't bisect within it. We 
>> can do if necessary.
>>
>> Thanks,
>> Tariq
>>
> 
> I see this might already be fixed, here:
> https://marc.info/?l=linux-netdev&m=153335713407532&w=2
> 
> Verifying...
> 

No repro when applying this fix.

Thanks,
Tariq

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-08-05 14:22 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-23 14:36 [PATCH net-next 0/6] virtio_net: Add ethtool stat items Toshiaki Makita
2018-07-23 14:36 ` [PATCH net-next 1/6] virtio_net: Fix incosistent received bytes counter Toshiaki Makita
2018-07-23 14:36 ` [PATCH net-next 2/6] virtio_net: Use temporary storage for accounting rx stats Toshiaki Makita
2018-07-23 14:36 ` [PATCH net-next 3/6] virtio_net: Make drop counter per-queue Toshiaki Makita
2018-07-23 14:36 ` [PATCH net-next 4/6] virtio_net: Factor out the logic to determine xdp sq Toshiaki Makita
2018-07-23 14:36 ` [PATCH net-next 5/6] virtio_net: Add XDP related stats Toshiaki Makita
2018-07-23 14:36 ` [PATCH net-next 6/6] virtio_net: Add kick stats Toshiaki Makita
2018-07-25  2:06 ` [PATCH net-next 0/6] virtio_net: Add ethtool stat items David Miller
2018-07-25  9:40 ` Michael S. Tsirkin
2018-07-25  9:40 ` Michael S. Tsirkin
2018-07-25 19:59   ` David Miller
2018-07-25 19:59   ` David Miller
2018-08-05 13:15     ` Tariq Toukan
2018-08-05 13:45       ` Tariq Toukan
2018-08-05 14:22         ` Tariq Toukan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.