diff options
author | Benoît Ganne <bganne@cisco.com> | 2020-09-28 17:34:17 +0200 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2020-10-02 08:51:47 +0000 |
commit | 2b92c705791a8186e20b00bbb1c8fc6fd1eddff8 (patch) | |
tree | bd438ed70d010b473a7f83f59e6ec1be91abda80 /src/vppinfra/linux/mem.c | |
parent | f30e07e3b5d660981593ee9fa379a8b0abc54684 (diff) |
vppinfra: fix legacy huge pages creation for default size
Type: fix
Change-Id: I941b92ebec66ccd9c9e9a12d485844313c9f117b
Signed-off-by: Benoît Ganne <bganne@cisco.com>
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vppinfra/linux/mem.c')
-rw-r--r-- | src/vppinfra/linux/mem.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/vppinfra/linux/mem.c b/src/vppinfra/linux/mem.c index 1b3694b1af4..8b2fd14d210 100644 --- a/src/vppinfra/linux/mem.c +++ b/src/vppinfra/linux/mem.c @@ -359,11 +359,20 @@ legacy_memfd_create (u8 * name) clib_mem_main_t *mm = &clib_mem_main; int fd = -1; char *mount_dir; + u8 *temp; u8 *filename; + /* + * Since mkdtemp will modify template string "/tmp/hugepage_mount.XXXXXX", + * it must not be a string constant, but should be declared as + * a character array. + */ + temp = format (0, "/tmp/hugepage_mount.XXXXXX%c", 0); + /* create mount directory */ - if ((mount_dir = mkdtemp ("/tmp/hugepage_mount.XXXXXX")) == 0) + if ((mount_dir = mkdtemp ((char *) temp)) == 0) { + vec_free (temp); vec_reset_length (mm->error); mm->error = clib_error_return_unix (mm->error, "mkdtemp"); return CLIB_MEM_ERROR; @@ -371,6 +380,7 @@ legacy_memfd_create (u8 * name) if (mount ("none", mount_dir, "hugetlbfs", 0, NULL)) { + vec_free (temp); rmdir ((char *) mount_dir); vec_reset_length (mm->error); mm->error = clib_error_return_unix (mm->error, "mount"); @@ -388,6 +398,7 @@ legacy_memfd_create (u8 * name) umount2 ((char *) mount_dir, MNT_DETACH); rmdir ((char *) mount_dir); vec_free (filename); + vec_free (temp); return fd; } @@ -403,6 +414,8 @@ clib_mem_vm_create_fd (clib_mem_page_sz_t log2_page_size, char *fmt, ...) if (log2_page_size == mm->log2_page_sz) log2_page_size = CLIB_MEM_PAGE_SZ_DEFAULT; + else if (log2_page_size == mm->log2_default_hugepage_sz) + log2_page_size = CLIB_MEM_PAGE_SZ_DEFAULT_HUGE; switch (log2_page_size) { |