[PATCH v1 3/6] mem: add dirty malloc element support
Thomas Monjalon
thomas at monjalon.net
Mon Jan 17 15:07:08 CET 2022
17/01/2022 09:07, Dmitry Kozlyuk:
> EAL malloc layer assumed all free elements content
> is filled with zeros ("clean"), as opposed to uninitialized ("dirty").
> This assumption was ensured in two ways:
> 1. EAL memalloc layer always returned clean memory.
> 2. Freed memory was cleared before returning into the heap.
>
> Clearing the memory can be as slow as around 14 GiB/s.
> To save doing so, memalloc layer is allowed to return dirty memory.
> Such segments being marked with RTE_MEMSEG_FLAG_DIRTY.
> The allocator tracks elements that contain dirty memory
> using the new flag in the element header.
> When clean memory is requested via rte_zmalloc*()
> and the suitable element is dirty, it is cleared on allocation.
> When memory is deallocated, the freed element is joined
> with adjacent free elements, and the dirty flag is updated:
>
> dirty + freed + dirty = dirty => no need to clean
> freed + dirty = dirty the freed memory
It is not said why dirty parts are not cleaned.
>
> clean + freed + clean = clean => freed memory
> clean + freed = clean must be cleared
> freed + clean = clean
> freed = clean
>
> As a result, memory is either cleared on free, as before,
> or it will be cleared on allocation if need be, but never twice.
It is not said whether it is a change for everybody,
or only when enabling an option.
More information about the dev
mailing list