From 986ca000f8398a00be07ccaf1ab4f7a0c84e69d9 Mon Sep 17 00:00:00 2001 From: Alex Mikheev Date: Tue, 10 Jan 2017 14:21:36 +0200 Subject: [PATCH] oshmem: spml: add memory allocation hook The hook is called from memheap when memory range is going to be allocated by smalloc(), realloc() and others. ucx spml uses this hook to call ucp_mem_advise in order to speedup non blocking memory mapping. Signed-off-by: Alex Mikheev --- oshmem/mca/memheap/buddy/memheap_buddy.c | 2 +- .../mca/memheap/ptmalloc/memheap_ptmalloc.c | 3 ++ oshmem/mca/spml/base/base.h | 1 + oshmem/mca/spml/base/spml_base.c | 4 +++ oshmem/mca/spml/ikrit/spml_ikrit.c | 1 + oshmem/mca/spml/spml.h | 11 +++++++ oshmem/mca/spml/ucx/spml_ucx.c | 30 ++++++++++++++++++- oshmem/mca/spml/ucx/spml_ucx.h | 2 ++ oshmem/mca/spml/yoda/spml_yoda.c | 1 + 9 files changed, 53 insertions(+), 2 deletions(-) diff --git a/oshmem/mca/memheap/buddy/memheap_buddy.c b/oshmem/mca/memheap/buddy/memheap_buddy.c index c7715f4dd1..b3f4ca1df9 100644 --- a/oshmem/mca/memheap/buddy/memheap_buddy.c +++ b/oshmem/mca/memheap/buddy/memheap_buddy.c @@ -469,7 +469,7 @@ static int _do_alloc(uint32_t order, } *p_buff = (void*) addr; - /* no barrier because it is not required by spec! */ + MCA_SPML_CALL(memuse_hook(addr, 1<mem_h, ¶ms); + if (UCS_OK != status) { + SPML_ERROR("ucp_mem_advise failed addr %p len %llu", + addr, (unsigned long long)length); + } +} + sshmem_mkey_t *mca_spml_ucx_register(void* addr, size_t size, uint64_t shmid, diff --git a/oshmem/mca/spml/ucx/spml_ucx.h b/oshmem/mca/spml/ucx/spml_ucx.h index 4b248e026a..b524031d3f 100644 --- a/oshmem/mca/spml/ucx/spml_ucx.h +++ b/oshmem/mca/spml/ucx/spml_ucx.h @@ -108,6 +108,8 @@ extern sshmem_mkey_t *mca_spml_ucx_register(void* addr, int *count); extern int mca_spml_ucx_deregister(sshmem_mkey_t *mkeys); +extern void mca_spml_ucx_memuse_hook(void *addr, size_t length); + extern void mca_spml_ucx_rmkey_unpack(sshmem_mkey_t *mkey, uint32_t segno, int pe, int tr_id); extern void mca_spml_ucx_rmkey_free(sshmem_mkey_t *mkey); diff --git a/oshmem/mca/spml/yoda/spml_yoda.c b/oshmem/mca/spml/yoda/spml_yoda.c index 8e87c58df7..ebdceab8c9 100644 --- a/oshmem/mca/spml/yoda/spml_yoda.c +++ b/oshmem/mca/spml/yoda/spml_yoda.c @@ -65,6 +65,7 @@ mca_spml_yoda_module_t mca_spml_yoda = { mca_spml_yoda_fence, mca_spml_base_rmkey_unpack, mca_spml_base_rmkey_free, + mca_spml_base_memuse_hook, (void *)&mca_spml_yoda }