DPDK patches and discussions
 help / color / mirror / Atom feed
* Re: [dpdk-dev] [Bug 440] net/mlx5: Read of "out_of_buffer" using fopen/fscanf/fclose causing TLB shootdowns due to mmap/munmap
       [not found] ` <bug-440-272-PxGGXr8U9C@http.bugs.dpdk.org/>
@ 2020-04-09  4:26   ` Mohsin Shaikh
  2020-04-09  4:44     ` Mohsin Shaikh
  0 siblings, 1 reply; 2+ messages in thread
From: Mohsin Shaikh @ 2020-04-09  4:26 UTC (permalink / raw)
  To: dev; +Cc: akozyrev

[-- Attachment #1: Type: text/plain, Size: 112 bytes --]

Hi Alexander,

Thank you for your quick response. Please find attached the patch for bug 440. 

- Mohsin


[-- Attachment #2: Type: text/plain, Size: 1007 bytes --]



> On 9 Apr 2020, at 1:07 AM, bugzilla@dpdk.org wrote:
> 
> https://bugs.dpdk.org/show_bug.cgi?id=440
> 
> Alexander Kozyrev (akozyrev@mellanox.com) changed:
> 
>           What    |Removed                     |Added
> ----------------------------------------------------------------------------
>     Ever confirmed|0                           |1
>             Status|UNCONFIRMED                 |CONFIRMED
>                 CC|                            |akozyrev@mellanox.com
> 
> --- Comment #1 from Alexander Kozyrev (akozyrev@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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [Bug 440] net/mlx5: Read of "out_of_buffer" using fopen/fscanf/fclose causing TLB shootdowns due to mmap/munmap
  2020-04-09  4:26   ` [dpdk-dev] [Bug 440] net/mlx5: Read of "out_of_buffer" using fopen/fscanf/fclose causing TLB shootdowns due to mmap/munmap Mohsin Shaikh
@ 2020-04-09  4:44     ` Mohsin Shaikh
  0 siblings, 0 replies; 2+ messages in thread
From: Mohsin Shaikh @ 2020-04-09  4:44 UTC (permalink / raw)
  To: dev; +Cc: akozyrev

Resending. 

============================================================
commit 89681d3655f27d758537ae01a02d500deee1acd6
Author: Mohsin Shaikh <mohsinshaikh@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 <mohsinshaikh@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, bugzilla@dpdk.org wrote:
>> 
>> https://bugs.dpdk.org/show_bug.cgi?id=440
>> 
>> Alexander Kozyrev (akozyrev@mellanox.com) changed:
>> 
>>          What    |Removed                     |Added
>> ----------------------------------------------------------------------------
>>    Ever confirmed|0                           |1
>>            Status|UNCONFIRMED                 |CONFIRMED
>>                CC|                            |akozyrev@mellanox.com
>> 
>> --- Comment #1 from Alexander Kozyrev (akozyrev@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.
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-09  4:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-440-272@http.bugs.dpdk.org/>
     [not found] ` <bug-440-272-PxGGXr8U9C@http.bugs.dpdk.org/>
2020-04-09  4:26   ` [dpdk-dev] [Bug 440] net/mlx5: Read of "out_of_buffer" using fopen/fscanf/fclose causing TLB shootdowns due to mmap/munmap Mohsin Shaikh
2020-04-09  4:44     ` Mohsin Shaikh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).