From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E02DDA09E8 for ; Tue, 8 Dec 2020 13:45:56 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 77A3272D9; Tue, 8 Dec 2020 13:45:55 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 17E1C72D9 for ; Tue, 8 Dec 2020 13:45:53 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@nvidia.com) with SMTP; 8 Dec 2020 14:45:47 +0200 Received: from nvidia.com (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 0B8Cjl4q014031; Tue, 8 Dec 2020 14:45:47 +0200 From: Viacheslav Ovsiienko To: stable@dpdk.org Cc: ktraynor@redhat.com, mohsinshaikh@niometrics.com Date: Tue, 8 Dec 2020 12:45:44 +0000 Message-Id: <1607431544-2831-1-git-send-email-viacheslavo@nvidia.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-stable] [PATCH v2] [18.11] net/mlx5: use open/read/close for ib stats query X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" From: Mohsin Shaikh [ 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 Cc: stable@dpdk.org Signed-off-by: Mohsin Shaikh Reviewed-by: Alexander Kozyrev Acked-by: Viacheslav Ovsiienko --- 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 #include #include #include #include #include +#include #include #include @@ -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