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

xiaoxiang781216 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 70273e7a569 drivers/pipes: support global var under bmp mode
70273e7a569 is described below

commit 70273e7a569087b631ea1e6ae6c929ff20e0e247
Author: dongjiuzhu1 <[email protected]>
AuthorDate: Wed Nov 12 21:39:26 2025 +0800

    drivers/pipes: support global var under bmp mode
    
    Make the pipe allocation lock and the pipe number counter per-CPU
    variables under BMP, so that each CPU registers its own pipes
    without contending for a single global lock.
    
    Signed-off-by: dongjiuzhu1 <[email protected]>
---
 drivers/pipes/pipe.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/pipes/pipe.c b/drivers/pipes/pipe.c
index 8b2d664f60e..ce181a032bd 100644
--- a/drivers/pipes/pipe.c
+++ b/drivers/pipes/pipe.c
@@ -72,8 +72,11 @@ static const struct file_operations g_pipe_fops =
   pipecommon_writev    /* writev */
 };
 
-static mutex_t g_pipelock = NXMUTEX_INITIALIZER;
-static int     g_pipeno;
+static DEFINE_PER_CPU_BMP(mutex_t, g_pipelock) = NXMUTEX_INITIALIZER;
+#define g_pipelock this_cpu_var_bmp(g_pipelock)
+
+static DEFINE_PER_CPU_BSS_BMP(int, g_pipeno);
+#define g_pipeno this_cpu_var_bmp(g_pipeno)
 
 /****************************************************************************
  * Private Functions

Reply via email to