Skip to content

Commit a77c9bd

Browse files
committed
Add support for MAP_SHARED to the proxy library for Linux only
Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
1 parent c5a5577 commit a77c9bd

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
@@ -228,6 +228,10 @@ In case of Linux it can be done without any code changes using the `LD_PRELOAD`
228228
$ LD_PRELOAD=/usr/lib/libumf_proxy.so myprogram
229229
```
230230

231+
The memory used by the proxy memory allocator is mmap'ed:
232+
1) with the `MAP_PRIVATE` flag by default or
233+
2) with the `MAP_SHARED` flag only if the `UMF_PROXY` environment variable contains the `page.disposition=shared` string.
234+
231235
#### Windows
232236

233237
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 flag");
117+
os_params.flag = 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)