Resending. 

============================================================
commit 89681d3655f27d758537ae01a02d500deee1acd6
Author: Mohsin Shaikh <mohsinsha...@niometrics.com>
Date:   Thu Apr 9 12:19:45 2020 +0800

    net/mlx5: Use open/read/close for reading ib stat
    
    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.
    
    The details can be found here:
    https://bugs.dpdk.org/show_bug.cgi?id=440
    
    Bugzilla ID: 440

diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c
index 205e4fe..91ac933 100644
--- a/drivers/net/mlx5/mlx5_stats.c
+++ b/drivers/net/mlx5/mlx5_stats.c
@@ -8,6 +8,8 @@
 #include <linux/ethtool.h>
 #include <stdint.h>
 #include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
 
 #include <rte_ethdev_driver.h>
 #include <rte_common.h>
@@ -139,20 +141,22 @@
 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[32];
+                       ssize_t n = read(fd, buf, sizeof(buf));
+                       close(fd);
+                       if (n != -1) {
+                               sscanf(buf, "%" SCNu64, stat);
                                return;
+                       }
                }
        }
        *stat = 0;

============================================================

Thanks,
Mohsin

> On 9 Apr 2020, at 12:26 PM, Mohsin Shaikh <mohsinsha...@niometrics.com> wrote:
> 
> Hi Alexander,
> 
> Thank you for your quick response. Please find attached the patch for bug 
> 440. 
> 
> - Mohsin
> 
> 
> 
>> On 9 Apr 2020, at 1:07 AM, bugzi...@dpdk.org wrote:
>> 
>> https://bugs.dpdk.org/show_bug.cgi?id=440
>> 
>> Alexander Kozyrev (akozy...@mellanox.com) changed:
>> 
>>          What    |Removed                     |Added
>> ----------------------------------------------------------------------------
>>    Ever confirmed|0                           |1
>>            Status|UNCONFIRMED                 |CONFIRMED
>>                CC|                            |akozy...@mellanox.com
>> 
>> --- Comment #1 from Alexander Kozyrev (akozy...@mellanox.com) ---
>> Hi Mohsin, thank you for the problem description and especially for the 
>> patch.
>> Would you mind sending this patch to DPDK mailing list so we can integrate 
>> it?
>> The patch looks really good to me. The only small thing I would like to 
>> change.
>> Could you please use SCNu64 macro instead of "%lu" in the sscanf function?
>>   sscanf(buf, "%" SCNu64, stat);
>> 
>> -- 
>> You are receiving this mail because:
>> You reported the bug.
> 

Reply via email to