feat: 对内核模块暴露OsMemNodeHead/OsMemPoolHead

对内核其他模块暴露OsMemNodeHead/OsMemPoolHead等结构体,
以便于对堆内存管理的调测及管理。

fix #I64ONE

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: I2e47d90412368dfdc8d82e6b30c9196e1fdf42f1
This commit is contained in:
Far 2022-12-05 16:41:20 +08:00
parent f190275664
commit 0d1c77c1e0
2 changed files with 66 additions and 65 deletions

View File

@ -490,6 +490,72 @@ extern UINT32 LOS_MemIntegrityCheck(const VOID *pool);
* </ul> * </ul>
* @see None. * @see None.
*/ */
/* Supposing a Second Level Index: SLI = 3. */
#define OS_MEM_SLI 3
/* Giving 1 free list for each small bucket: 4, 8, 12, up to 124. */
#define OS_MEM_SMALL_BUCKET_COUNT 31
#define OS_MEM_SMALL_BUCKET_MAX_SIZE 128
/* Giving 2^OS_MEM_SLI free lists for each large bucket. */
#define OS_MEM_LARGE_BUCKET_COUNT 24
/* OS_MEM_SMALL_BUCKET_MAX_SIZE to the power of 2 is 7. */
#define OS_MEM_LARGE_START_BUCKET 7
/* The count of free list. */
#define OS_MEM_FREE_LIST_COUNT (OS_MEM_SMALL_BUCKET_COUNT + (OS_MEM_LARGE_BUCKET_COUNT << OS_MEM_SLI))
/* The bitmap is used to indicate whether the free list is empty, 1: not empty, 0: empty. */
#define OS_MEM_BITMAP_WORDS ((OS_MEM_FREE_LIST_COUNT >> 5) + 1)
struct OsMemNodeHead {
#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == 1)
UINT32 magic;
#endif
#if (LOSCFG_MEM_LEAKCHECK == 1)
UINTPTR linkReg[LOSCFG_MEM_RECORD_LR_CNT];
#endif
union {
struct OsMemNodeHead *prev; /* The prev is used for current node points to the previous node */
struct OsMemNodeHead *next; /* The next is used for sentinel node points to the expand node */
} ptr;
#if (LOSCFG_TASK_MEM_USED == 1)
UINT32 taskID;
UINT32 sizeAndFlag;
#elif (LOSCFG_MEM_FREE_BY_TASKID == 1)
UINT32 taskID : 6;
UINT32 sizeAndFlag : 26;
#else
UINT32 sizeAndFlag;
#endif
};
struct OsMemFreeNodeHead {
struct OsMemNodeHead header;
struct OsMemFreeNodeHead *prev;
struct OsMemFreeNodeHead *next;
};
struct OsMemPoolInfo {
VOID *pool;
UINT32 totalSize;
UINT32 attr;
#if (LOSCFG_MEM_WATERLINE == 1)
UINT32 waterLine; /* Maximum usage size in a memory pool */
UINT32 curUsedSize; /* Current usage size in a memory pool */
#endif
#if (LOSCFG_MEM_MUL_REGIONS == 1)
UINT32 totalGapSize;
#endif
};
struct OsMemPoolHead {
struct OsMemPoolInfo info;
UINT32 freeListBitmap[OS_MEM_BITMAP_WORDS];
struct OsMemFreeNodeHead *freeList[OS_MEM_FREE_LIST_COUNT];
#if (LOSCFG_MEM_MUL_POOL == 1)
VOID *nextPool;
#endif
};
extern VOID LOS_MemUnlockEnable(VOID *pool); extern VOID LOS_MemUnlockEnable(VOID *pool);
extern UINT32 OsMemSystemInit(VOID); extern UINT32 OsMemSystemInit(VOID);

View File

@ -59,21 +59,6 @@ VOID *g_poolHead = NULL;
/* The following is the macro definition and interface implementation related to the TLSF. */ /* The following is the macro definition and interface implementation related to the TLSF. */
/* Supposing a Second Level Index: SLI = 3. */
#define OS_MEM_SLI 3
/* Giving 1 free list for each small bucket: 4, 8, 12, up to 124. */
#define OS_MEM_SMALL_BUCKET_COUNT 31
#define OS_MEM_SMALL_BUCKET_MAX_SIZE 128
/* Giving 2^OS_MEM_SLI free lists for each large bucket. */
#define OS_MEM_LARGE_BUCKET_COUNT 24
/* OS_MEM_SMALL_BUCKET_MAX_SIZE to the power of 2 is 7. */
#define OS_MEM_LARGE_START_BUCKET 7
/* The count of free list. */
#define OS_MEM_FREE_LIST_COUNT (OS_MEM_SMALL_BUCKET_COUNT + (OS_MEM_LARGE_BUCKET_COUNT << OS_MEM_SLI))
/* The bitmap is used to indicate whether the free list is empty, 1: not empty, 0: empty. */
#define OS_MEM_BITMAP_WORDS ((OS_MEM_FREE_LIST_COUNT >> 5) + 1)
#define OS_MEM_BITMAP_MASK 0x1FU #define OS_MEM_BITMAP_MASK 0x1FU
/* Used to find the first bit of 1 in bitmap. */ /* Used to find the first bit of 1 in bitmap. */
@ -120,60 +105,10 @@ STATIC INLINE UINT32 OsMemSlGet(UINT32 size, UINT32 fl)
#error "When enter here, LOSCFG_BASE_CORE_TSK_LIMIT larger than 63 is not support" #error "When enter here, LOSCFG_BASE_CORE_TSK_LIMIT larger than 63 is not support"
#endif #endif
struct OsMemNodeHead {
#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == 1)
UINT32 magic;
#endif
#if (LOSCFG_MEM_LEAKCHECK == 1)
UINTPTR linkReg[LOSCFG_MEM_RECORD_LR_CNT];
#endif
union {
struct OsMemNodeHead *prev; /* The prev is used for current node points to the previous node */
struct OsMemNodeHead *next; /* The next is used for sentinel node points to the expand node */
} ptr;
#if (LOSCFG_TASK_MEM_USED == 1)
UINT32 taskID;
UINT32 sizeAndFlag;
#elif (LOSCFG_MEM_FREE_BY_TASKID == 1)
UINT32 taskID : 6;
UINT32 sizeAndFlag : 26;
#else
UINT32 sizeAndFlag;
#endif
};
struct OsMemUsedNodeHead { struct OsMemUsedNodeHead {
struct OsMemNodeHead header; struct OsMemNodeHead header;
}; };
struct OsMemFreeNodeHead {
struct OsMemNodeHead header;
struct OsMemFreeNodeHead *prev;
struct OsMemFreeNodeHead *next;
};
struct OsMemPoolInfo {
VOID *pool;
UINT32 totalSize;
UINT32 attr;
#if (LOSCFG_MEM_WATERLINE == 1)
UINT32 waterLine; /* Maximum usage size in a memory pool */
UINT32 curUsedSize; /* Current usage size in a memory pool */
#endif
#if (LOSCFG_MEM_MUL_REGIONS == 1)
UINT32 totalGapSize;
#endif
};
struct OsMemPoolHead {
struct OsMemPoolInfo info;
UINT32 freeListBitmap[OS_MEM_BITMAP_WORDS];
struct OsMemFreeNodeHead *freeList[OS_MEM_FREE_LIST_COUNT];
#if (LOSCFG_MEM_MUL_POOL == 1)
VOID *nextPool;
#endif
};
/* The memory pool support expand. */ /* The memory pool support expand. */
#define OS_MEM_POOL_EXPAND_ENABLE 0x01 #define OS_MEM_POOL_EXPAND_ENABLE 0x01
/* The memory pool support no lock. */ /* The memory pool support no lock. */