Skip to contentSkip to conversation

pci: force address of mappings in secondary process

RFC In review Stephen Hemminger 5 participants 11 messages Jul 11, 2017 – Jan 28, 2019

lore
Share & tools
lore
#0 lore raw

RFC 1/1 pci: force address of mappings in secondary process

The PCI memory resources in the secondary process should be in the exact same location as the primary process. Otherwise there is a risk of a stray pointer.

Not sure if this is right, but it looks like a potential problem.

---
 lib/librte_eal/common/eal_common_pci_uio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/eal_common_pci_uio.c +1 -1
index 367a6816dcb8..2156b1a436c4 100644
@@ -77,7 +77,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
 
 			void *mapaddr = pci_map_resource(uio_res->maps[i].addr,
 					fd, (off_t)uio_res->maps[i].offset,
-					(size_t)uio_res->maps[i].size, 0);
+					(size_t)uio_res->maps[i].size, MAP_FIXED);
 			/* fd is not needed in slave process, close it */
 			close(fd);
 			if (mapaddr != uio_res->maps[i].addr) {
Signature · 1 line
2.11.0
#1 lore raw
Quoted 38 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, July 11, 2017 9:13 AM
To: [email protected]
Cc: Stephen Hemminger
Subject: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

The PCI memory resources in the secondary process should be in the exact same location as the primary process. Otherwise there is a risk of a stray pointer.

Not sure if this is right, but it looks like a potential problem.

---
 lib/librte_eal/common/eal_common_pci_uio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/eal_common_pci_uio.c +1 -1
index 367a6816dcb8..2156b1a436c4 100644
@@ -77,7 +77,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
 
 			void *mapaddr = pci_map_resource(uio_res-
 >maps[i].addr,
 					fd, (off_t)uio_res->maps[i].offset,
-					(size_t)uio_res->maps[i].size, 0);
+					(size_t)uio_res->maps[i].size,
 MAP_FIXED);
 			/* fd is not needed in slave process, close it */
lib/librte_eal/common/eal_common_pci_uio.c +0 -1
 			close(fd);
 			if (mapaddr != uio_res->maps[i].addr) {
--
Quoted 1 line

2.11.0

+1 for this RFC. I also once encounter such problem, and I use the same way to solve it. The addr parameter of mmap() syscall is only a hint instead of a must even the VMA is not occupied yet.

Thanks,
Jianfeng

#2 lore raw
Quoted 40 lines · Jianfeng
Quoted 34 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, July 11, 2017 9:13 AM
To: [email protected]
Cc: Stephen Hemminger
Subject: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

The PCI memory resources in the secondary process should be in the exact same location as the primary process. Otherwise there is a risk of a stray pointer.

Not sure if this is right, but it looks like a potential problem.

---
  lib/librte_eal/common/eal_common_pci_uio.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/eal_common_pci_uio.c +1 -1
index 367a6816dcb8..2156b1a436c4 100644
@@ -77,7 +77,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
 
  			void *mapaddr = pci_map_resource(uio_res-
 > maps[i].addr,
  					fd, (off_t)uio_res->maps[i].offset,
-					(size_t)uio_res->maps[i].size, 0);
+					(size_t)uio_res->maps[i].size,
 MAP_FIXED);
  			/* fd is not needed in slave process, close it */
Quoted 4 lines

close(fd);
if (mapaddr != uio_res->maps[i].addr) {
--
2.11.0

+1 for this RFC. I also once encounter such problem, and I use the same way to solve it. The addr parameter of mmap() syscall is only a hint instead of a must even the VMA is not occupied yet.

Quoted 2 lines

Thanks,
Jianfeng

How do you know the VMA is not occupied?

I think the risk here is that the dynamic linker loaded some shared library in that VMA, and forcing MAP_FIXED is not a safe solution. What I have observed is that Linux will return a different VMA than the one hinted when there is already a mapping in the requested/hinted VMA.

I reckon this is a similar issue as we have with the multi-process model when we do not get the VMA requested for the huge-pages.
AFAIK we do not have a robust solution for this issue other than restart the program and hope the dynamic linker does not map anything in the VMA ranges that we need to map from the primary. This is also assuming that the application does not allocate memory and maps things before calling eal_init as it could potentially use VMA ranges that we need in the secondary process.

The proposal for new secondary process model would solve these issues:
http://dpdk.org/ml/archives/dev/2017-May/066147.html

Thanks,
Sergio

#3 lore raw
Quoted 60 lines · On Tue, 11 Jul 2017 12:35:39 +0100 Sergio Gonzalez Monroy…
Quoted 40 lines · Jianfeng
Quoted 34 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, July 11, 2017 9:13 AM
To: [email protected]
Cc: Stephen Hemminger
Subject: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

The PCI memory resources in the secondary process should be in the exact same location as the primary process. Otherwise there is a risk of a stray pointer.

Not sure if this is right, but it looks like a potential problem.

---
  lib/librte_eal/common/eal_common_pci_uio.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/eal_common_pci_uio.c +1 -1
index 367a6816dcb8..2156b1a436c4 100644
@@ -77,7 +77,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
 
  			void *mapaddr = pci_map_resource(uio_res-  
 > maps[i].addr,  
  					fd, (off_t)uio_res->maps[i].offset,
-					(size_t)uio_res->maps[i].size, 0);
+					(size_t)uio_res->maps[i].size,
 MAP_FIXED);
  			/* fd is not needed in slave process, close it */
Quoted 4 lines

close(fd);
if (mapaddr != uio_res->maps[i].addr) {
--
2.11.0

+1 for this RFC. I also once encounter such problem, and I use the same way to solve it. The addr parameter of mmap() syscall is only a hint instead of a must even the VMA is not occupied yet.

Quoted 2 lines

Thanks,
Jianfeng

How do you know the VMA is not occupied?

I think the risk here is that the dynamic linker loaded some shared library in that VMA, and forcing MAP_FIXED is not a safe solution. What I have observed is that Linux will return a different VMA than the one hinted when there is already a mapping in the requested/hinted VMA.

I reckon this is a similar issue as we have with the multi-process model when we do not get the VMA requested for the huge-pages. AFAIK we do not have a robust solution for this issue other than restart the program and hope the dynamic linker does not map anything in the VMA ranges that we need to map from the primary. This is also assuming that the application does not allocate memory and maps things before calling eal_init as it could potentially use VMA ranges that we need in the secondary process.

Quoted 5 lines

The proposal for new secondary process model would solve these issues:
http://dpdk.org/ml/archives/dev/2017-May/066147.html

Thanks,
Sergio

That proposal defeats some of the isolation of secondary process model. The idea is that secondary could be built separately. It is also overly complex and would make a somewhat fragile part of the DPDK, more difficult.

#5 lore raw
In reply to Sergio Gonzalez Monroy
Quoted 49 lines

-----Original Message-----
From: Gonzalez Monroy, Sergio
Sent: Tuesday, July 11, 2017 7:36 PM
To: Tan, Jianfeng; Stephen Hemminger; [email protected]
Subject: Re: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

Quoted 29 lines · Jianfeng
Quoted 29 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, July 11, 2017 9:13 AM
To: [email protected]
Cc: Stephen Hemminger
Subject: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

The PCI memory resources in the secondary process should be in the exact same location as the primary process. Otherwise there is a risk of a stray pointer.

Not sure if this is right, but it looks like a potential problem.

---
  lib/librte_eal/common/eal_common_pci_uio.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/eal_common_pci_uio.c +0 -0
index 367a6816dcb8..2156b1a436c4 100644
@@ -77,7 +77,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
 
  			void *mapaddr = pci_map_resource(uio_res-
 > maps[i].addr,
Quoted 10 lines
Quoted 9 lines
lib/librte_eal/common/eal_common_pci_uio.c +1 -1
  					fd, (off_t)uio_res->maps[i].offset,
-					(size_t)uio_res->maps[i].size, 0);
+					(size_t)uio_res->maps[i].size,
 MAP_FIXED);
  			/* fd is not needed in slave process, close it */

close(fd);
if (mapaddr != uio_res->maps[i].addr) {
--
2.11.0

+1 for this RFC. I also once encounter such problem, and I use the same

Quoted 7 lines

way to solve it. The addr parameter of mmap() syscall is only a hint instead of a must even the VMA is not occupied yet.

Quoted 3 lines

Thanks,
Jianfeng

How do you know the VMA is not occupied?

I did by check /proc/self/maps.

Quoted 5 lines

I think the risk here is that the dynamic linker loaded some shared library in that VMA, and forcing MAP_FIXED is not a safe solution. What I have observed is that Linux will return a different VMA than the one hinted when there is already a mapping in the requested/hinted VMA.

IMO, that's not the target of this RFC. The target is to solve the situation (in current primary/secondary model) that kernel will not use the addr even there's no VMA on that addr. This is my understanding, Stephen, please correct me if I'm wrong.

Quoted 9 lines

I reckon this is a similar issue as we have with the multi-process model when we do not get the VMA requested for the huge-pages. AFAIK we do not have a robust solution for this issue other than restart the program and hope the dynamic linker does not map anything in the VMA ranges that we need to map from the primary. This is also assuming that the application does not allocate memory and maps things before calling eal_init as it could potentially use VMA ranges that we need in the secondary process.

This is another problem.

Quoted 3 lines

The proposal for new secondary process model would solve these issues:
http://dpdk.org/ml/archives/dev/2017-May/066147.html

And yes, this might happen to solve the targeted issue in this RFC. But before the new model is out, this patch seems a workable way for the original issue.

Thanks,
Jianfeng

Quoted 3 lines

Thanks,
Sergio

#4 lore raw
In reply to Stephen Hemminger
Quoted 62 lines · Stephen Hemminger
Quoted 59 lines · On Tue, 11 Jul 2017 12:35:39 +0100 Sergio Gonzalez Monroy…
Quoted 40 lines · Jianfeng
Quoted 36 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, July 11, 2017 9:13 AM
To: [email protected]
Cc: Stephen Hemminger
Subject: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

The PCI memory resources in the secondary process should be in the exact same location as the primary process. Otherwise there is a risk of a stray pointer.

Not sure if this is right, but it looks like a potential problem.

---
   lib/librte_eal/common/eal_common_pci_uio.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/eal_common_pci_uio.c +1 -1
index 367a6816dcb8..2156b1a436c4 100644
@@ -77,7 +77,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
 
   			void *mapaddr = pci_map_resource(uio_res-
 > maps[i].addr,
   					fd, (off_t)uio_res->maps[i].offset,
-					(size_t)uio_res->maps[i].size, 0);
+					(size_t)uio_res->maps[i].size,
 MAP_FIXED);
   			/* fd is not needed in slave process, close it */
   			close(fd);
   			if (mapaddr != uio_res->maps[i].addr) {
Quoted 2 lines

--
2.11.0

+1 for this RFC. I also once encounter such problem, and I use the same way to solve it. The addr parameter of mmap() syscall is only a hint instead of a must even the VMA is not occupied yet.

Quoted 2 lines

Thanks,
Jianfeng

How do you know the VMA is not occupied?

I think the risk here is that the dynamic linker loaded some shared library in that VMA, and forcing MAP_FIXED is not a safe solution. What I have observed is that Linux will return a different VMA than the one hinted when there is already a mapping in the requested/hinted VMA.

I reckon this is a similar issue as we have with the multi-process model when we do not get the VMA requested for the huge-pages. AFAIK we do not have a robust solution for this issue other than restart the program and hope the dynamic linker does not map anything in the VMA ranges that we need to map from the primary. This is also assuming that the application does not allocate memory and maps things before calling eal_init as it could potentially use VMA ranges that we need in the secondary process.

Quoted 9 lines
Quoted 5 lines

The proposal for new secondary process model would solve these issues:
http://dpdk.org/ml/archives/dev/2017-May/066147.html

Thanks,
Sergio

That proposal defeats some of the isolation of secondary process model. The idea is that secondary could be built separately. It is also overly complex and would make a somewhat fragile part of the DPDK, more difficult.

I did not mean/want to change the focus of this thread. Those are valid concerns which should be discussed in its own thread.

Thanks,
Sergio

#6 lore raw
In reply to Tan, Jianfeng
Quoted 52 lines · Jianfeng
Quoted 52 lines

-----Original Message-----
From: Gonzalez Monroy, Sergio
Sent: Tuesday, July 11, 2017 7:36 PM
To: Tan, Jianfeng; Stephen Hemminger; [email protected]
Subject: Re: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

Quoted 29 lines · Jianfeng
Quoted 29 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, July 11, 2017 9:13 AM
To: [email protected]
Cc: Stephen Hemminger
Subject: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

The PCI memory resources in the secondary process should be in the exact same location as the primary process. Otherwise there is a risk of a stray pointer.

Not sure if this is right, but it looks like a potential problem.

---
   lib/librte_eal/common/eal_common_pci_uio.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/eal_common_pci_uio.c +0 -0
index 367a6816dcb8..2156b1a436c4 100644
@@ -77,7 +77,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
 
   			void *mapaddr = pci_map_resource(uio_res-
 > maps[i].addr,
Quoted 10 lines
Quoted 9 lines
lib/librte_eal/common/eal_common_pci_uio.c +1 -1
   					fd, (off_t)uio_res->maps[i].offset,
-					(size_t)uio_res->maps[i].size, 0);
+					(size_t)uio_res->maps[i].size,
 MAP_FIXED);
   			/* fd is not needed in slave process, close it */
   			close(fd);
   			if (mapaddr != uio_res->maps[i].addr) {

--
2.11.0

+1 for this RFC. I also once encounter such problem, and I use the same

way to solve it. The addr parameter of mmap() syscall is only a hint instead of a must even the VMA is not occupied yet.

Quoted 2 lines

Thanks,
Jianfeng

Quoted 8 lines
Quoted 1 line

How do you know the VMA is not occupied?

I did by check /proc/self/maps.

Quoted 4 lines

I think the risk here is that the dynamic linker loaded some shared library in that VMA, and forcing MAP_FIXED is not a safe solution. What I have observed is that Linux will return a different VMA than the one hinted when there is already a mapping in the requested/hinted VMA.

IMO, that's not the target of this RFC. The target is to solve the situation (in current primary/secondary model) that kernel will not use the addr even there's no VMA on that addr. This is my understanding, Stephen, please correct me if I'm wrong.

The point I was trying to make is, that you do not know if there is a mapping or not in that address, and by using MAP_FIXED it will unmap whatever was in there before.

So unless you parse /proc/self/maps and check that the VMA range is not being used, forcing MAP_FIXED is not safe.

Quoted 9 lines
Quoted 8 lines

I reckon this is a similar issue as we have with the multi-process model when we do not get the VMA requested for the huge-pages. AFAIK we do not have a robust solution for this issue other than restart the program and hope the dynamic linker does not map anything in the VMA ranges that we need to map from the primary. This is also assuming that the application does not allocate memory and maps things before calling eal_init as it could potentially use VMA ranges that we need in the secondary process.

This is another problem.

It is the same problem, VMA ranges that we need to map being already used.

Thanks,
Sergio

Quoted 9 lines
Quoted 2 lines

The proposal for new secondary process model would solve these issues:
http://dpdk.org/ml/archives/dev/2017-May/066147.html

And yes, this might happen to solve the targeted issue in this RFC. But before the new model is out, this patch seems a workable way for the original issue.

Thanks,
Jianfeng

Quoted 2 lines

Thanks,
Sergio

#7 lore raw
Quoted 72 lines

-----Original Message-----
From: Gonzalez Monroy, Sergio
Sent: Wednesday, July 12, 2017 3:32 PM
To: Tan, Jianfeng; Stephen Hemminger; [email protected]
Subject: Re: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

Quoted 29 lines · Jianfeng
Quoted 29 lines

-----Original Message-----
From: Gonzalez Monroy, Sergio
Sent: Tuesday, July 11, 2017 7:36 PM
To: Tan, Jianfeng; Stephen Hemminger; [email protected]
Subject: Re: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

Quoted 20 lines · Jianfeng
Quoted 20 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, July 11, 2017 9:13 AM
To: [email protected]
Cc: Stephen Hemminger
Subject: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

The PCI memory resources in the secondary process should be in the exact same location as the primary process. Otherwise there is a risk of a stray pointer.

Not sure if this is right, but it looks like a potential problem.

---
   lib/librte_eal/common/eal_common_pci_uio.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

lib/librte_eal/common/eal_common_pci_uio.c pci_uio_map_secondary(struct rte_pci_device

Quoted 6 lines
lib/librte_eal/common/eal_common_pci_uio.c +0 -0
index 367a6816dcb8..2156b1a436c4 100644
@@ -77,7 +77,7 @@ pci_uio_map_secondary(struct rte_pci_device

*dev)

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 10 lines
lib/librte_eal/common/eal_common_pci_uio.c +1 -1
   			void *mapaddr = pci_map_resource(uio_res-
 > maps[i].addr,
   					fd, (off_t)uio_res->maps[i].offset,
-					(size_t)uio_res->maps[i].size, 0);
+					(size_t)uio_res->maps[i].size,
 MAP_FIXED);
   			/* fd is not needed in slave process, close it */
   			close(fd);
   			if (mapaddr != uio_res->maps[i].addr) {
Quoted 2 lines

--
2.11.0

+1 for this RFC. I also once encounter such problem, and I use the same

Quoted 1 line
Quoted 1 line

way to solve it. The addr parameter of mmap() syscall is only a hint instead

of

Quoted 10 lines
Quoted 4 lines

a must even the VMA is not occupied yet.

Quoted 2 lines

Thanks,
Jianfeng

How do you know the VMA is not occupied?

I did by check /proc/self/maps.

Quoted 4 lines

I think the risk here is that the dynamic linker loaded some shared library in that VMA, and forcing MAP_FIXED is not a safe solution. What I have observed is that Linux will return a different VMA than the one hinted when there is already a mapping in the requested/hinted

VMA.

Quoted 8 lines
Quoted 1 line

IMO, that's not the target of this RFC. The target is to solve the situation (in

current primary/secondary model) that kernel will not use the addr even there's no VMA on that addr. This is my understanding, Stephen, please correct me if I'm wrong.

The point I was trying to make is, that you do not know if there is a mapping or not in that address, and by using MAP_FIXED it will unmap whatever was in there before.

Oh, I missed that if there's conflict, the existing VMA will be unmapped. That's a bad effect.

Quoted 8 lines

So unless you parse /proc/self/maps and check that the VMA range is not being used, forcing MAP_FIXED is not safe.

Quoted 4 lines
Quoted 4 lines

I reckon this is a similar issue as we have with the multi-process model when we do not get the VMA requested for the huge-pages. AFAIK we do not have a robust solution for this issue other than restart the program and hope the dynamic linker does not map anything in the

Quoted 8 lines

VMA

Quoted 5 lines
Quoted 4 lines

ranges that we need to map from the primary. This is also assuming that the application does not allocate memory and maps things before calling eal_init as it could potentially use VMA ranges that we need in the secondary process.

This is another problem.

It is the same problem, VMA ranges that we need to map being already used.

Still two problems from my side:
(1) A VMA already exists on that addr/len range; conflict happens.
(2) Kernel will not allocate the VMA to DPDK even there is no VMA on that ranges; there's no conflict.

Thanks,
Jianfeng

Quoted 16 lines

Thanks,
Sergio

Quoted 3 lines
Quoted 2 lines

The proposal for new secondary process model would solve these issues:
http://dpdk.org/ml/archives/dev/2017-May/066147.html

And yes, this might happen to solve the targeted issue in this RFC. But

before the new model is out, this patch seems a workable way for the original issue.

Quoted 6 lines

Thanks,
Jianfeng

Quoted 2 lines

Thanks,
Sergio

#8 lore raw
Quoted 94 lines · Jianfeng)
Quoted 70 lines

-----Original Message-----
From: Gonzalez Monroy, Sergio
Sent: Wednesday, July 12, 2017 3:32 PM
To: Tan, Jianfeng; Stephen Hemminger; dev at dpdk.org
Subject: Re: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

Quoted 29 lines · Jianfeng
Quoted 29 lines

-----Original Message-----
From: Gonzalez Monroy, Sergio
Sent: Tuesday, July 11, 2017 7:36 PM
To: Tan, Jianfeng; Stephen Hemminger; dev at dpdk.org
Subject: Re: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

Quoted 20 lines · Jianfeng
Quoted 20 lines

-----Original Message-----
From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Stephen Hemminger
Sent: Tuesday, July 11, 2017 9:13 AM
To: dev at dpdk.org
Cc: Stephen Hemminger
Subject: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

The PCI memory resources in the secondary process should be in the exact same location as the primary process. Otherwise there is a risk of a stray pointer.

Not sure if this is right, but it looks like a potential problem.

---
   lib/librte_eal/common/eal_common_pci_uio.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

lib/librte_eal/common/eal_common_pci_uio.c pci_uio_map_secondary(struct rte_pci_device

Quoted 6 lines
lib/librte_eal/common/eal_common_pci_uio.c +0 -0
index 367a6816dcb8..2156b1a436c4 100644
@@ -77,7 +77,7 @@ pci_uio_map_secondary(struct rte_pci_device

*dev)

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 10 lines
lib/librte_eal/common/eal_common_pci_uio.c +1 -1
   			void *mapaddr = pci_map_resource(uio_res-
 > maps[i].addr,
   					fd, (off_t)uio_res->maps[i].offset,
-					(size_t)uio_res->maps[i].size, 0);
+					(size_t)uio_res->maps[i].size,
 MAP_FIXED);
   			/* fd is not needed in slave process, close it */
   			close(fd);
   			if (mapaddr != uio_res->maps[i].addr) {
Quoted 2 lines

--
2.11.0

+1 for this RFC. I also once encounter such problem, and I use the same

Quoted 1 line
Quoted 1 line

way to solve it. The addr parameter of mmap() syscall is only a hint instead

of

Quoted 10 lines
Quoted 4 lines

a must even the VMA is not occupied yet.

Quoted 2 lines

Thanks,
Jianfeng

How do you know the VMA is not occupied?

I did by check /proc/self/maps.

Quoted 4 lines

I think the risk here is that the dynamic linker loaded some shared library in that VMA, and forcing MAP_FIXED is not a safe solution. What I have observed is that Linux will return a different VMA than the one hinted when there is already a mapping in the requested/hinted

VMA.

Quoted 8 lines
Quoted 1 line

IMO, that's not the target of this RFC. The target is to solve the situation (in

current primary/secondary model) that kernel will not use the addr even there's no VMA on that addr. This is my understanding, Stephen, please correct me if I'm wrong.

The point I was trying to make is, that you do not know if there is a mapping or not in that address, and by using MAP_FIXED it will unmap whatever was in there before.

Oh, I missed that if there's conflict, the existing VMA will be unmapped. That's a bad effect.

Quoted 13 lines

So unless you parse /proc/self/maps and check that the VMA range is not being used, forcing MAP_FIXED is not safe.

Quoted 4 lines
Quoted 4 lines

I reckon this is a similar issue as we have with the multi-process model when we do not get the VMA requested for the huge-pages. AFAIK we do not have a robust solution for this issue other than restart the program and hope the dynamic linker does not map anything in the

VMA

Quoted 4 lines
Quoted 4 lines

ranges that we need to map from the primary. This is also assuming that the application does not allocate memory and maps things before calling eal_init as it could potentially use VMA ranges that we need in the secondary process.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

This is another problem.

It is the same problem, VMA ranges that we need to map being already used.

Still two problems from my side:
(1) A VMA already exists on that addr/len range; conflict happens.
(2) Kernel will not allocate the VMA to DPDK even there is no VMA on that ranges; there's no conflict.

Hi Stephen,

Both Sergio & Jianfeng are not active anymore in DPDK, which the discussion seems was going on with. cc'ed Anatoly.

Is this RFC still valid?
Should we expect an update on it?

Thanks,
ferruh

Quoted 22 lines

Thanks,
Jianfeng

Quoted 16 lines

Thanks,
Sergio

Quoted 3 lines
Quoted 2 lines

The proposal for new secondary process model would solve these issues:
http://dpdk.org/ml/archives/dev/2017-May/066147.html

And yes, this might happen to solve the targeted issue in this RFC. But

before the new model is out, this patch seems a workable way for the original issue.

Quoted 6 lines

Thanks,
Jianfeng

Quoted 2 lines

Thanks,
Sergio

#9 lore raw
Quoted 105 lines · On Wed, 23 Jan 2019 19:21:03 +0000 Ferruh Yigit <[email protected]> wrote:
Quoted 94 lines · Jianfeng)
Quoted 70 lines

-----Original Message-----
From: Gonzalez Monroy, Sergio
Sent: Wednesday, July 12, 2017 3:32 PM
To: Tan, Jianfeng; Stephen Hemminger; dev at dpdk.org
Subject: Re: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

Quoted 29 lines · Jianfeng
Quoted 29 lines

-----Original Message-----
From: Gonzalez Monroy, Sergio
Sent: Tuesday, July 11, 2017 7:36 PM
To: Tan, Jianfeng; Stephen Hemminger; dev at dpdk.org
Subject: Re: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

Quoted 20 lines · Jianfeng
Quoted 20 lines

-----Original Message-----
From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Stephen Hemminger
Sent: Tuesday, July 11, 2017 9:13 AM
To: dev at dpdk.org
Cc: Stephen Hemminger
Subject: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

The PCI memory resources in the secondary process should be in the exact same location as the primary process. Otherwise there is a risk of a stray pointer.

Not sure if this is right, but it looks like a potential problem.

---
   lib/librte_eal/common/eal_common_pci_uio.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

lib/librte_eal/common/eal_common_pci_uio.c pci_uio_map_secondary(struct rte_pci_device

Quoted 6 lines
lib/librte_eal/common/eal_common_pci_uio.c +0 -0
index 367a6816dcb8..2156b1a436c4 100644
@@ -77,7 +77,7 @@ pci_uio_map_secondary(struct rte_pci_device  

*dev)

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 10 lines
lib/librte_eal/common/eal_common_pci_uio.c +1 -1
   			void *mapaddr = pci_map_resource(uio_res-  
 > maps[i].addr,  
   					fd, (off_t)uio_res->maps[i].offset,
-					(size_t)uio_res->maps[i].size, 0);
+					(size_t)uio_res->maps[i].size,
 MAP_FIXED);
   			/* fd is not needed in slave process, close it */
   			close(fd);
   			if (mapaddr != uio_res->maps[i].addr) {
Quoted 2 lines

--
2.11.0

+1 for this RFC. I also once encounter such problem, and I use the same

Quoted 1 line
Quoted 1 line

way to solve it. The addr parameter of mmap() syscall is only a hint instead

of

Quoted 10 lines
Quoted 4 lines

a must even the VMA is not occupied yet.

Quoted 2 lines

Thanks,
Jianfeng

How do you know the VMA is not occupied?

I did by check /proc/self/maps.

Quoted 4 lines

I think the risk here is that the dynamic linker loaded some shared library in that VMA, and forcing MAP_FIXED is not a safe solution. What I have observed is that Linux will return a different VMA than the one hinted when there is already a mapping in the requested/hinted

VMA.

Quoted 8 lines
Quoted 1 line

IMO, that's not the target of this RFC. The target is to solve the situation (in

current primary/secondary model) that kernel will not use the addr even there's no VMA on that addr. This is my understanding, Stephen, please correct me if I'm wrong.

The point I was trying to make is, that you do not know if there is a mapping or not in that address, and by using MAP_FIXED it will unmap whatever was in there before.

Oh, I missed that if there's conflict, the existing VMA will be unmapped. That's a bad effect.

Quoted 13 lines

So unless you parse /proc/self/maps and check that the VMA range is not being used, forcing MAP_FIXED is not safe.

Quoted 4 lines
Quoted 4 lines

I reckon this is a similar issue as we have with the multi-process model when we do not get the VMA requested for the huge-pages. AFAIK we do not have a robust solution for this issue other than restart the program and hope the dynamic linker does not map anything in the

VMA

Quoted 4 lines
Quoted 4 lines

ranges that we need to map from the primary. This is also assuming that the application does not allocate memory and maps things before calling eal_init as it could potentially use VMA ranges that we need in the secondary process.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

This is another problem.

It is the same problem, VMA ranges that we need to map being already used.

Still two problems from my side:
(1) A VMA already exists on that addr/len range; conflict happens.
(2) Kernel will not allocate the VMA to DPDK even there is no VMA on that ranges; there's no conflict.

Hi Stephen,

Quoted 32 lines

Both Sergio & Jianfeng are not active anymore in DPDK, which the discussion seems was going on with. cc'ed Anatoly.

Is this RFC still valid?
Should we expect an update on it?

Thanks,
ferruh

Quoted 22 lines

Thanks,
Jianfeng

Quoted 16 lines

Thanks,
Sergio

Quoted 3 lines
Quoted 2 lines

The proposal for new secondary process model would solve these issues:
http://dpdk.org/ml/archives/dev/2017-May/066147.html

And yes, this might happen to solve the targeted issue in this RFC. But

before the new model is out, this patch seems a workable way for the original issue.

Quoted 6 lines

Thanks,
Jianfeng

Quoted 2 lines

Thanks,
Sergio

MAP_FIXED is the wrong solution. If the secondary passes the address it wants, and gets something else that means that is overlapping. The current code returns an error which is the best response.

#10 lore raw
Quoted 141 lines · Stephen Hemminger
Quoted 105 lines · On Wed, 23 Jan 2019 19:21:03 +0000 Ferruh Yigit <[email protected]> wrote:
Quoted 94 lines · Jianfeng)
Quoted 70 lines

-----Original Message-----
From: Gonzalez Monroy, Sergio
Sent: Wednesday, July 12, 2017 3:32 PM
To: Tan, Jianfeng; Stephen Hemminger; dev at dpdk.org
Subject: Re: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

Quoted 29 lines · Jianfeng
Quoted 29 lines

-----Original Message-----
From: Gonzalez Monroy, Sergio
Sent: Tuesday, July 11, 2017 7:36 PM
To: Tan, Jianfeng; Stephen Hemminger; dev at dpdk.org
Subject: Re: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

Quoted 20 lines · Jianfeng
Quoted 20 lines

-----Original Message-----
From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Stephen Hemminger
Sent: Tuesday, July 11, 2017 9:13 AM
To: dev at dpdk.org
Cc: Stephen Hemminger
Subject: [dpdk-dev] [RFC] pci: force address of mappings in secondary process

The PCI memory resources in the secondary process should be in the exact same location as the primary process. Otherwise there is a risk of a stray pointer.

Not sure if this is right, but it looks like a potential problem.

---
    lib/librte_eal/common/eal_common_pci_uio.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

lib/librte_eal/common/eal_common_pci_uio.c pci_uio_map_secondary(struct rte_pci_device

Quoted 6 lines
lib/librte_eal/common/eal_common_pci_uio.c +0 -0
index 367a6816dcb8..2156b1a436c4 100644
@@ -77,7 +77,7 @@ pci_uio_map_secondary(struct rte_pci_device

*dev)

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 10 lines
lib/librte_eal/common/eal_common_pci_uio.c +1 -1
    			void *mapaddr = pci_map_resource(uio_res-
 > maps[i].addr,
    					fd, (off_t)uio_res->maps[i].offset,
-					(size_t)uio_res->maps[i].size, 0);
+					(size_t)uio_res->maps[i].size,
 MAP_FIXED);
    			/* fd is not needed in slave process, close it */
    			close(fd);
    			if (mapaddr != uio_res->maps[i].addr) {
Quoted 2 lines

--
2.11.0

+1 for this RFC. I also once encounter such problem, and I use the same

Quoted 1 line
Quoted 1 line

way to solve it. The addr parameter of mmap() syscall is only a hint instead

of

Quoted 10 lines
Quoted 4 lines

a must even the VMA is not occupied yet.

Quoted 2 lines

Thanks,
Jianfeng

How do you know the VMA is not occupied?

I did by check /proc/self/maps.

Quoted 4 lines

I think the risk here is that the dynamic linker loaded some shared library in that VMA, and forcing MAP_FIXED is not a safe solution. What I have observed is that Linux will return a different VMA than the one hinted when there is already a mapping in the requested/hinted

VMA.

Quoted 8 lines
Quoted 1 line

IMO, that's not the target of this RFC. The target is to solve the situation (in

current primary/secondary model) that kernel will not use the addr even there's no VMA on that addr. This is my understanding, Stephen, please correct me if I'm wrong.

The point I was trying to make is, that you do not know if there is a mapping or not in that address, and by using MAP_FIXED it will unmap whatever was in there before.

Oh, I missed that if there's conflict, the existing VMA will be unmapped. That's a bad effect.

Quoted 13 lines

So unless you parse /proc/self/maps and check that the VMA range is not being used, forcing MAP_FIXED is not safe.

Quoted 4 lines
Quoted 4 lines

I reckon this is a similar issue as we have with the multi-process model when we do not get the VMA requested for the huge-pages. AFAIK we do not have a robust solution for this issue other than restart the program and hope the dynamic linker does not map anything in the

VMA

Quoted 4 lines
Quoted 4 lines

ranges that we need to map from the primary. This is also assuming that the application does not allocate memory and maps things before calling eal_init as it could potentially use VMA ranges that we need in the secondary process.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

This is another problem.

It is the same problem, VMA ranges that we need to map being already used.

Still two problems from my side:
(1) A VMA already exists on that addr/len range; conflict happens.
(2) Kernel will not allocate the VMA to DPDK even there is no VMA on that ranges; there's no conflict.

Hi Stephen,

Quoted 32 lines

Both Sergio & Jianfeng are not active anymore in DPDK, which the discussion seems was going on with. cc'ed Anatoly.

Is this RFC still valid?
Should we expect an update on it?

Thanks,
ferruh

Quoted 22 lines

Thanks,
Jianfeng

Quoted 16 lines

Thanks,
Sergio

Quoted 3 lines
Quoted 2 lines

The proposal for new secondary process model would solve these issues:
http://dpdk.org/ml/archives/dev/2017-May/066147.html

And yes, this might happen to solve the targeted issue in this RFC. But

before the new model is out, this patch seems a workable way for the original issue.

Quoted 6 lines

Thanks,
Jianfeng

Quoted 2 lines

Thanks,
Sergio

Quoted 4 lines

MAP_FIXED is the wrong solution. If the secondary passes the address it wants, and gets something else that means that is overlapping. The current code returns an error which is the best response.

...which is why this: http://patches.dpdk.org/bundle/aburakov/reliable_device_map/

is a better approach :)

Signature · 2 lines
Thanks,
Anatoly