Shared memory between two primary DPDK processes
Dmitry Kozlyuk
dmitry.kozliuk at gmail.com
Mon Apr 18 21:08:14 CEST 2022
2022-04-18 19:53 (UTC+0200), Antonio Di Bacco:
> Another info to add:
>
> The process that allocates the 1GB page has this map:
> antodib at Ubuntu-20.04-5:: /proc> sudo cat /proc/27812/maps | grep huge
> 140000000-180000000 rw-s 00000000 00:46 97193
> /dev/huge1G/rtemap_0
>
> while the process that maps the 1GB page (--file-prefix p2) has this maps,
> is stealing a new page?
> antodib at Ubuntu-20.04-5:: /proc> sudo cat /proc/27906/maps | grep huge
> 140000000-180000000 rw-s 00000000 00:46 113170
> /dev/huge1G/p2map_0
> 7f7bc0000000-7f7c00000000 rw-s 00000000 00:46 97193
> /dev/huge1G/rtemap_0
>
> Il giorno lun 18 apr 2022 alle ore 19:34 Antonio Di Bacco <
> a.dibacco.ks at gmail.com> ha scritto:
>
> > 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.
> > Now the weird thing:
> > 1) In the first process I allocate- a huge page, then get the fd
> > 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
> >
> > int second_process(int remote_pid, int remote_mem_fd) {
> >
> > printf("remote_pid %d remote_mem_fd %d\n", remote_pid,
> > remote_mem_fd);
> > int pidfd = syscall(__NR_pidfd_open, remote_pid, 0);
> >
> > int my_mem_fd = syscall(438, pidfd, remote_mem_fd, 0);
> > printf("my_mem_fd %d\n", my_mem_fd); // This is nice
> >
> > int flags = MAP_SHARED | MAP_HUGETLB | (30 << MAP_HUGE_SHIFT);
> > uint64_t* addr = (uint64_t*) mmap(NULL, 1024 * 1024 * 1024,
> > PROT_READ|PROT_WRITE, flags, my_mem_fd, 0);
> > if (addr == -1)
> > perror("mmap");
> > *addr = 0x0101010102020202;
> > }
I don't quite understand what do you mean by "stealing a new page",
but it shows that the second process has mapped the same hugepage file
as the first process (just confirms that mmap indeed works).
rte_mem_virt2phy() can tell if the physical address
is really the same in both processes.
Are you sure that the 2nd process writes before the 1st one reads?
Are you sure read/write is not optimized out?
More information about the users
mailing list