mempool:fix bug when use MM_BACKTRACE

caculate blk address when mempool_multiple_free
have a bug. need a real blocksize to caulate the
memory address.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao
2023-02-01 20:00:25 +08:00
committed by Xiang Xiao
parent 84059a949c
commit 4ced3c9642
3 changed files with 34 additions and 43 deletions
+26
View File
@@ -34,6 +34,18 @@
#include <nuttx/spinlock.h>
#include <nuttx/semaphore.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#if CONFIG_MM_BACKTRACE >= 0
# define MEMPOOL_REALBLOCKSIZE(pool) (ALIGN_UP(pool->blocksize + \
sizeof(struct mempool_backtrace_s), \
pool->blockalign))
#else
# define MEMPOOL_REALBLOCKSIZE(pool) (pool->blocksize)
#endif
/****************************************************************************
* Public Types
****************************************************************************/
@@ -70,6 +82,9 @@ struct mempool_procfs_entry_s
struct mempool_s
{
size_t blocksize; /* The size for every block in mempool */
#if CONFIG_MM_BACKTRACE >= 0
size_t blockalign; /* The alignment of the blocksize */
#endif
size_t initialsize; /* The initialize size in normal mempool */
size_t interruptsize; /* The initialize size in interrupt mempool */
size_t expandsize; /* The size of expand block every time for mempool */
@@ -101,6 +116,17 @@ struct mempool_s
#endif
};
#if CONFIG_MM_BACKTRACE >= 0
struct mempool_backtrace_s
{
FAR struct list_node node;
pid_t pid;
# if CONFIG_MM_BACKTRACE > 0
FAR void *backtrace[CONFIG_MM_BACKTRACE];
# endif
};
#endif
struct mempoolinfo_s
{
unsigned long arena; /* This is the total size of mempool */