Skip to content

Commit 83f6a88

Browse files
committed
Add support for MAP_SHARED to the proxy library for Linux only
Signed-off-by: Lukasz Dorau <[email protected]>
1 parent eb926b8 commit 83f6a88

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ In case of Linux it can be done without any code changes using the `LD_PRELOAD`
233233
$ LD_PRELOAD=/usr/lib/libumf_proxy.so myprogram
234234
```
235235

236+
The memory used by the proxy memory allocator is mmap'ed:
237+
1) with the `MAP_PRIVATE` flag by default or
238+
2) with the `MAP_SHARED` flag only if the `UMF_PROXY` environment variable contains the `page.disposition=shared` string.
239+
236240
#### Windows
237241

238242
In case of Windows it requires:

src/proxy_lib/proxy_lib.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ void proxy_lib_create_common(void) {
111111
umfOsMemoryProviderParamsDefault();
112112
enum umf_result_t umf_result;
113113

114+
#ifndef _WIN32
115+
if (util_env_var_has_str("UMF_PROXY", "page.disposition=shared")) {
116+
LOG_DEBUG("proxy_lib: using the MAP_SHARED visibility mode");
117+
os_params.visibility = UMF_MEM_MAP_SHARED;
118+
}
119+
#endif
120+
114121
umf_result = umfMemoryProviderCreate(umfOsMemoryProviderOps(), &os_params,
115122
&OS_memory_provider);
116123
if (umf_result != UMF_RESULT_SUCCESS) {

0 commit comments

Comments
 (0)