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 93AB7A0597; Thu, 9 Apr 2020 22:39:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0849A1C23C; Thu, 9 Apr 2020 22:39:44 +0200 (CEST) Received: from integrity.niometrics.com (integrity.niometrics.com [42.61.70.122]) by dpdk.org (Postfix) with ESMTP id 84C991C204; Thu, 9 Apr 2020 22:39:42 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by integrity.niometrics.com (Postfix) with ESMTP id 4573E409CBA9; Fri, 10 Apr 2020 04:39:40 +0800 (+08) DKIM-Filter: OpenDKIM Filter v2.11.0 integrity.niometrics.com 4573E409CBA9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niometrics.com; s=default; t=1586464781; bh=k3+1DSvtM1jcHtI5o4LYJdb5B7Lmsl8XQEfbM1f4Kv4=; h=From:To:Cc:Subject:Date:From; b=ENv7xFT4zg4v3TTvIxTsESTzU200s+Cvla7hanABSS6jsI9B1SKuzVT6+LuvxeOtB HlLiJld3bJzhmJ9oJoSZhE/3BMXn2DklXrtmNIpkhVnLlCrdHnlimyy2JwLFqZsBXs vJlyPRB0Q+6oo9Co35dryfVDVzKCKjjqJa8HWHxE= X-Virus-Scanned: amavisd-new at niometrics.com Received: from integrity.niometrics.com ([127.0.0.1]) by localhost (integrity.niometrics.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id djwhH-_LQsry; Fri, 10 Apr 2020 04:39:40 +0800 (+08) Received: from monkey-island.localdomain (unknown [10.15.0.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by integrity.niometrics.com (Postfix) with ESMTPSA id DF9CC409CBA8; Fri, 10 Apr 2020 04:39:38 +0800 (+08) DMARC-Filter: OpenDMARC Filter v1.3.2 integrity.niometrics.com DF9CC409CBA8 DKIM-Filter: OpenDKIM Filter v2.11.0 integrity.niometrics.com DF9CC409CBA8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niometrics.com; s=default; t=1586464779; bh=k3+1DSvtM1jcHtI5o4LYJdb5B7Lmsl8XQEfbM1f4Kv4=; h=From:To:Cc:Subject:Date:From; b=Zpf9nyorkMUOzztcaK8tArYueUxVy1zKfIayyiVo9TyffRIo0qpvMSu1Ba0U7IIss XH33+g0Lf7VMs6GgRcEZ60OqVVcIGl2WpboyxFC97Dtd4DKyrYJ2JCHkybR43+FiH3 fiSvrPhdceoonFX1lrpO9jP5s0Lm/bqI3qjIKHSQ= From: Mohsin Shaikh To: dev@dpdk.org Cc: stable@dpdk.org, akozyrev@mellanox.com, Mohsin Shaikh Date: Fri, 10 Apr 2020 04:37:06 +0800 Message-Id: <1586464626-12958-1-git-send-email-mohsinshaikh@niometrics.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-1.1 required=3.5 tests=ALL_TRUSTED, AWL, DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on integrity.niometrics.com Subject: [dpdk-dev] [PATCH] net/mlx5: use open/read/close for reading ib stat X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" fgets(3)/fread(3)/fscanf(3) etc. use mmap(2)/munmap(2) which leads to TLB shootdown 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 --- drivers/net/mlx5/mlx5_stats.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c index 7603502..b2c09d8 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 inline void 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; + } } } *stat = 0; -- 1.8.3.1