Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/vnet/devices/virtio/vhost_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,9 @@ vhost_user_exit (vlib_main_t * vm)
vhost_user_main_t *vum = &vhost_user_main;
vhost_user_intf_t *vui;

vlib_worker_thread_barrier_sync (vlib_get_main ());
if (vec_len (vlib_mains) > 1)
vlib_worker_thread_barrier_sync (vlib_get_main ());

/* *INDENT-OFF* */
pool_foreach (vui, vum->vhost_user_interfaces, {
vhost_user_delete_if (vnm, vm, vui->sw_if_index);
Expand Down
21 changes: 21 additions & 0 deletions src/vppinfra/pmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/mempolicy.h>
#include <linux/memfd.h>

Expand Down Expand Up @@ -254,6 +255,7 @@ pmalloc_map_pages (clib_pmalloc_main_t * pm, clib_pmalloc_arena_t * a,
int old_mpol = -1;
long unsigned int mask[16] = { 0 };
long unsigned int old_mask[16] = { 0 };
uword page_size = 1 << a->log2_subpage_sz;
uword size = (uword) n_pages << pm->def_log2_page_sz;

clib_error_free (pm->error);
Expand Down Expand Up @@ -326,6 +328,25 @@ pmalloc_map_pages (clib_pmalloc_main_t * pm, clib_pmalloc_arena_t * a,
goto error;
}

/* Check if huge page is not allocated,
wrong allocation will generate the SIGBUS */
if (a->log2_subpage_sz != pm->sys_log2_page_sz)
{
for (int i = 0; i < n_pages; i++)
{
unsigned char flag;
mincore (va + i * page_size, 1, &flag);
// flag is 1 if the page was successfully allocated and in memory
if (!flag)
{
pm->error =
clib_error_return_unix (0,
"Unable to fulfill huge page allocation request");
goto error;
}
}
}

clib_memset (va, 0, size);

rv = set_mempolicy (old_mpol, old_mask, sizeof (old_mask) * 8 + 1);
Expand Down