<div dir="ltr">At the end I tried the pidfd_getfd syscall that is working really fine and giving me back a "clone" fd of an fd in that was opened from another process. I tested it opening a text file in the first process  and after cloning the fd , I could really read the file also in the second process. <div>Now the weird thing:</div><div>1) In the first process I allocate- a huge page, then get the fd</div><div>2) In the second process I get my "clone" fd and do an mmap, it works but if I write on that memory, the first process cannot see what I wrote</div><div>  </div><div>int second_process(int remote_pid, int remote_mem_fd) {</div><div><br></div><div>        printf("remote_pid %d remote_mem_fd %d\n", remote_pid, remote_mem_fd);<br>        int pidfd = syscall(__NR_pidfd_open, remote_pid, 0);<br><br>        int my_mem_fd = syscall(438, pidfd, remote_mem_fd, 0);<br>        printf("my_mem_fd %d\n", my_mem_fd);   // This is nice<br><br>        int flags = MAP_SHARED | MAP_HUGETLB | (30 << MAP_HUGE_SHIFT);<br>        uint64_t* addr = (uint64_t*) mmap(NULL, 1024 * 1024 * 1024, PROT_READ|PROT_WRITE, flags, my_mem_fd, 0);<br>        if (addr == -1)<br>            perror("mmap");<br>        *addr = 0x0101010102020202;<br></div><div>}</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno gio 14 apr 2022 alle ore 21:51 Antonio Di Bacco <<a href="mailto:a.dibacco.ks@gmail.com">a.dibacco.ks@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno gio 14 apr 2022 alle ore 21:01 Dmitry Kozlyuk <<a href="mailto:dmitry.kozliuk@gmail.com" target="_blank">dmitry.kozliuk@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">2022-04-14 10:20 (UTC+0200), Antonio Di Bacco:<br>
[...]<br>
> Ok, after having a look to memif I managed to exchange the fd  between the<br>
> two processes and it works.<br>
> Anyway the procedure seems a little bit clunky and I think I'm going to use<br>
> the new SYSCALL pidfd_getfd<br>
> to achieve the same result.  In your opinion this method (getfd_pidfd)<br>
> could also work if the two DPDK processes<br>
> are inside different docker containers?<br>
<br>
Honestly, I've just learned about pidfd_getfd() from you.<br>
But I know that containers use PID namespaces, so there's a question<br>
how you will obtain the pidfd of a process in another container.<br>
<br>
In general, any method of sharing FD will work.<br>
Remember that you also need offset and size.<br>
Given that some channel is required to share those,<br>
I think Unix domain socket is still the preferred way.<br>
<br>
> Or is there another mechanims like using handles to hugepages present in<br>
> the filesystem to share between two<br>
> different containers?<br>
<br>
FD is needed for mmap().<br>
You need to either pass the FD or open() the same hugepage file by path.<br>
I advise against using paths because they are not a part of DPDK API contract.<br></blockquote><div><br></div><div>Thank you very much Dmitry, your answers are always enlightening.</div><div>I'm going to ask a different question on the <a href="http://dpdk.org" target="_blank">dpdk.org</a> about the best practice to share memory between two dpdk processes running in different containers. </div></div></div>
</blockquote></div>