summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/svm/ssvm.c27
-rw-r--r--src/vppinfra/linux/mem.c58
-rw-r--r--src/vppinfra/mem.h1
3 files changed, 15 insertions, 71 deletions
diff --git a/src/svm/ssvm.c b/src/svm/ssvm.c
index aca65ad6f42..47441eb94df 100644
--- a/src/svm/ssvm.c
+++ b/src/svm/ssvm.c
@@ -291,7 +291,7 @@ ssvm_server_init_memfd (ssvm_private_t * memfd)
int
ssvm_client_init_memfd (ssvm_private_t * memfd)
{
- clib_mem_vm_map_t mapa = { 0 };
+ int mmap_flags = MAP_SHARED;
ssvm_shared_header_t *sh;
uword page_size;
@@ -304,37 +304,40 @@ ssvm_client_init_memfd (ssvm_private_t * memfd)
return SSVM_API_ERROR_MMAP;
}
+ if (memfd->requested_va)
+ mmap_flags |= MAP_FIXED;
+
/*
* Map the segment once, to look at the shared header
*/
- mapa.fd = memfd->fd;
- mapa.size = page_size;
+ sh = (void *) mmap (0, page_size, PROT_READ | PROT_WRITE, MAP_SHARED,
+ memfd->fd, 0);
- if (clib_mem_vm_ext_map (&mapa))
+ if (sh == MAP_FAILED)
{
- clib_unix_warning ("client research mmap (fd %d)", mapa.fd);
+ clib_unix_warning ("client research mmap (fd %d)", memfd->fd);
close (memfd->fd);
return SSVM_API_ERROR_MMAP;
}
- sh = mapa.addr;
memfd->requested_va = sh->ssvm_va;
memfd->ssvm_size = sh->ssvm_size;
- clib_mem_vm_free (sh, page_size);
+ munmap (sh, page_size);
/*
* Remap the segment at the 'right' address
*/
- mapa.requested_va = memfd->requested_va;
- mapa.size = memfd->ssvm_size;
- if (clib_mem_vm_ext_map (&mapa))
+ sh = (void *) mmap (uword_to_pointer (memfd->requested_va, void *),
+ memfd->ssvm_size,
+ PROT_READ | PROT_WRITE, mmap_flags, memfd->fd, 0);
+
+ if (sh == MAP_FAILED)
{
clib_unix_warning ("client final mmap");
close (memfd->fd);
return SSVM_API_ERROR_MMAP;
}
- sh = mapa.addr;
sh->client_pid = getpid ();
memfd->sh = sh;
return 0;
@@ -347,7 +350,7 @@ ssvm_delete_memfd (ssvm_private_t * memfd)
if (memfd->is_server)
clib_mem_vm_unmap (memfd->sh);
else
- clib_mem_vm_free (memfd->sh, memfd->ssvm_size);
+ munmap (memfd->sh, memfd->ssvm_size);
close (memfd->fd);
}
diff --git a/src/vppinfra/linux/mem.c b/src/vppinfra/linux/mem.c
index c20de9c2103..1b3694b1af4 100644
--- a/src/vppinfra/linux/mem.c
+++ b/src/vppinfra/linux/mem.c
@@ -750,64 +750,6 @@ done:
return r;
}
-clib_error_t *
-clib_mem_vm_ext_map (clib_mem_vm_map_t * a)
-{
- long unsigned int old_mask[16] = { 0 };
- int mmap_flags = MAP_SHARED;
- clib_error_t *err = 0;
- int old_mpol = -1;
- void *addr;
- int rv;
-
- if (a->numa_node)
- {
- rv = get_mempolicy (&old_mpol, old_mask, sizeof (old_mask) * 8 + 1, 0,
- 0);
-
- if (rv == -1)
- {
- err = clib_error_return_unix (0, "get_mempolicy");
- goto done;
- }
- }
-
- if (a->requested_va)
- mmap_flags |= MAP_FIXED;
-
- if (old_mpol != -1)
- {
- long unsigned int mask[16] = { 0 };
- mask[0] = 1 << a->numa_node;
- rv = set_mempolicy (MPOL_BIND, mask, sizeof (mask) * 8 + 1);
- if (rv == -1)
- {
- err = clib_error_return_unix (0, "set_mempolicy");
- goto done;
- }
- }
-
- addr = (void *) mmap (uword_to_pointer (a->requested_va, void *), a->size,
- PROT_READ | PROT_WRITE, mmap_flags, a->fd, 0);
-
- if (addr == MAP_FAILED)
- return clib_error_return_unix (0, "mmap");
-
- /* re-apply old numa memory policy */
- if (old_mpol != -1 &&
- set_mempolicy (old_mpol, old_mask, sizeof (old_mask) * 8 + 1) == -1)
- {
- err = clib_error_return_unix (0, "set_mempolicy");
- goto done;
- }
-
- a->addr = addr;
- CLIB_MEM_UNPOISON (addr, a->size);
-
-done:
- return err;
-}
-
int
clib_mem_set_numa_affinity (u8 numa_node, int force)
{
diff --git a/src/vppinfra/mem.h b/src/vppinfra/mem.h
index 2fd4bfb5dbb..e998eb0f7bc 100644
--- a/src/vppinfra/mem.h
+++ b/src/vppinfra/mem.h
@@ -498,7 +498,6 @@ typedef struct
u8 numa_node;
} clib_mem_vm_map_t;
-clib_error_t *clib_mem_vm_ext_map (clib_mem_vm_map_t * a);
void clib_mem_vm_randomize_va (uword * requested_va,
clib_mem_page_sz_t log2_page_size);
void mheap_trace (void *v, int enable);