From 8a70377fc40e636307544d9c2fc15948f7051f67 Mon Sep 17 00:00:00 2001 From: Neo Xu Date: Sun, 27 Oct 2024 02:13:01 +0800 Subject: [PATCH] fs/shm: align memory size to cache line size Make sure the share memory takes the full cache line. Signed-off-by: Neo Xu --- fs/shm/shmfs_alloc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/shm/shmfs_alloc.c b/fs/shm/shmfs_alloc.c index a6bd4affad32d..05f3ff9d0cfcc 100644 --- a/fs/shm/shmfs_alloc.c +++ b/fs/shm/shmfs_alloc.c @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -54,7 +55,8 @@ FAR struct shmfs_object_s *shmfs_alloc_object(size_t length) size_t cachesize = up_get_dcache_linesize(); if (cachesize > 0) { - object->paddr = fs_heap_memalign(cachesize, length); + object->paddr = fs_heap_memalign(cachesize, + ALIGN_UP(length, cachesize)); } else { @@ -78,7 +80,8 @@ FAR struct shmfs_object_s *shmfs_alloc_object(size_t length) size_t cachesize = up_get_dcache_linesize(); if (cachesize > 0) { - object->paddr = kumm_memalign(cachesize, length); + object->paddr = kumm_memalign(cachesize, + ALIGN_UP(length, cachesize)); } else {