diff options
author | Damjan Marion <damarion@cisco.com> | 2020-10-09 17:16:55 +0200 |
---|---|---|
committer | Damjan Marion <damarion@cisco.com> | 2021-04-18 15:22:50 +0200 |
commit | f8cb70177f3321e091632b26cf2a0a67b43878ea (patch) | |
tree | bd37760af3e597a4e5b4cfa4682912906d93a9c0 /src/vppinfra/linux | |
parent | 30a819579cb396db1c975ae8e08477129aa7950d (diff) |
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 <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/linux')
-rw-r--r-- | src/vppinfra/linux/mem.c | 14 | ||||
-rw-r--r-- | src/vppinfra/linux/syscall.h | 66 |
2 files changed, 7 insertions, 73 deletions
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 <vppinfra/time.h> #include <vppinfra/format.h> #include <vppinfra/clib_error.h> -#include <vppinfra/linux/syscall.h> #include <vppinfra/linux/sysfs.h> #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 <unistd.h> -#include <sys/syscall.h> - -#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: - */ |