In Linux 5.17 a new feature was added, PR_SET_VMA_ANON_NAME, which lets you give names to anonymous virtual memory ranges. These names are shown in /proc/<pid>/maps, which can help with debugging.
The pymalloc allocator uses mmap to allocate arenas. It should use PR_SET_VMA_ANON_NAME to give names to the memory ranges containing arenas, e.g. "Python: arena".
Some examples of this done for other languages are in Glibc and Go.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Activity
picnixz commented on Nov 22, 2025
picnixz commented on Nov 22, 2025
Urhg... It's funny but... I cannot test this because I don't have a recent enough Linux kernel :D
pythongh-141770: Annotate anonymous mmap only for debug build
corona10 commented on Nov 29, 2025
Working and verifying in my local environment.
This feature should be enabled by kernel config itself too.
https://bugzilla.redhat.com/show_bug.cgi?id=2302746
encukou commented on Dec 1, 2025
Should this be exposed to users, with something like mmap.mmap(..., name=...)?
Merge remote-tracking branch 'upstream/main' into pythongh-141770
gh-141770: Annotate anonymous mmap usage if "-X dev" is used (gh-142079)
corona10 commented on Dec 8, 2025
Nice idea, I will pile a new issue.
vstinner commented on Dec 8, 2025
Since it's only supported on Linux, I'm not sure that it's a good idea.
Revert "pythongh-141770: Annotate anonymous mmap usage if "-X dev" is…