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

jerpelea 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 a3f733d3879 fs/shm: Add a flag FS_SHMFS_NO_ALIGN to remove SHM 
alignment
a3f733d3879 is described below

commit a3f733d38790e881cd552cf5e00c9c1d2a42feae
Author: Jukka Laitinen <[email protected]>
AuthorDate: Fri Aug 14 14:43:13 2026 +0300

    fs/shm: Add a flag FS_SHMFS_NO_ALIGN to remove SHM alignment
    
    This can be used on small systems to save RAM if the SHM object
    doesn't need to be cache-aligned.
    
    Signed-off-by: Jukka Laitinen <[email protected]>
---
 fs/shm/Kconfig       | 10 ++++++++++
 fs/shm/shmfs_alloc.c |  8 ++++++++
 2 files changed, 18 insertions(+)

diff --git a/fs/shm/Kconfig b/fs/shm/Kconfig
index 77bdbe5a320..1922738ccde 100644
--- a/fs/shm/Kconfig
+++ b/fs/shm/Kconfig
@@ -19,4 +19,14 @@ config FS_SHMFS_VFS_PATH
                The path to where shared memory objects will exist in the VFS
                namespace.
 
+config FS_SHMFS_NO_ALIGN
+       bool "Skip cache-line alignment/padding of shm objects"
+       default n
+       ---help---
+               Skip cache-line alignment of the shm object metadata header and
+               the object length. Saves RAM in FLAT builds where shm objects
+               are never used as DMA targets and no cache maintenance is
+               performed on their contents. Callers that need DMA-safe shm
+               buffers must not enable this.
+
 endif # FS_SHMFS
diff --git a/fs/shm/shmfs_alloc.c b/fs/shm/shmfs_alloc.c
index 7b68b763cf6..0133f85a168 100644
--- a/fs/shm/shmfs_alloc.c
+++ b/fs/shm/shmfs_alloc.c
@@ -53,7 +53,11 @@ FAR struct shmfs_object_s *shmfs_alloc_object(size_t length)
 
   size_t hdr_size = sizeof(struct shmfs_object_s);
   size_t alloc_size = length;
+#ifdef CONFIG_FS_SHMFS_NO_ALIGN
+  size_t cachesize = 0;
+#else
   size_t cachesize = up_get_dcache_linesize();
+#endif
 
   if (cachesize > 0)
     {
@@ -83,7 +87,11 @@ FAR struct shmfs_object_s *shmfs_alloc_object(size_t length)
   object = fs_heap_zalloc(sizeof(struct shmfs_object_s));
   if (object)
     {
+#ifdef CONFIG_FS_SHMFS_NO_ALIGN
+      size_t cachesize = 0;
+#else
       size_t cachesize = up_get_dcache_linesize();
+#endif
 
       if (cachesize > 0)
         {

Reply via email to