<div id="mailbox-conversation"><div style="font-family:微软雅黑;font-size:14px;color:#000000"><div>
<span style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 25.6px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; font-family: 'Courier New'; font-size: 16px; display: inline !important; background-color: rgb(249, 249, 249);">Hi Jerin</span></div><div><span style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 25.6px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; font-family: 'Courier New'; font-size: 16px; display: inline !important; background-color: rgb(249, 249, 249);">Let me re-organize my question.</span></div><div><span style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 25.6px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; font-family: 'Courier New'; font-size: 16px; display: inline !important; background-color: rgb(249, 249, 249);">We are using DPDK configure with "no-huge" option to implement our ethernet forwarding application.(Since in my HW platform, when I enable huge-page, linux will hang during startup).</span></div><div><span style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 25.6px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; font-family: 'Courier New'; font-size: 16px; display: inline !important; background-color: rgb(249, 249, 249);">After check the EAL source code, I found when I configure DPDK as "No-huge", DPDK will allocate memory with <span style="color: rgb(0, 0, 0); font-family: 'Courier New'; font-size: 16px; 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; float: none; display: inline !important; background-color: rgb(249, 249, 249);">memfd_create-->ftruncate-->mmap.</span></span></div><div><font face="microsoft yahei, sans-serif"><span style="font-family: 'Courier New'; font-size: 16px; background-color: rgb(249, 249, 249);">Our user scenario is like this:</span></font></div><div><font face="microsoft yahei, sans-serif"><span style="font-family: 'Courier New'; font-size: 16px; background-color: rgb(249, 249, 249);">
</span></font><div style="-webkit-tap-highlight-color: transparent; outline: 0px; margin: 5px 0px 0px; padding: 0px; border: 0px; color: rgb(0, 0, 0); font-family: 微软雅黑; 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; background-color: rgb(249, 249, 249);"><p class="MsoNormal" style="-webkit-tap-highlight-color: transparent; outline: none; margin: 1em 0px 1em 36pt;"><span style="-webkit-tap-highlight-color: transparent; outline: 0px; margin: 0px; padding: 0px; border: 0px; color: black; font-family: 'Courier New'; font-size: 16px;">1.Our HW platform does not support IOMMU, it's a ARM A53 based platform.</span></p></div><div style="-webkit-tap-highlight-color: transparent; outline: 0px; margin: 5px 0px 0px; padding: 0px; border: 0px; color: rgb(0, 0, 0); font-family: 微软雅黑; 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; background-color: rgb(249, 249, 249);"><p class="MsoNormal" style="-webkit-tap-highlight-color: transparent; outline: none; margin: 1em 0px 1em 36pt;"><span style="-webkit-tap-highlight-color: transparent; outline: 0px; margin: 0px; padding: 0px; border: 0px; color: black; font-family: 'Courier New'; font-size: 16px;">2.We try to use DPDK to accelerate the ethernet forwarding performance with our own HW accelerator(Let's use HAC as abbreviate).</span></p></div><div style="-webkit-tap-highlight-color: transparent; outline: 0px; margin: 5px 0px 0px; padding: 0px; border: 0px; color: rgb(0, 0, 0); font-family: 微软雅黑; 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; background-color: rgb(249, 249, 249);"><p class="MsoNormal" style="-webkit-tap-highlight-color: transparent; outline: none; margin: 1em 0px 1em 36pt;"><span style="-webkit-tap-highlight-color: transparent; outline: 0px; margin: 0px; padding: 0px; border: 0px; color: black; font-family: 'Courier New'; font-size: 16px;">3.We configure DPDK as "no-huge", and try to use rte_malloc to allocate memory and pass the PHY address of this memory to HAC(write the PHY address to it's register).</span></p></div><div style="-webkit-tap-highlight-color: transparent; outline: 0px; margin: 5px 0px 0px; padding: 0px; border: 0px; color: rgb(0, 0, 0); font-family: 微软雅黑; 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; background-color: rgb(249, 249, 249);"><p class="MsoNormal" style="-webkit-tap-highlight-color: transparent; outline: none; margin: 1em 0px 1em 36pt;"><span style="-webkit-tap-highlight-color: transparent; outline: 0px; margin: 0px; padding: 0px; border: 0px; color: black; font-family: 'Courier New'; font-size: 16px;">4.When HAC receive the ethernet packet, it will parse the packet data and write the descriptor and payload to the memory which allocated in step 3.(The HAC know where to write since we already tell it the physical address with it's register).</span></p></div><div style="-webkit-tap-highlight-color: transparent; outline: 0px; margin: 5px 0px 0px; padding: 0px; border: 0px; color: rgb(0, 0, 0); font-family: 微软雅黑; 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; background-color: rgb(249, 249, 249);"><p class="MsoNormal" style="-webkit-tap-highlight-color: transparent; outline: none; margin: 1em 0px 1em 36pt;"><span style="-webkit-tap-highlight-color: transparent; outline: 0px; margin: 0px; padding: 0px; border: 0px; color: black; font-family: 'Courier New'; font-size: 16px;">5.Application use the virtual address of this memory to read the descriptor and payload to do something else.</span></p></div><div>

</div><font face="microsoft yahei, sans-serif"><span style="font-family: 'Courier New'; font-size: 16px; background-color: rgb(249, 249, 249);">I need the memory I got from rte_malloc be </span></font><span style="font-family: 'Courier New'; font-size: 16px;"><strong><font face="microsoft yahei, sans-serif"><span style="font-size: 16px; font-family: 'Courier New'; color: rgb(226, 0, 28); background-color: rgb(249, 249, 249);">physically continous and uncacheable</span></font></strong></span><font face="microsoft yahei, sans-serif"><span style="font-family: 'Courier New'; font-size: 16px; background-color: rgb(249, 249, 249);"> to avoid In-coherent issue and other issue.</span></font></div><div><font face="microsoft yahei, sans-serif"><span style="font-family: 'Courier New'; font-size: 16px; background-color: rgb(249, 249, 249);">I want to know if the memory allocated as <span style="color: rgb(0, 0, 0); font-family: 'Courier New'; font-size: 16px; 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; float: none; display: inline !important; background-color: rgb(249, 249, 249);">memfd_create-->ftruncate-->mmap is </span></span></font><span style="font-family: 'Courier New'; font-size: 16px;"><strong><font face="microsoft yahei, sans-serif"><span style="font-family: 'Courier New'; font-size: 16px; font-style: normal; font-variant: 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; float: none; color: rgb(226, 0, 28); display: inline !important; background-color: rgb(249, 249, 249);">physically continous and uncacheable</span></font></strong></span><font face="microsoft yahei, sans-serif"><span style="color: rgb(0, 0, 0); font-family: 'Courier New'; 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; float: none; font-size: 16px; display: inline !important; background-color: rgb(249, 249, 249);">.</span></font></div><div><br></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>Kinsella, Ray <ray.kinsella@intel.com></div><div><b>发送时间:</b>08/09/22 19:44:26</div><div><b>收件人:</b>Nick Tian <nick.tian@longsailingsemi.com>, Burakov, Anatoly <anatoly.burakov@intel.com>, users@dpdk.org <users@dpdk.org></div><div><b>抄送:</b>Jason Liu <jason.liu@longsailingsemi.com>, Sunshine Qin <sunshine.qin@longsailingsemi.com>, Mediter Li <mediter.li@longsailingsemi.com>, jerinj@marvell.com <jerinj@marvell.com></div><div><b>主题:</b>RE: 回复:回复:RE: About memory coherency</div></div><div><blockquote class="gmail_quote"><meta><meta><style>p.msonormal, li.msonormal, div.msonormal {margin: 0.0cm;font-size: 11.0pt;font-family: calibri , sans-serif;}a:link, span.msohyperlink {mso-style-priority: 99;color: #0563c1;text-decoration: underline;}span.emailstyle21 {mso-style-type: personal-reply;font-family: courier new;color: windowtext;font-weight: normal;font-style: normal;text-decoration: none none;}.msochpdefault {mso-style-type: export-only;font-family: calibri , sans-serif;mso-fareast-language: en-us;}div.wordsection1 {page: wordsection1;}</style><div class="WordSection1"><p class="MsoNormal"><span style="font-size: 12.0pt;font-family: courier new;mso-fareast-language: en-us;">Hi Nick,</span></p><p class="MsoNormal"><span style="font-size: 12.0pt;font-family: courier new;mso-fareast-language: en-us;"> </span></p><p class="MsoNormal"><span style="font-size: 12.0pt;font-family: courier new;mso-fareast-language: en-us;">Adding Jerin to direct your query. As I think you need some of the ARM guys to chime in here, coherency constraints are ARM is different to Intel.</span></p><p class="MsoNormal"><span style="font-size: 12.0pt;font-family: courier new;mso-fareast-language: en-us;"> </span></p><p class="MsoNormal"><span style="font-size: 12.0pt;font-family: courier new;mso-fareast-language: en-us;">Ray K</span></p><p class="MsoNormal"><span style="font-size: 12.0pt;font-family: courier new;mso-fareast-language: en-us;"> </span></p><div style="border: none;border-top: solid #e1e1e1 1.0pt;padding: 3.0pt 0.0cm 0.0cm 0.0cm;"><p class="MsoNormal" style="margin-left: 36.0pt;"><b><span>From:</span></b><span> Nick Tian <nick.tian@longsailingsemi.com><br><b>Sent:</b> Tuesday 9 August 2022 12:32<br><b>To:</b> Nick Tian <nick.tian@longsailingsemi.com>; Burakov, Anatoly <anatoly.burakov@intel.com>; Kinsella, Ray <ray.kinsella@intel.com>; users@dpdk.org<br><b>Cc:</b> Jason Liu <jason.liu@longsailingsemi.com>; Sunshine Qin <sunshine.qin@longsailingsemi.com>; Mediter Li <mediter.li@longsailingsemi.com><br><b>Subject:</b> </span><span style="font-family: ms gothic;">回复:回复:</span><span>RE: About memory coherency</span></p></div><p class="MsoNormal" style="margin-left: 36.0pt;"> </p><div id="mailbox-conversation"><div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">Hi  Anatoly</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">Let me provide some detail about our user sce</span><span style="font-size: 10.5pt;font-family: arial , sans-serif;color: black;background: #333333;"></span><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">nario.</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">1.Our HW platform does not support IOMMU, it's a ARM A53 based platform.</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">2.We try to use DPDK to accelerate the ethernet forwarding performance with our own HW accelerator(Let use HAC as abbreviate).</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">3.We configure DPDK as "no-huge", and try to use rte_malloc to allocate memory and pass the PHY address of this memory to HAC(write the PHY address to it's register).</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">4.When HAC receive the ethernet packet, it will parse the packet data and write the descriptor and payload to the memory which allocated in step 3.(The HAC know where to write since we already tell it the address with it's register).</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">5.Application use the virtual address of this memory to read the descriptor and payload to do something else.</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">As far as you know, the memory which would be passed to HW should be "uncacheable" and "physically continous" to avoid the in-coherency issue and other issue.</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">(Given 64 bytes start with Address1 has already in CPU L2 cache, in the meantime , HAC write 32 bytes from Address1, then in-coherency issue will happen. since if we read the content from Address1 with software, the software will get</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">the old copy from cache instead of the latest one in DDR).</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> </span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">So, I need to know the memory which allocated by rte_malloc( configure with no-huge) is</span><strong><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: #e2001c;background: white;">UNCACHEABLE/Physically continous </span></strong><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">or not? </span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">We need it</span><strong><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: #e2001c;">physically continous</span></strong><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> and</span><strong><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: #e2001c;">UNCACHEABLE</span></strong><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">,  otherwise it will not suitable for this user scenario.</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> </span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> </span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> </span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><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: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> </span></p></div></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> </span></p></div></div><blockquote style="margin-top: 5.0pt;margin-bottom: 5.0pt;"><div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 7.5pt;">------------------</span><span style="font-size: 7.5pt;font-family: ms gothic;">原始</span><span style="font-size: 7.5pt;font-family: microsoft jhenghei , sans-serif;">邮件</span><span style="font-size: 7.5pt;"> ------------------</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><b><span style="font-family: microsoft jhenghei , sans-serif;">发件人</span>:</b>Nick Tian <<a href="mailto:nick.tian@longsailingsemi.com" target="_blank">nick.tian@longsailingsemi.com</a>></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><b><span style="font-family: microsoft jhenghei , sans-serif;">发送时间</span>:</b>08/09/22 17:41:35</p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><b><span style="font-family: ms gothic;">收件人</span>:</b>Burakov, Anatoly <<a href="mailto:anatoly.burakov@intel.com" target="_blank">anatoly.burakov@intel.com</a>>, Kinsella, Ray <<a href="mailto:ray.kinsella@intel.com" target="_blank">ray.kinsella@intel.com</a>>,<a href="mailto:users@dpdk.org" target="_blank">users@dpdk.org</a> <<a href="mailto:users@dpdk.org" target="_blank">users@dpdk.org</a>></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><b><span style="font-family: ms gothic;">抄送</span>:</b>Jason Liu <<a href="mailto:jason.liu@longsailingsemi.com" target="_blank">jason.liu@longsailingsemi.com</a>>, Sunshine Qin <<a href="mailto:sunshine.qin@longsailingsemi.com" target="_blank">sunshine.qin@longsailingsemi.com</a>>, Mediter Li <<a href="mailto:mediter.li@longsailingsemi.com" target="_blank">mediter.li@longsailingsemi.com</a>></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><b><span style="font-family: ms gothic;">主</span></b><b><span style="font-family: microsoft jhenghei , sans-serif;">题</span>:</b><span style="font-family: ms gothic;">回复:</span>RE: About memory coherency</p></div></div><div><blockquote style="margin-top: 5.0pt;margin-bottom: 5.0pt;"><div id="mailbox-conversation"><div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">Hi Burakov</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">Thanks for your reply.</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">BTW, about the memory reserved by <span style="background: #f9f9f9;">memfd_create-->ftruncate-->mmap, </span></span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;background: #f9f9f9;">what on earth is the coherency between cache and DDR? In another word, is it cacheable?uncacheable?</span><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"></span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;background: #f9f9f9;">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><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"></span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;background: #f9f9f9;">If yes, how can we ensure the coherency between cache and DDR?</span><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"></span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> </span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> </span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><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: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">  memfd = memfd_create("nohuge", 0);<br>...</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">   fd = memfd;<br>    flags = MAP_SHARED; //MAP_SHARED means </span><strong><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: #e2001c;">UNCACHEABLE</span></strong><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">?</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><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: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> </span></p></div></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> </span></p></div></div><blockquote style="margin-top: 5.0pt;margin-bottom: 5.0pt;"><div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 7.5pt;">------------------</span><span style="font-size: 7.5pt;font-family: ms gothic;">原始</span><span style="font-size: 7.5pt;font-family: microsoft jhenghei , sans-serif;">邮件</span><span style="font-size: 7.5pt;"> ------------------</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><b><span style="font-family: microsoft jhenghei , sans-serif;">发件人</span>:</b>Burakov, Anatoly <<a href="mailto:anatoly.burakov@intel.com" target="_blank">anatoly.burakov@intel.com</a>></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><b><span style="font-family: microsoft jhenghei , sans-serif;">发送时间</span>:</b>08/09/22 17:25:35</p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><b><span style="font-family: ms gothic;">收件人</span>:</b>Kinsella, Ray <<a href="mailto:ray.kinsella@intel.com" target="_blank">ray.kinsella@intel.com</a>>, Nick Tian <<a href="mailto:nick.tian@longsailingsemi.com" target="_blank">nick.tian@longsailingsemi.com</a>>,<a href="mailto:users@dpdk.org" target="_blank">users@dpdk.org</a> <<a href="mailto:users@dpdk.org" target="_blank">users@dpdk.org</a>></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><b><span style="font-family: ms gothic;">主</span></b><b><span style="font-family: microsoft jhenghei , sans-serif;">题</span>:</b>RE: About memory coherency</p></div></div><div><blockquote style="margin-top: 5.0pt;margin-bottom: 5.0pt;"><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="color: #1f497d;">There are two different issues at play here.</span></p><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="color: #1f497d;"> </span></p><p class="MsoNormal" style="margin-left: 36.0pt;"><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" style="margin-left: 36.0pt;"><span style="color: #1f497d;"> </span></p><p class="MsoNormal" style="margin-left: 36.0pt;"><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" style="margin-left: 36.0pt;"><span style="color: #1f497d;"> </span></p><div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="color: #1f497d;">Thanks,</span></p><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="color: #1f497d;">Anatoly</span></p></div><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="color: #1f497d;"> </span></p><div style="border: none;border-left: solid blue 1.5pt;padding: 0.0cm 0.0cm 0.0cm 4.0pt;"><div><div style="border: none;border-top: solid #e1e1e1 1.0pt;padding: 3.0pt 0.0cm 0.0cm 0.0cm;"><p class="MsoNormal" style="margin-left: 36.0pt;"><b>From:</b> Kinsella, Ray <<a href="mailto:ray.kinsella@intel.com" target="_blank">ray.kinsella@intel.com</a>><br><b>Sent:</b> Tuesday, August 9, 2022 10:04 AM<br><b>To:</b> Nick Tian <<a href="mailto:nick.tian@longsailingsemi.com" target="_blank">nick.tian@longsailingsemi.com</a>>;<a href="mailto:users@dpdk.org" target="_blank">users@dpdk.org</a><br><b>Cc:</b> Burakov, Anatoly <<a href="mailto:anatoly.burakov@intel.com" target="_blank">anatoly.burakov@intel.com</a>><br><b>Subject:</b> RE: About memory coherency</p></div></div><p class="MsoNormal" style="margin-left: 36.0pt;"> </p><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 12.0pt;font-family: courier new;"> </span></p><p class="MsoNormal" style="margin-left: 36.0pt;"><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" style="margin-left: 36.0pt;"><span style="font-size: 12.0pt;font-family: courier new;"> </span></p><p class="MsoNormal" style="margin-left: 36.0pt;"><span style="font-size: 12.0pt;font-family: courier new;">Ray K</span></p><p class="MsoNormal" style="margin-left: 36.0pt;"><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.0cm 0.0cm 0.0cm;"><p class="MsoNormal" style="margin-left: 72.0pt;"><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: 72.0pt;"> </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: 36.0pt;"><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: 36.0pt;"><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: 36.0pt;"><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: 36.0pt;"><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: 36.0pt;"><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: 36.0pt;"><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: 36.0pt;"><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: 36.0pt;"><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: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> </span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><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: 36.0pt;"><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: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">....</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><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: 36.0pt;"><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: 36.0pt;"><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: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;">...</span></p></div><div><p class="MsoNormal" style="margin-left: 36.0pt;"><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: 36.0pt;"><span style="font-size: 10.5pt;font-family: microsoft yahei , sans-serif;color: black;"> </span></p></div></div></div></div></blockquote></div></div></div></blockquote></div></blockquote></div></blockquote></div></blockquote></div></div></blockquote></div></blockquote></div>