<div dir="ltr"><div>Hi Dmitry,</div><div><br></div><div>My apologies for the private reply. I am quite new to the mailing list.</div><div>I will do a profile later of the allocation.</div><div><br></div><div>As for the issue, at 550 GB so 252'757'352 MBUFs (using default mbuf buf size), it works now, with ring allocation. However, the physical memory usage now goes up a lot and I end up swapping. It appears that not all memory is in hugepages (not all pages are filled) and that perhaps the kernel also allocates more memory. I have 755 GiB RAM available, so 600 GB of mempool is pushing it.<br></div><div>I realise now that I also have some private data in the mempool, so the figure of 550 GB is plainly wrong. In reality, one object is:</div><div><ul><li>rte_mempool_calc_obj_size gives: total_size = 2240 bytes<br></li><li>Private data per mbuf (alignment included) is:  48 bytes</li></ul><div>So actual memory consumption is: 252'757'352 MBUFs × (48 + 2240 bytes) = 578'308'821'376 bytes ~ 578 GB</div><div>That is at least 28 GB more.</div><div><br></div><div>I now fixed my program to address this issue and when requesting 500 GB, it will take the private data and headroom into account.<br></div><div><br></div><div>I will update later with some memory statistics and a profile.<br></div></div><div><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Feb 20, 2025 at 12:21 PM Dmitry Kozlyuk <<a href="mailto:dmitry.kozliuk@gmail.com">dmitry.kozliuk@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Lucas,<br>
<br>
Please don't send private replies to discussions in the mailing list.<br>
<br>
2025-02-20 12:00 (UTC+0100), Lucas:<br>
> Hi Dmitry,<br>
> <br>
> Thank you for your detailed instructions.<br>
> I have followed them in the following way:<br>
> <br>
>    - In config/rte_config.h set RTE_MAX_MEM_MB_PER_LIST to 524288<br>
>    - In config/rte_config.h set RTE_MAX_MEM_MB_PER_TYPE to 524288<br>
>    - To change RTE_MAX_MEM_MB, I have to change the configure set in the<br>
>    meson build system. To do so, I changed<br>
>    <a href="https://elixir.bootlin.com/dpdk/v24.11.1/source/config/meson.build#L362" rel="noreferrer" target="_blank">https://elixir.bootlin.com/dpdk/v24.11.1/source/config/meson.build#L362</a><br>
>    I replaced "dpdk_conf.set('RTE_MAX_MEM_MB', 524288)" with<br>
>    "dpdk_conf.set('RTE_MAX_MEM_MB', 8388608)". As I have 8 NUMA nodes, with 2<br>
>    huge pages sizes: 8 NUMA nodes × 2 hugepage sizes × 512 GiB = 8388 GiB<br>
> <br>
> With these changes, my program can create a mempool with  275'735'294<br>
> MBUFS, comprising 2'176 (bytes of MBUF size) × 275'735'294 =<br>
> 599'999'999'744 bytes ~ 600 GB, but fails later, as I also need an extra<br>
> rte_ring to hold pointers to the MBUFs. In HTOP, a virtual memory size of<br>
> 4'097G is reported.<br>
> However, with a smaller amount, 229'779'411 MBUFs, it works (i.e. 500 GB).<br>
> And I can also allocate a ring of the same size (I use RING_F_EXACT_SZ, so<br>
> in reality it is more).<br>
> <br>
> I have tried increasing the limits further to be able to allocate more:<br>
> <br>
>    - In config/rte_config.h set RTE_MAX_MEM_MB_PER_LIST to 1048576<br>
>    - In config/rte_config.h set RTE_MAX_MEM_MB_PER_TYPE to 1048576<br>
>    - Set RTE_MAX_MEM_MB = 16'777'216<br>
> <br>
> The virtual memory allocated is now 8192G, 8192G, and I can allocate 600 GB<br>
> for the mempool (275'735'294 MBUFs), but the ring allocation fails (fails<br>
> with 'Cannot allocate memory'). Allocation of the mempool now takes seven<br>
> minutes.<br>
<br>
It would be interesting to profile this one your issue is resolved.<br>
I expect that hugepage allocation takes only about 10 seconds of this,<br>
while the rest is mempool initialization.<br>
<br>
> How would I be able to also allocate a ring of the same size?<br>
> I verified that the number of MBUFs I need rounded up to the next power of<br>
> 2 is still smaller than the max size of an unsigned int on my platform<br>
> (x86_64, so 32 bit unsigned int).<br>
> I have 670 hugepages of 1 GB available. Is this too little? In principle<br>
> the ring takes 64 bits × # entries = memory. In this case, that would be:<br>
> next power of 2 is 536'870'912 × 8 bytes (64 bites) = 4.3 GB.<br>
> With 670 GB available, and roughly 600 GB for the mempool, this should fit.<br>
> Could it be that supporting structures take the rest of the memory?<br>
<br>
Mempool adds headers and padding to objects within,<br>
so it probably takes more memory than calculated.<br>
You can use rte_mempool_mem_iter() and rte_mempool_calc_obj_size() to check.<br>
You can check exact memory usage with rte_malloc_get_socket_stats().<br>
</blockquote></div>