Skip to content

Commit 7190b3c

Browse files
specht478akpm00
authored andcommitted
mm: mmap: map MAP_STACK to VM_NOHUGEPAGE only if THP is enabled
commit c4608d1 ("mm: mmap: map MAP_STACK to VM_NOHUGEPAGE") maps the mmap option MAP_STACK to VM_NOHUGEPAGE. This is also done if CONFIG_TRANSPARENT_HUGEPAGE is not defined. But in that case, the VM_NOHUGEPAGE does not make sense. I discovered this issue when trying to use the tool CRIU to checkpoint and restore a container. Our running kernel is compiled without CONFIG_TRANSPARENT_HUGEPAGE. CRIU parses the output of /proc/<pid>/smaps and saves the "nh" flag. When trying to restore the container, CRIU fails to restore the "nh" mappings, since madvise() MADV_NOHUGEPAGE always returns an error because CONFIG_TRANSPARENT_HUGEPAGE is not defined. Link: https://lkml.kernel.org/r/20250507-map-map_stack-to-vm_nohugepage-only-if-thp-is-enabled-v5-1-c6c38cfefd6e@kuka.com Fixes: c4608d1 ("mm: mmap: map MAP_STACK to VM_NOHUGEPAGE") Signed-off-by: Ignacio Moreno Gonzalez <[email protected]> Acked-by: David Hildenbrand <[email protected]> Reviewed-by: Lorenzo Stoakes <[email protected]> Reviewed-by: Yang Shi <[email protected]> Reviewed-by: Liam R. Howlett <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 910224c commit 7190b3c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/linux/mman.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ calc_vm_flag_bits(struct file *file, unsigned long flags)
155155
return _calc_vm_trans(flags, MAP_GROWSDOWN, VM_GROWSDOWN ) |
156156
_calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED ) |
157157
_calc_vm_trans(flags, MAP_SYNC, VM_SYNC ) |
158+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
158159
_calc_vm_trans(flags, MAP_STACK, VM_NOHUGEPAGE) |
160+
#endif
159161
arch_calc_vm_flag_bits(file, flags);
160162
}
161163

0 commit comments

Comments
 (0)