linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: mmap: map MAP_STACK to VM_NOHUGEPAGE only if THP is enabled
@ 2025-05-02  9:31 Ignacio Moreno Gonzalez via B4 Relay
  2025-05-02 12:46 ` Lorenzo Stoakes
  2025-05-02 13:03 ` Matthew Wilcox
  0 siblings, 2 replies; 10+ messages in thread
From: Ignacio Moreno Gonzalez via B4 Relay @ 2025-05-02  9:31 UTC (permalink / raw)
  To: Liam.Howlett, lorenzo.stoakes
  Cc: linux-mm, linux-kernel, Ignacio Moreno Gonzalez

From: Ignacio Moreno Gonzalez <Ignacio.MorenoGonzalez@kuka.com>

commit c4608d1bf7c6 ("mm: mmap: map MAP_STACK to VM_NOHUGEPAGE") maps
the mmap option MAP_STACK to VM_NOHUGEPAGE. This is also done if
CONFIG_TRANSPARENT_HUGETABLES is not defined. But in that case, the
VM_NOHUGEPAGE does not make sense. For instance, when calling madvise()
with MADV_NOHUGEPAGE, an error is always returned.

Signed-off-by: Ignacio Moreno Gonzalez <Ignacio.MorenoGonzalez@kuka.com>
---
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_HUGETABLES. 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_HUGETABLES is not defined.
---
 include/linux/mman.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/mman.h b/include/linux/mman.h
index bce214fece16b9af3791a2baaecd6063d0481938..1e83bc0e3db670b04743f5208826e87455a05325 100644
--- a/include/linux/mman.h
+++ b/include/linux/mman.h
@@ -155,7 +155,9 @@ calc_vm_flag_bits(struct file *file, unsigned long flags)
 	return _calc_vm_trans(flags, MAP_GROWSDOWN,  VM_GROWSDOWN ) |
 	       _calc_vm_trans(flags, MAP_LOCKED,     VM_LOCKED    ) |
 	       _calc_vm_trans(flags, MAP_SYNC,	     VM_SYNC      ) |
+#if defined(CONFIG_TRANSPARENT_HUGEPAGE)
 	       _calc_vm_trans(flags, MAP_STACK,	     VM_NOHUGEPAGE) |
+#endif
 	       arch_calc_vm_flag_bits(file, flags);
 }
 

---
base-commit: fc96b232f8e7c0a6c282f47726b2ff6a5fb341d2
change-id: 20250428-map-map_stack-to-vm_nohugepage-only-if-thp-is-enabled-ce40a1de095d

Best regards,
-- 
Ignacio Moreno Gonzalez <Ignacio.MorenoGonzalez@kuka.com>




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-05-06 12:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-02  9:31 [PATCH] mm: mmap: map MAP_STACK to VM_NOHUGEPAGE only if THP is enabled Ignacio Moreno Gonzalez via B4 Relay
2025-05-02 12:46 ` Lorenzo Stoakes
2025-05-02 20:53   ` Yang Shi
2025-05-03  9:50     ` Lorenzo Stoakes
2025-05-05 17:53       ` Yang Shi
2025-05-06 12:26       ` Ignacio Moreno Gonzalez
2025-05-02 13:03 ` Matthew Wilcox
2025-05-02 13:12   ` Lorenzo Stoakes
2025-05-02 14:16     ` Matthew Wilcox
2025-05-02 14:24       ` Lorenzo Stoakes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox