yangsong8-a1 opened a new pull request, #22060:
URL: https://github.com/apache/nuttx/pull/22060

   ## Summary
     
     Add CONFIG_DMABUF_SYSTEM_HEAP_RESERVE_SIZE.  When it is non-zero, the
     system DMA-BUF heap reserves a region of that size at startup and runs
     its own mm heap on it, so DMA-BUF allocations no longer compete with
     the rest of the system for user heap memory.  Allocation and free
     always use the same heap.  If the region cannot be set up, creating
     the heap fails.
     
     The second commit keeps the default (size 0) on the existing
     kumm_memalign()/kumm_free() path, so nothing changes unless the option
     is set.  The third commit corrects the Kconfig help text, which said
     that allocations fall back to the public heap when the region is full;
     they fail with -ENOMEM instead.
     
     ## Impact
     
     drivers/dma-buf only.  New Kconfig option, default 0: no behavior
     change by default.
     
     ## Testing
     
     Ubuntu 22.04, gcc 13.1, sim:nsh with CONFIG_DMABUF_HEAPS=y.  A test
     program allocates 64 KiB dma-bufs from /dev/dma_heap/system until the
     allocation fails (at most 64), checks each one through mmap(), and
     prints /proc/meminfo while the buffers are held and after they are
     closed.
     
     master:
     
     nsh> hello
     open heap: 3 (errno 0)
     allocated 64 x 65536 bytes, bad 0
     --- meminfo while held
           total       used       free    maxused    maxfree  nused  nfree name
        67108856    6137112   60971744    6137808   60923536    380      5 Umem
     --- meminfo after free
           total       used       free    maxused    maxfree  nused  nfree name
        67108856    1929416   65179440    6137808   65121936    123     11 Umem
     
     This PR, CONFIG_DMABUF_SYSTEM_HEAP_RESERVE_SIZE=0 (same numbers as
     master):
     
     nsh> hello
     open heap: 3 (errno 0)
     allocated 64 x 65536 bytes, bad 0
     --- meminfo while held
           total       used       free    maxused    maxfree  nused  nfree name
        67108856    6137112   60971744    6137808   60923536    380      5 Umem
     --- meminfo after free
           total       used       free    maxused    maxfree  nused  nfree name
        67108856    1929416   65179440    6137808   65121936    123     11 Umem
     
     This PR, CONFIG_DMABUF_SYSTEM_HEAP_RESERVE_SIZE=262144: buffers come
     from the "dmabuf" heap, the fourth allocation fails with ENOMEM, and
     the memory goes back to that heap on close:
     
     nsh> hello
     open heap: 3 (errno 0)
     alloc 3 failed: errno 12
     allocated 3 x 65536 bytes, bad 0
     --- meminfo while held
           total       used       free    maxused    maxfree  nused  nfree name
          262136     197384      64752     198144      64656      5      3 
dmabuf
        67108856    2190968   64917888    2191664   64859776    125      3 Umem
     --- meminfo after free
           total       used       free    maxused    maxfree  nused  nfree name
          262136        728     261408     198144     261408      2      1 
dmabuf
        67108856    2190344   64918512    2191664   64859776    115      3 Umem
     
     ````
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to