Skip to content

Commit

Permalink
core/util: Adding MR cache malloc hooking mechanism
Browse files Browse the repository at this point in the history
Integrate hooking memory allocation related calls into the MR
cache.  This allows us to support older linux kernel that do not
support userfaultfd.

The core of the code is adapted from OpenMPI.

Signed-off-by: Nikita Gusev <nikita.gusev@intel.com>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
  • Loading branch information
shefty committed Jul 26, 2019
1 parent ae5d5ef commit dbfd9a4
Show file tree
Hide file tree
Showing 5 changed files with 458 additions and 5 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ common_srcs = \
prov/util/src/util_ns.c \
prov/util/src/util_shm.c \
prov/util/src/util_mem_monitor.c\
prov/util/src/util_mem_hooks.c \
prov/util/src/util_mr_cache.c


Expand Down
19 changes: 17 additions & 2 deletions include/ofi_mr.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#include <ofi_list.h>
#include <ofi_tree.h>


struct ofi_mr_info {
struct iovec iov;
};
Expand Down Expand Up @@ -125,6 +124,8 @@ int ofi_monitor_subscribe(struct ofi_mem_monitor *monitor,
void ofi_monitor_unsubscribe(struct ofi_mem_monitor *monitor,
const void *addr, size_t len);

extern struct ofi_mem_monitor *default_monitor;

/*
* Userfault fd memory monitor
*/
Expand All @@ -139,6 +140,19 @@ void ofi_uffd_cleanup(void);

extern struct ofi_mem_monitor *uffd_monitor;

/*
* Memory intercept call memory monitor
*/
struct ofi_memhooks {
struct ofi_mem_monitor monitor;
struct dlist_entry intercept_list;
};

int ofi_memhooks_init(void);
void ofi_memhooks_cleanup(void);

extern struct ofi_mem_monitor *memhooks_monitor;


/*
* Used to store registered memory regions into a lookup map. This
Expand Down Expand Up @@ -184,7 +198,7 @@ int ofi_mr_close(struct fid *fid);
int ofi_mr_regattr(struct fid *fid, const struct fi_mr_attr *attr,
uint64_t flags, struct fid_mr **mr_fid);
int ofi_mr_regv(struct fid *fid, const struct iovec *iov,
size_t count, uint64_t access, uint64_t offset,
size_t count, uint64_t access, uint64_t offset,
uint64_t requested_key, uint64_t flags,
struct fid_mr **mr_fid, void *context);
int ofi_mr_reg(struct fid *fid, const void *buf, size_t len,
Expand All @@ -201,6 +215,7 @@ struct ofi_mr_cache_params {
size_t max_cnt;
size_t max_size;
int merge_regions;
char * monitor;
};

extern struct ofi_mr_cache_params cache_params;
Expand Down
Loading

0 comments on commit dbfd9a4

Please sign in to comment.