patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Mohsin Shaikh <mohsinshaikh@niometrics.com>
To: stable@dpdk.org
Cc: akozyrev@mellanox.com, Mohsin Shaikh <mohsinshaikh@niometrics.com>
Subject: [dpdk-stable] [PATCH 18.11] net/mlx5: use open/read/close for ib stats query
Date: Wed, 17 Jun 2020 15:18:01 +0800
Message-ID: <1592378281-5174-1-git-send-email-mohsinshaikh@niometrics.com> (raw)

[ upstream commit 00437823cb80b8fa87dbe61becc07bd42ee98549 ]

fgets(3)/fread(3)/fscanf(3) etc. use mmap(2)/munmap(2) which leads
to TLB shutdown interrupts to all DPDK app cores including RX cores.
This can cause packet drops. Use read(2)/write(2) instead.

Bugzilla ID: 440

Signed-off-by: Mohsin Shaikh <mohsinshaikh@niometrics.com>
Reviewed-by: Alexander Kozyrev <akozyrev@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
 drivers/net/mlx5/mlx5_stats.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c
index 6906dc8..0b1fe3d 100644
--- a/drivers/net/mlx5/mlx5_stats.c
+++ b/drivers/net/mlx5/mlx5_stats.c
@@ -3,11 +3,13 @@
  * Copyright 2015 Mellanox Technologies, Ltd
  */
 
+#include <fcntl.h>
 #include <inttypes.h>
 #include <linux/sockios.h>
 #include <linux/ethtool.h>
 #include <stdint.h>
 #include <stdio.h>
+#include <unistd.h>
 
 #include <rte_ethdev_driver.h>
 #include <rte_common.h>
@@ -139,19 +141,24 @@
 static inline void
 mlx5_read_ib_stat(struct mlx5_priv *priv, const char *ctr_name, uint64_t *stat)
 {
-	FILE *file;
+	int fd;
+
 	MKSTR(path, "%s/ports/1/hw_counters/%s",
 		  priv->ibdev_path,
 		  ctr_name);
 
-	file = fopen(path, "rb");
-	if (file) {
-		int n = fscanf(file, "%" SCNu64, stat);
+	fd = open(path, O_RDONLY);
+	if (fd != -1) {
+		char buf[21] = {'\0'};
+		ssize_t n = read(fd, buf, sizeof(buf));
 
-		fclose(file);
-		if (n != 1)
-			stat = 0;
+		close(fd);
+		if (n != -1) {
+			*stat = strtoull(buf, NULL, 10);
+			return;
+		}
 	}
+	*stat = 0;
 }
 
 /**
-- 
1.8.3.1


             reply	other threads:[~2020-06-17  7:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17  7:18 Mohsin Shaikh [this message]
2020-12-08 11:34 [dpdk-stable] [PATCH] [18.11] " Viacheslav Ovsiienko
2020-12-08 12:06 ` Kevin Traynor
2020-12-08 12:41   ` Slava Ovsiienko
2020-12-08 12:52     ` Kevin Traynor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1592378281-5174-1-git-send-email-mohsinshaikh@niometrics.com \
    --to=mohsinshaikh@niometrics.com \
    --cc=akozyrev@mellanox.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git