This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 767599cd822 mm/Kconfig: Use a spinlock for the page allocator with SMP.
767599cd822 is described below

commit 767599cd82218318a61b83f578fe8c1a6c47e458
Author: Marco Casaroli <[email protected]>
AuthorDate: Mon Oct 12 16:37:06 2026 +0200

    mm/Kconfig: Use a spinlock for the page allocator with SMP.
    
    The page allocator takes the granule lock once for each page: fork()
    copies a process one page at a time, and the destruction of an
    address environment frees it one page at a time.  With SMP and a
    semaphore, unlock gives the lock to a waiter that is only made ready.
    When all CPUs run tasks of the same priority, that waiter can wait a
    full round-robin interval for a CPU while it holds the lock, and every
    page allocation in the system waits behind it.
    
    On qemu-armv8a with 4 CPUs and 4 shells that run programs in a loop,
    the LPWORK thread took up to 631 ms to destroy an address environment
    (1 ms when idle).  The freed pages fell behind until the page pool was
    empty.  With GRAN_INTR, the destroy took 2 ms and the pool stayed full.
    
    Make GRAN_INTR the default for MM_PGALLOC with SMP.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 mm/Kconfig | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/mm/Kconfig b/mm/Kconfig
index 70a79bd1dad..fd2feac0be1 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -276,7 +276,7 @@ if GRAN
 
 config GRAN_INTR
        bool "Interrupt level support"
-       default n
+       default MM_PGALLOC && SMP
        ---help---
                Normally mutual exclusive access to granule allocator data is 
assured
                using a semaphore.  If this option is set then, instead, mutual
@@ -284,6 +284,11 @@ config GRAN_INTR
                invasive to system performance, it will also support use of the 
granule
                allocator from interrupt level logic.
 
+               The page allocator takes the lock once for each page.  With 
SMP, a
+               semaphore can be given to a thread that waits for a CPU, and all
+               page allocations then wait for that thread.  This option is the
+               default for MM_PGALLOC with SMP.
+
 config DEBUG_GRAN
        bool "Granule Allocator Debug"
        default n

Reply via email to