Commit Graph

1 Commits

Author SHA1 Message Date
Max Kellermann
e67565f54c
Zend, ext/opcache: use PR_SET_VMA_ANON_NAME (Linux 5.17) (#8234)
The new Linux 5.17 feature PR_SET_VMA_ANON_NAME can give names to
anonymous private memory, see:

 https://lwn.net/Articles/867818/

It can be useful while debugging, to identify which portion of the
process's memory belongs to which subsystem.

This is how /proc/PID/maps can look like:

 555ccd400000-555ccdc00000 r-xp 00000000 00:00 0                          [anon:huge_code_pages]
 7f6ec6600000-7f6ec6800000 rw-p 00000000 00:00 0                          [anon:zend_alloc]

The first mapping is the PHP executable copied to anonymous memory by
option "opcache.huge_code_pages".  The second one is a memory area for
the "zend_alloc.h" memory allocator library.

Unfortunately, it is not possible to give names to shared memory
(MAP_SHARED),  because Linux MAP_SHARED really maps /dev/zero (see
shmem_zero_setup()), which makes madvise_vma_anon_name() believe this
is a file mapping, failing the prctl() with EBADF.
2022-06-20 12:27:01 +01:00