From: Mohsin Shaikh Date: Thu, 9 Apr 2020 20:37:06 +0000 (+0800) Subject: net/mlx5: use open/read/close for ib stats query X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=00437823cb80b8fa87dbe61becc07bd42ee98549;p=dpdk.git net/mlx5: use open/read/close for ib stats query 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 Cc: stable@dpdk.org Signed-off-by: Mohsin Shaikh Reviewed-by: Alexander Kozyrev Acked-by: Viacheslav Ovsiienko --- diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c index 5bc6fa6aa1..b4ca6922a4 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 #include #include #include #include #include +#include #include #include @@ -142,20 +144,23 @@ static const unsigned int xstats_n = RTE_DIM(mlx5_counters_init); static inline int mlx5_read_ib_stat(struct mlx5_priv *priv, const char *ctr_name, uint64_t *stat) { - FILE *file; + int fd; + if (priv->sh) { MKSTR(path, "%s/ports/%d/hw_counters/%s", priv->sh->ibdev_path, priv->ibv_port, ctr_name); - - file = fopen(path, "rb"); - if (file) { - int n = fscanf(file, "%" SCNu64, stat); - - fclose(file); - if (n == 1) + fd = open(path, O_RDONLY); + if (fd != -1) { + char buf[21] = {'\0'}; + ssize_t n = read(fd, buf, sizeof(buf)); + + close(fd); + if (n != -1) { + *stat = strtoull(buf, NULL, 10); return 0; + } } } *stat = 0;