From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
To: Antonio Di Bacco <a.dibacco.ks@gmail.com>
Cc: users@dpdk.org
Subject: Re: Shared memory between two primary DPDK processes
Date: Mon, 18 Apr 2022 22:08:14 +0300 [thread overview]
Message-ID: <20220418220814.08bebded@sovereign> (raw)
In-Reply-To: <CAO8pfFktove500UAE1RuepxmA78d4hJCdAkHw8Dsxck9_dSpbQ@mail.gmail.com>
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@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@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@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?
next prev parent reply other threads:[~2022-04-18 19:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-08 12:31 Antonio Di Bacco
2022-04-08 13:26 ` Dmitry Kozlyuk
2022-04-08 14:36 ` Ferruh Yigit
2022-04-08 21:14 ` Antonio Di Bacco
2022-04-08 21:08 ` Antonio Di Bacco
2022-04-11 13:03 ` Antonio Di Bacco
2022-04-11 17:30 ` Dmitry Kozlyuk
2022-04-14 8:20 ` Antonio Di Bacco
2022-04-14 19:01 ` Dmitry Kozlyuk
2022-04-14 19:51 ` Antonio Di Bacco
2022-04-18 17:34 ` Antonio Di Bacco
2022-04-18 17:53 ` Antonio Di Bacco
2022-04-18 19:08 ` Dmitry Kozlyuk [this message]
2022-07-06 22:14 ` Antonio Di Bacco
2022-07-07 0:26 ` Dmitry Kozlyuk
2022-07-07 8:48 ` Antonio Di Bacco
2022-07-07 9:26 ` Dmitry Kozlyuk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220418220814.08bebded@sovereign \
--to=dmitry.kozliuk@gmail.com \
--cc=a.dibacco.ks@gmail.com \
--cc=users@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).