[PATCH v1 5/6] eal/linux: allow hugepage file reuse
Thomas Monjalon
thomas at monjalon.net
Mon Jan 17 15:24:00 CET 2022
17/01/2022 09:14, Dmitry Kozlyuk:
> Linux EAL ensured that mapped hugepages are clean
> by always mapping from newly created files:
> existing hugepage backing files were always removed.
> In this case, the kernel clears the page to prevent data leaks,
> because the mapped memory may contain leftover data
> from the previous process that was using this memory.
> Clearing takes the bulk of the time spent in mmap(2),
> increasing EAL initialization time.
>
> Introduce a mode to keep existing files and reuse them
> in order to speed up initial memory allocation in EAL.
> Hugepages mapped from such files may contain data
> left by the previous process that used this memory,
> so RTE_MEMSEG_FLAG_DIRTY is set for their segments.
> If multiple hugepages are mapped from the same file:
> 1. When fallocate(2) is used, all memory mapped from this file
> is considered dirty, because it is unknown
> which parts of the file are holes.
> 2. When ftruncate(3) is used, memory mapped from this file
> is considered dirty unless the file is extended
> to create a new mapping, which implies clean memory.
[...]
> struct hugepage_file_discipline {
> /** Unlink files before mapping them to leave no trace in hugetlbfs. */
> bool unlink_before_mapping;
> + /** Reuse existing files, never delete or re-create them. */
> + bool keep_existing;
> };
That's a bit confusing to mix "unlink" and "keep".
I would prefer focusing on what is done, i.e. unlink when.
I like "unlink_before_mapping" because it is a real action.
The other action should be "unlink_existing" or "unlink_before_creating".
More information about the dev
mailing list