Skip to content

Commit 32cc007

Browse files
committed
Address code review
1 parent 855742b commit 32cc007

File tree

7 files changed

+12
-11
lines changed

7 files changed

+12
-11
lines changed

Include/internal/pycore_pymem.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,13 @@ static inline int
100100
_PyAnnotateMemoryMap(void *addr, size_t size, const char *name)
101101
{
102102
#if defined(Py_DEBUG) && defined(HAVE_PR_SET_VMA_ANON_NAME) && defined(__linux__)
103-
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)addr, size, name);
104-
// Ignore errno from prctl
105-
// See: https://bugzilla.redhat.com/show_bug.cgi?id=2302746
106-
errno = 0;
103+
assert(strlen(name) < 80);
104+
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)addr, size, name);
105+
// Ignore errno from prctl
106+
// See: https://bugzilla.redhat.com/show_bug.cgi?id=2302746
107+
errno = 0;
107108
#endif
108-
return 0;
109+
return 0;
109110
}
110111

111112
extern int _PyMem_GetAllocatorName(

Modules/_ctypes/malloc_closure.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static void more_core(void)
8484
0);
8585
if (item == (void *)MAP_FAILED)
8686
return;
87-
_PyAnnotateMemoryMap(item, mem_size, "cpython:more_core");
87+
_PyAnnotateMemoryMap(item, mem_size, "cpython:malloc_closure:more_core");
8888
#endif
8989

9090
#ifdef MALLOC_CLOSURE_DEBUG

Modules/mmapmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1952,7 +1952,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
19521952
PyErr_SetFromErrno(PyExc_OSError);
19531953
return NULL;
19541954
}
1955-
_PyAnnotateMemoryMap(m_obj->data, map_size, "cpython:new_mmap_object");
1955+
_PyAnnotateMemoryMap(m_obj->data, map_size, "cpython:mmap:new_mmap_object");
19561956
m_obj->access = (access_mode)access;
19571957
return (PyObject *)m_obj;
19581958
}

Objects/obmalloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ _PyMem_ArenaAlloc(void *Py_UNUSED(ctx), size_t size)
467467
if (ptr == MAP_FAILED)
468468
return NULL;
469469
assert(ptr != NULL);
470-
_PyAnnotateMemoryMap(ptr, size, "cpython:PyMem_ArenaAlloc");
470+
_PyAnnotateMemoryMap(ptr, size, "cpython:obmalloc:PyMem_ArenaAlloc");
471471
return ptr;
472472
#else
473473
return malloc(size);

Python/jit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jit_alloc(size_t size)
7272
unsigned char *memory = mmap(NULL, size, prot, flags, -1, 0);
7373
int failed = memory == MAP_FAILED;
7474
if (!failed) {
75-
_PyAnnotateMemoryMap(memory, size, "cpython:jit_alloc");
75+
_PyAnnotateMemoryMap(memory, size, "cpython:jit:jit_alloc");
7676
}
7777
#endif
7878
if (failed) {

Python/perf_jit_trampoline.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ static void* perf_map_jit_init(void) {
10861086
close(fd);
10871087
return NULL; // Memory mapping failed
10881088
}
1089-
_PyAnnotateMemoryMap(perf_jit_map_state.mapped_buffer, page_size, "cpython:perf_map_jit_init");
1089+
_PyAnnotateMemoryMap(perf_jit_map_state.mapped_buffer, page_size, "cpython:perf_jit_trampoline:perf_map_jit_init");
10901090
#endif
10911091

10921092
perf_jit_map_state.mapped_size = page_size;

Python/perf_trampoline.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ new_code_arena(void)
291291
perf_status = PERF_STATUS_FAILED;
292292
return -1;
293293
}
294-
_PyAnnotateMemoryMap(memory, mem_size, "cpython:new_code_arena");
294+
_PyAnnotateMemoryMap(memory, mem_size, "cpython:perf_trampoline:new_code_arena");
295295
void *start = &_Py_trampoline_func_start;
296296
void *end = &_Py_trampoline_func_end;
297297
size_t code_size = end - start;

0 commit comments

Comments
 (0)