From f8cb70177f3321e091632b26cf2a0a67b43878ea Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Fri, 9 Oct 2020 17:16:55 +0200 Subject: vppinfra: remove linux/syscall.h For portabiliy reasons it is better to have all wrapped in clib code. I.e. instead of using getcpu() we have clib_get_current_numa_node () and clib_get_current_cpu_id(). Type: refactor Change-Id: I29b52d7f29bc7f93873402c4070561f564b71c63 Signed-off-by: Damjan Marion --- src/vppinfra/linux/mem.c | 14 +++++----- src/vppinfra/linux/syscall.h | 66 -------------------------------------------- 2 files changed, 7 insertions(+), 73 deletions(-) delete mode 100644 src/vppinfra/linux/syscall.h (limited to 'src/vppinfra/linux') diff --git a/src/vppinfra/linux/mem.c b/src/vppinfra/linux/mem.c index 11a1e9ee45a..cb46df82552 100644 --- a/src/vppinfra/linux/mem.c +++ b/src/vppinfra/linux/mem.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #ifndef F_LINUX_SPECIFIC_BASE @@ -149,7 +148,7 @@ clib_mem_main_init () mm->log2_page_sz = min_log2 (page_size); /* default system hugeppage size */ - if ((fd = memfd_create ("test", MFD_HUGETLB)) != -1) + if ((fd = syscall (__NR_memfd_create, "test", MFD_HUGETLB)) != -1) { mm->log2_default_hugepage_sz = clib_mem_get_fd_log2_page_size (fd); close (fd); @@ -169,7 +168,7 @@ clib_mem_main_init () for (int i = 0; i < CLIB_MAX_NUMAS; i++) { int status; - if (move_pages (0, 1, &va, &i, &status, 0) == 0) + if (syscall (__NR_move_pages, 0, 1, &va, &i, &status, 0) == 0) mm->numa_node_bitmap |= 1ULL << i; } @@ -298,7 +297,7 @@ clib_mem_vm_create_fd (clib_mem_page_sz_t log2_page_size, char *fmt, ...) vec_add1 (s, 0); /* memfd_create introduced in kernel 3.17, we don't support older kernels */ - fd = memfd_create ((char *) s, memfd_flags); + fd = syscall (__NR_memfd_create, (char *) s, memfd_flags); /* kernel versions < 4.14 does not support memfd_create for huge pages */ if (fd == -1 && errno == EINVAL && @@ -568,7 +567,7 @@ clib_mem_get_page_stats (void *start, clib_mem_page_sz_t log2_page_size, stats->total = n_pages; stats->log2_page_sz = log2_page_size; - if (move_pages (0, n_pages, ptr, 0, status, 0) != 0) + if (syscall (__NR_move_pages, 0, n_pages, ptr, 0, status, 0) != 0) { stats->unknown = n_pages; goto done; @@ -658,7 +657,8 @@ clib_mem_set_numa_affinity (u8 numa_node, int force) mask[0] = 1 << numa_node; - if (set_mempolicy (force ? MPOL_BIND : MPOL_PREFERRED, mask, mask_len)) + if (syscall (__NR_set_mempolicy, force ? MPOL_BIND : MPOL_PREFERRED, mask, + mask_len)) goto error; vec_reset_length (mm->error); @@ -675,7 +675,7 @@ clib_mem_set_default_numa_affinity () { clib_mem_main_t *mm = &clib_mem_main; - if (set_mempolicy (MPOL_DEFAULT, 0, 0)) + if (syscall (__NR_set_mempolicy, MPOL_DEFAULT, 0, 0)) { vec_reset_length (mm->error); mm->error = clib_error_return_unix (mm->error, (char *) __func__); diff --git a/src/vppinfra/linux/syscall.h b/src/vppinfra/linux/syscall.h deleted file mode 100644 index c07cad631bd..00000000000 --- a/src/vppinfra/linux/syscall.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2017 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef included_linux_syscall_h -#define included_linux_syscall_h - -#include -#include - -#ifndef HAVE_GETCPU -static inline int -getcpu (unsigned *cpu, unsigned *node) -{ - return syscall (__NR_getcpu, cpu, node, 0); -} -#endif - -static inline long -set_mempolicy (int mode, const unsigned long *nodemask, unsigned long maxnode) -{ - return syscall (__NR_set_mempolicy, mode, nodemask, maxnode); -} - -static inline int -get_mempolicy (int *mode, unsigned long *nodemask, unsigned long maxnode, - void *addr, unsigned long flags) -{ - return syscall (__NR_get_mempolicy, mode, nodemask, maxnode, addr, flags); -} - -static inline long -move_pages (int pid, unsigned long count, void **pages, const int *nodes, - int *status, int flags) -{ - return syscall (__NR_move_pages, pid, count, pages, nodes, status, flags); -} - -#ifndef HAVE_MEMFD_CREATE -static inline int -memfd_create (const char *name, unsigned int flags) -{ - return syscall (__NR_memfd_create, name, flags); -} -#endif - -#endif /* included_linux_syscall_h */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ -- cgit 1.2.3-korg