Skip to content

Commit 4dd1ee4

Browse files
committed
Address code review
1 parent d71a744 commit 4dd1ee4

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Doc/whatsnew/3.15.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ Build changes
12551255

12561256
* Annotating anonymous mmap usage is now supported if Linux kernel supports ``PR_SET_VMA_ANON_NAME``.
12571257
Annotations are visible in ``/proc/<pid>/maps`` if the kernel supports the feature
1258-
and ``-X dev`` is passed to the interpreter.
1258+
and ``-X dev`` is passed to the Python or Python is built in debug mode.
12591259
(Contributed by Donghee Na in :gh:`141770`)
12601260

12611261

Include/internal/pycore_mmap.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ extern "C" {
1616
# include <sys/prctl.h>
1717
#endif
1818

19-
#if defined(HAVE_PR_SET_VMA_ANON_NAME) && defined(__linux__)
19+
#if defined(HAVE_PR_SET_VMA_ANON_NAME) && defined(__linux__) && defined(Py_DEBUG)
20+
# define _PyAnnotateMemoryMap(addr, size, name) \
21+
do { \
22+
assert(strlen(name) < 80); \
23+
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)(addr), (size), (name)); \
24+
/* Ignore errno from prctl */ \
25+
/* See: https://bugzilla.redhat.com/show_bug.cgi?id=2302746 */ \
26+
errno = 0; \
27+
} while (0)
28+
#elif defined(HAVE_PR_SET_VMA_ANON_NAME) && defined(__linux__)
2029
# define _PyAnnotateMemoryMap(addr, size, name) \
2130
do { \
2231
if (_Py_GetConfig()->dev_mode) { \

0 commit comments

Comments
 (0)