Skip to content

Commit 8a70377

Browse files
XuNeoxiaoxiang781216
authored andcommitted
fs/shm: align memory size to cache line size
Make sure the share memory takes the full cache line. Signed-off-by: Neo Xu <[email protected]>
1 parent 9af5fc5 commit 8a70377

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/shm/shmfs_alloc.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include <nuttx/arch.h>
3030
#include <nuttx/cache.h>
31+
#include <nuttx/nuttx.h>
3132
#include <nuttx/kmalloc.h>
3233
#include <nuttx/pgalloc.h>
3334

@@ -54,7 +55,8 @@ FAR struct shmfs_object_s *shmfs_alloc_object(size_t length)
5455
size_t cachesize = up_get_dcache_linesize();
5556
if (cachesize > 0)
5657
{
57-
object->paddr = fs_heap_memalign(cachesize, length);
58+
object->paddr = fs_heap_memalign(cachesize,
59+
ALIGN_UP(length, cachesize));
5860
}
5961
else
6062
{
@@ -78,7 +80,8 @@ FAR struct shmfs_object_s *shmfs_alloc_object(size_t length)
7880
size_t cachesize = up_get_dcache_linesize();
7981
if (cachesize > 0)
8082
{
81-
object->paddr = kumm_memalign(cachesize, length);
83+
object->paddr = kumm_memalign(cachesize,
84+
ALIGN_UP(length, cachesize));
8285
}
8386
else
8487
{

0 commit comments

Comments
 (0)