<div id="mailbox-conversation"><div style="font-family:微软雅黑;font-size:14px;color:#000000"><div>Hi Burakov</div><div>Thanks for your reply.</div><div>BTW, about the memory reserved by 
<span style="color: rgb(0, 0, 0); font-family: 'microsoft yahei', sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 22.4px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: rgb(249, 249, 249);">memfd_create-->ftruncate-->mmap, </span></div><div><span style="color: rgb(0, 0, 0); font-family: 'microsoft yahei', sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 22.4px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: rgb(249, 249, 249);">what on earth is the coherency between cache and DDR? In another word, is it cacheable?uncacheable?</span></div><div><font face="microsoft yahei, sans-serif"><span style="background-color: rgb(249, 249, 249);">Is it possible for application to pass this memory to a device with DMA controller(I mean pass the PHY addr coverted by  rte_mem_virt2phy to DMA controller)?</span></font></div><div><font face="microsoft yahei, sans-serif"><span style="background-color: rgb(249, 249, 249);">If yes, how can we ensure the coherency between cache and DDR?</span></font></div><div><br></div><div><br></div><div>static int eal_legacy_hugepage_init(void)</div><div>  memfd = memfd_create("nohuge", 0);<br>...</div><div>    fd = memfd;<br>    flags = MAP_SHARED; //MAP_SHARED means <strong><span style="color: rgb(226, 0, 28);">UNCACHEABLE</span></strong>?</div><div><br></div><div><div id="mailbox-conversation"><br></div></div><div><br class="ignorable"></div></div><blockquote><div><div style="font-size: 70%"> ------------------原始邮件 ------------------</div><div><b>发件人:</b>Burakov, Anatoly <anatoly.burakov@intel.com></div><div><b>发送时间:</b>08/09/22 17:25:35</div><div><b>收件人:</b>Kinsella, Ray <ray.kinsella@intel.com>, Nick Tian <nick.tian@longsailingsemi.com>, users@dpdk.org <users@dpdk.org></div><div><b>主题:</b>RE: About memory coherency</div></div><div><blockquote class="gmail_quote"><meta><meta><style>p.msonormal, li.msonormal, div.msonormal {margin: 0.0in;font-size: 11.0pt;font-family: calibri , sans-serif;}a:link, span.msohyperlink {mso-style-priority: 99;color: #0563c1;text-decoration: underline;}span.emailstyle20 {mso-style-type: personal-reply;font-family: calibri , sans-serif;color: #1f497d;}.msochpdefault {mso-style-type: export-only;font-size: 10.0pt;}div.wordsection1 {page: wordsection1;}</style><div class="WordSection1"><p class="MsoNormal"><span style="color: #1f497d;">There are two different issues at play here.</span></p><p class="MsoNormal"><span style="color: #1f497d;"> </span></p><p class="MsoNormal"><span style="color: #1f497d;">The purpose of “no-huge” flag is to run DPDK without requiring hugepage memory. Originally, this has been done using an anonymous mmap() call – so, this memory was not using any fd’s at all. This presents a problem with vhost-user, because it relies on fd’s for its shared memory implementation. This is what memfd (a relatively recent addition to the kernel) is addressing – it’s enabling usage of vhost-user with no-huge because memfd actually does create an fd to back our memory.</span></p><p class="MsoNormal"><span style="color: #1f497d;"> </span></p><p class="MsoNormal"><span style="color: #1f497d;">That said, while description says “malloc”, it is<i>technically</i> incorrect because there’s no malloc involved in the process. The “malloc” term is simply shorthand for “use regular memory”, and should be understood in that context.</span></p><p class="MsoNormal"><span style="color: #1f497d;"> </span></p><div><p class="MsoNormal"><span style="color: #1f497d;">Thanks,</span></p><p class="MsoNormal"><span style="color: #1f497d;">Anatoly</span></p></div><p class="MsoNormal"><span style="color: #1f497d;"> </span></p><div style="border: none;border-left: solid blue 1.5pt;padding: 0.0in 0.0in 0.0in 4.0pt;"><div><div style="border: none;border-top: solid #e1e1e1 1.0pt;padding: 3.0pt 0.0in 0.0in 0.0in;"><p class="MsoNormal"><b>From:</b> Kinsella, Ray <ray.kinsella@intel.com> <br><b>Sent:</b> Tuesday, August 9, 2022 10:04 AM<br><b>To:</b> Nick Tian <nick.tian@longsailingsemi.com>; users@dpdk.org<br><b>Cc:</b> Burakov, Anatoly <anatoly.burakov@intel.com><br><b>Subject:</b> RE: About memory coherency</p></div></div><p class="MsoNormal"> </p><p class="MsoNormal"><span style="font-size: 12.0pt;font-family: courier new;"> </span></p><p class="MsoNormal"><span style="font-size: 12.0pt;font-family: courier new;">I may be incorrect, but is it not simply the case, that when using the no-huge parameter that MAP_HUGETLB is omitted from flags?</span></p><p class="MsoNormal"><span style="font-size: 12.0pt;font-family: courier new;"> </span></p><p class="MsoNormal"><span style="font-size: 12.0pt;font-family: courier new;">Ray K</span></p><p class="MsoNormal"><span style="font-size: 12.0pt;font-family: courier new;"> </span></p><div style="border: none;border-top: solid #e1e1e1 1.0pt;padding: 3.0pt 0.0in 0.0in 0.0in;"><p class="MsoNormal" style="margin-left: 0.5in;"><b>From:</b> Nick Tian <<a href="mailto:nick.tian@longsailingsemi.com" target="_blank">nick.tian@longsailingsemi.com</a>><br><b>Sent:</b> Tuesday 9 August 2022 03:55<br><b>To:</b> <a href="mailto:users@dpdk.org" target="_blank">users@dpdk.org</a><br><b>Subject:</b> About memory coherency</p></div><p class="MsoNormal" style="margin-left: 0.5in;"><span> </span></p><div id="mailbox-conversation"><div><blockquote style="margin-top: 5.0pt;margin-bottom: 5.0pt;"><div id="mailbox-conversation"><div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">Hi</span></p></div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">I am confusing about the "no-huge" option of DPDK 21.11.</span></p></div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">The dpdk usage said: --no-huge:Use malloc instead of hugetlbfs.</span></p></div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">But when I check the EAL source code, I found some code piece like this:</span></p></div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">It's look like "no-huge" option will lead dpdk use memfd_create-->ftruncate-->mmap to reserve memory</span></p></div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">and then provide to application with rte_malloc.</span></p></div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">Am I right?</span></p></div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">If so, what the "malloc" in "use malloc instead of hugelbfs" refer to?</span></p></div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> </span></p></div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">EAL_memory.c</span></p></div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">static int eal_legacy_hugepage_init(void){</span></p></div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">....</span></p></div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> if (internal_conf->no_hugetlbfs) {<br>....<br>#ifdef MEMFD_SUPPORTED<br>  /* create a memfd and store it in the segment fd table */<br>  memfd = memfd_create("nohuge", 0);<br>......</span></p></div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">  /* we got an fd - now resize it */<br>   if (ftruncate(memfd, internal_conf->memory) < 0) {<br>.....</span></p></div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">   fd = memfd;<br>    flags = MAP_SHARED;   }<br>....<br>  prealloc_addr = msl->base_va;<br>  addr = mmap(prealloc_addr, mem_sz, PROT_READ | PROT_WRITE,<br>    <span style="background: yellow;mso-highlight: yellow;">flags</span> | MAP_FIXED, fd, 0);</span></p></div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">...</span></p></div><div><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> </span></p></div><div><div id="mailbox-conversation"><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> </span></p></div></div></div></div></blockquote></div></div></div></div></blockquote></div></blockquote></div>