To optimize the layout of the meta data of mem_slab & mem_pool #3866
Labels
area: Kernel
Enhancement
Changes/Updates/Additions to existing features
priority: low
Low impact/importance bug
Reported by Quanwen Du:
The suggestions here:
mem_slab
, current logic is using the first 4bytes of the free buffer as NEXT pointer of free_list, then link all the free buffers together. But I suggest to use the tail 4bytes as NEXT pointer of free_list. As we know there are issues of memory overflow/corruption. If we move the NEXT to the tail 4bytes, then we have a bigger guard space, then even when memory overflow writing happens, it is lower possibility that the NEXT pointer will be corrupted. I know there is argument that we should let the corruption be visible earlier, but I think it shall be always right to reduce the impact of the overflow corruptionmem_pool
, which puts the bitmap and level info at the end of the buffer. So the suggestion here is to changeK_MEM_POOL_DEFINE
: to move_mpool_lvls_##name
before _mpool_buf_##name
; also to define the bitmap of block availability before mpool_buf##name. Of cause this suggestion assumed the toolchain will layout these arrays per its definition sequence, I will assume this is the most case, so shall be OK to re-layout these arrays.(Imported from Jira ZEP-2435)
The text was updated successfully, but these errors were encountered: