Skip to content

Commit

Permalink
fs/shm: align memory size to cache line size
Browse files Browse the repository at this point in the history
Make sure the share memory takes the full cache line.

Signed-off-by: Neo Xu <[email protected]>
  • Loading branch information
XuNeo authored and xiaoxiang781216 committed Oct 27, 2024
1 parent 9af5fc5 commit 8a70377
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fs/shm/shmfs_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <nuttx/arch.h>
#include <nuttx/cache.h>
#include <nuttx/nuttx.h>
#include <nuttx/kmalloc.h>
#include <nuttx/pgalloc.h>

Expand All @@ -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
{
Expand All @@ -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
{
Expand Down

0 comments on commit 8a70377

Please sign in to comment.