linux icon indicating copy to clipboard operation
linux copied to clipboard

configs: enable CONFIG_ANON_VMA_NAME

Open DCNick3 opened this issue 8 months ago • 4 comments

Describe the bug

PR_SET_VMA_ANON_NAME is a useful linux feature that allows you to give a name to a mapped memory range. It has been generally available in desktop linux since kernel 5.17. Its support, however, requires enabling CONFIG_ANON_VMA_NAME at kernel compile time, and it is disabled on Raspberry Pi 5 kernel.

It would be nice to see it enabled.

Steps to reproduce the behaviour

sudo modprobe configs
zcat /proc/config.gz | grep CONFIG_ANON_VMA_NAME
# CONFIG_ANON_VMA_NAME is not set

Device (s)

Raspberry Pi 5

System

cat /etc/rpi-issue:

Raspberry Pi reference 2024-11-19
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 891df1e21ed2b6099a2e6a13e26c91dea44b34d4, stage2

vcgencmd version:

2025/05/08 15:13:17 
Copyright (c) 2012 Broadcom
version 69471177 (release) (embedded)

uname -a:

Linux ninika-rpi 6.12.34+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.12.34-1+rpt1~bookworm (2025-06-26) aarch64 GNU/Linux

Logs

No response

Additional context

No response

DCNick3 avatar Aug 19 '25 16:08 DCNick3

I did go around testing kernel configurations of various linux distributions, and it seems that the "generally available in desktop linux" is not entirely true. The distro support is spotty:

  • Debian 12 has it disabled
  • Ubuntu 24.04 has it enabled
  • WSL Ubuntu 24.04 has it disabled (and the kernel is too old to support it too)
  • Fedora 42 has it disabled
  • Arch Linux has it enabled
  • Void Linux has it enabled
  • Raspberry Pi OS has it disabled
  • Google's Container-Optimized OS has it disabled
  • Android has it enabled

It's still a very useful feature when writing software that manually calls mmap, and it simplifies debugging greatly.

DCNick3 avatar Aug 20 '25 08:08 DCNick3

Can you point to any software which requires it?

pelwell avatar Aug 20 '25 08:08 pelwell

Since it's a debugging aid, it's hard to find any software that "requires" it (that is, won't work without it enabled), but there's a bunch that can take advantage of it:

  • glibc: https://github.com/bminor/glibc/blob/fc058b46c78f090580c1ca5b785b54ae4092f0c1/malloc/malloc.c#L2434 & https://github.com/bminor/glibc/blob/fc058b46c78f090580c1ca5b785b54ae4092f0c1/sysdeps/unix/sysv/linux/setvmaname.c#L63-L64
  • go runtime: https://go.dev/doc/go1.25#vma-names-on-linux
  • ruby runtime: https://github.com/ruby/ruby/blob/609fe7e48a2430c7d7db0a48855e851393c73b6c/gc.c#L5482
  • php runtime: https://github.com/CM4all/php-src/blob/dbdcc95c9cc7c17e8a3e6f56ca6be68378ba8f9c/Zend/zend_mmap.h#L39
  • OxCaml runtime: https://github.com/stedolan/flambda-backend/blob/d0002dabd2cdbfcf460cb5b1935e34d813a739f4/runtime/unix.c#L528
  • MMTk, a memory manager framework: https://github.com/mmtk/mmtk-core/blob/e058ceeb33daa6a07c29fe4cbffae71af5b9da99/src/util/memory.rs#L265
  • rpmalloc, a memory allocator: https://github.com/mjansson/rpmalloc/blob/6b34d956911bb778ec6b99e4dbff9e956c5dc467/rpmalloc/rpmalloc.c#L706
  • jemalloc, a memory allocator: https://github.com/jemalloc/jemalloc/blob/1972241cd204c60fb5b66f23c48a117879636161/src/pages.c#L116
  • mimalloc, a memory allocator: https://github.com/microsoft/mimalloc/blob/09a27098aa6e9286518bd9c74e6ffa7199c3f04e/src/prim/unix/prim.c#L215
  • chromium: https://source.chromium.org/chromium/chromium/src/+/a78c1724fac4b8184387e191650381d8ebcd7cfd:base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.cc;l=159;bpv=0;bpt=0
  • firefox: https://searchfox.org/firefox-main/rev/60308bc3792ef201b82377682de068a5a1c72575/mfbt/TaggedAnonymousMemory.cpp#34
  • bytehound, a memory profiler: https://github.com/koute/bytehound/blob/f8397e70efcdad1d48c4999d609d786ed8ab988b/preload/src/api.rs#L102
  • ...

I am also developing a piece of software that would benefit from such a functionality on a Raspberry Pi, which is my motivation for wanting this in Raspberry Pi OS kernels.

DCNick3 avatar Aug 20 '25 08:08 DCNick3

That's not a compelling argument in favour of enabling the feature. It's telling that only one architecture (and 2 defconfigs) enable it:

arch/s390/configs/debug_defconfig:110:CONFIG_ANON_VMA_NAME=y
arch/s390/configs/defconfig:101:CONFIG_ANON_VMA_NAME=y

pelwell avatar Aug 20 '25 16:08 pelwell