From f06b3bdd9232e722c04062de58da5b45a115bc34 Mon Sep 17 00:00:00 2001 From: Nathan Skrzypczak Date: Mon, 23 Nov 2020 16:23:11 +0100 Subject: dpdk: fix eal in nohugtlb mode When running with `dpdk { no-hugetlb }` dont try to allocate hugepages and remove --in-memory as this seems to be rejected by DPDK Type: fix Change-Id: I02c56ade0b4e706b3f76331745e2af64bb62f6e0 Signed-off-by: Nathan Skrzypczak --- src/plugins/dpdk/device/init.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'src/plugins/dpdk') diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c index 58de03b5343..2d2281e64a9 100644 --- a/src/plugins/dpdk/device/init.c +++ b/src/plugins/dpdk/device/init.c @@ -1177,6 +1177,7 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) u8 *s, *tmp = 0; int ret, i; int num_whitelisted = 0; + int eal_no_hugetlb = 0; u8 no_pci = 0; u8 no_vmbus = 0; u8 file_prefix = 0; @@ -1195,6 +1196,7 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) if (unformat (input, "no-hugetlb")) { vec_add1 (conf->eal_init_args, (u8 *) "--no-huge"); + eal_no_hugetlb = 1; } else if (unformat (input, "telemetry")) conf->enable_telemetry = 1; @@ -1345,22 +1347,27 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) if (!conf->uio_driver_name) conf->uio_driver_name = format (0, "auto%c", 0); - default_hugepage_sz = clib_mem_get_default_hugepage_size (); - - /* *INDENT-OFF* */ - clib_bitmap_foreach (x, tm->cpu_socket_bitmap, ( + if (eal_no_hugetlb == 0) { - clib_error_t *e; - uword n_pages; - /* preallocate at least 16MB of hugepages per socket, - if more is needed it is up to consumer to preallocate more */ - n_pages = round_pow2 ((uword) 16 << 20, default_hugepage_sz); - n_pages /= default_hugepage_sz; - - if ((e = clib_sysfs_prealloc_hugepages(x, 0, n_pages))) - clib_error_report (e); - })); - /* *INDENT-ON* */ + vec_add1 (conf->eal_init_args, (u8 *) "--in-memory"); + + default_hugepage_sz = clib_mem_get_default_hugepage_size (); + + /* *INDENT-OFF* */ + clib_bitmap_foreach (x, tm->cpu_socket_bitmap, ( + { + clib_error_t *e; + uword n_pages; + /* preallocate at least 16MB of hugepages per socket, + if more is needed it is up to consumer to preallocate more */ + n_pages = round_pow2 ((uword) 16 << 20, default_hugepage_sz); + n_pages /= default_hugepage_sz; + + if ((e = clib_sysfs_prealloc_hugepages(x, 0, n_pages))) + clib_error_report (e); + })); + /* *INDENT-ON* */ + } /* on/off dpdk's telemetry thread */ if (conf->enable_telemetry == 0) @@ -1720,7 +1727,6 @@ dpdk_init (vlib_main_t * vm) dm->conf->nchannels = 4; vec_add1 (dm->conf->eal_init_args, (u8 *) "vnet"); - vec_add1 (dm->conf->eal_init_args, (u8 *) "--in-memory"); /* Default vlib_buffer_t flags, DISABLES tcp/udp checksumming... */ dm->buffer_flags_template = (VLIB_BUFFER_TOTAL_LENGTH_VALID | -- cgit 1.2.3-korg