File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ cmake_dependent_option(SNMALLOC_STATIC_LIBRARY "Build static libraries" ON "NOT
24
24
cmake_dependent_option (SNMALLOC_MEMCPY_BOUNDS "Perform bounds checks on memcpy with heap objects" OFF "NOT SNMALLOC_HEADER_ONLY_LIBRARY" OFF )
25
25
cmake_dependent_option (SNMALLOC_CHECK_LOADS "Perform bounds checks on the source argument to memcpy with heap objects" OFF "SNMALLOC_MEMCPY_BOUNDS" OFF )
26
26
cmake_dependent_option (SNMALLOC_OPTIMISE_FOR_CURRENT_MACHINE "Compile for current machine architecture" Off "NOT SNMALLOC_HEADER_ONLY_LIBRARY" OFF )
27
+ cmake_dependent_option (SNMALLOC_PAGEID "Set an id to memory regions" OFF "NOT SNMALLOC_PAGEID" OFF )
27
28
if (NOT SNMALLOC_HEADER_ONLY_LIBRARY )
28
29
# Pick a sensible default for the thread cleanup mechanism
29
30
if (${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD )
@@ -323,6 +324,8 @@ if(NOT SNMALLOC_HEADER_ONLY_LIBRARY)
323
324
324
325
target_compile_definitions (${name} PRIVATE
325
326
SNMALLOC_CHECK_LOADS=$<IF:$<BOOL:${SNMALLOC_CHECK_LOADS}>,true,false> )
327
+ target_compile_definitions (${name} PRIVATE
328
+ SNMALLOC_PAGEID=$<IF:$<BOOL:${SNMALLOC_PAGEID}>,true,false> )
326
329
327
330
install (TARGETS ${name} EXPORT snmallocConfig )
328
331
Original file line number Diff line number Diff line change 6
6
7
7
# include < string.h>
8
8
# include < sys/mman.h>
9
+ # include < sys/prctl.h>
9
10
# include < syscall.h>
10
11
11
12
extern " C" int puts (const char * str);
@@ -38,7 +39,32 @@ namespace snmalloc
38
39
{
39
40
void * p = PALPOSIX<PALLinux>::reserve (size);
40
41
if (p)
42
+ {
41
43
madvise (p, size, MADV_DONTDUMP);
44
+ # ifdef SNMALLOC_PAGEID
45
+ # ifndef PR_SET_VMA
46
+ # define PR_SET_VMA 0x53564d41
47
+ # define PR_SET_VMA_ANON_NAME 0
48
+ # endif
49
+
50
+ /* *
51
+ *
52
+ * If the kernel is set with CONFIG_ANON_VMA_NAME
53
+ * the reserved pages would appear as follow
54
+ *
55
+ * 7fa5f0ceb000-7fa5f0e00000 rw-p 00000000 00:00 0 [anon:snmalloc]
56
+ * 7fa5f0e00000-7fa5f1800000 rw-p 00000000 00:00 0 [anon:snmalloc]
57
+ *
58
+ */
59
+
60
+ prctl (
61
+ PR_SET_VMA,
62
+ PR_SET_VMA_ANON_NAME,
63
+ (unsigned long )p,
64
+ size,
65
+ (unsigned long )" snmalloc" );
66
+ # endif
67
+ }
42
68
return p;
43
69
}
44
70
You can’t perform that action at this time.
0 commit comments