selftests: mm: remove duplicate unneeded defines
authorMuhammad Usama Anjum <usama.anjum@collabora.com>
Mon, 12 Jun 2023 09:53:47 +0000 (14:53 +0500)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 19 Jun 2023 23:19:25 +0000 (16:19 -0700)
Remove all defines which aren't needed after correctly including the
kernel header files.

Link: https://lkml.kernel.org/r/20230612095347.996335-2-usama.anjum@collabora.com
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Stefan Roesch <shr@devkernel.io>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
17 files changed:
tools/testing/selftests/mm/cow.c
tools/testing/selftests/mm/hugepage-shm.c
tools/testing/selftests/mm/hugepage-vmemmap.c
tools/testing/selftests/mm/khugepaged.c
tools/testing/selftests/mm/madv_populate.c
tools/testing/selftests/mm/map_fixed_noreplace.c
tools/testing/selftests/mm/map_hugetlb.c
tools/testing/selftests/mm/map_populate.c
tools/testing/selftests/mm/mlock-random-test.c
tools/testing/selftests/mm/mlock2.h
tools/testing/selftests/mm/mrelease_test.c
tools/testing/selftests/mm/mremap_dontunmap.c
tools/testing/selftests/mm/on-fault-limit.c
tools/testing/selftests/mm/pkey-powerpc.h
tools/testing/selftests/mm/pkey-x86.h
tools/testing/selftests/mm/protection_keys.c
tools/testing/selftests/mm/vm_util.h

index e4c5095e74fc2318fb9f9c2fc2fdef64af47251d..7324ce5363c0c98103aced7d686f373089db60de 100644 (file)
@@ -15,6 +15,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <assert.h>
+#include <linux/mman.h>
 #include <sys/mman.h>
 #include <sys/ioctl.h>
 #include <sys/wait.h>
index e2527f32005b38258790617369a5038c5bfceb3d..478bb1e989e9f3b58b61c252587a2978f0f55a0d 100644 (file)
 #include <sys/shm.h>
 #include <sys/mman.h>
 
-#ifndef SHM_HUGETLB
-#define SHM_HUGETLB 04000
-#endif
-
 #define LENGTH (256UL*1024*1024)
 
 #define dprintf(x)  printf(x)
index 557bdbd4f87e8684530abee51a633e0470f50829..5b354c209e936f825cb4156c60ac0836e0be8288 100644 (file)
 
 #define MAP_LENGTH             (2UL * 1024 * 1024)
 
-#ifndef MAP_HUGETLB
-#define MAP_HUGETLB            0x40000 /* arch specific */
-#endif
-
 #define PAGE_SIZE              4096
 
 #define PAGE_COMPOUND_HEAD     (1UL << 15)
index e88ee039d0eb44e381be7980f50afdd7fee54d9b..030667cb55337735355bb0bb833f4a5a56cfbdee 100644 (file)
@@ -11,6 +11,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#include <linux/mman.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
 #include <sys/types.h>
index 262eae6b58f230bc66a44ff69a37436ad70d370e..60547245e479b1517f83adb30360c64728036899 100644 (file)
 #include "../kselftest.h"
 #include "vm_util.h"
 
-#ifndef MADV_POPULATE_READ
-#define MADV_POPULATE_READ     22
-#endif /* MADV_POPULATE_READ */
-#ifndef MADV_POPULATE_WRITE
-#define MADV_POPULATE_WRITE    23
-#endif /* MADV_POPULATE_WRITE */
-
 /*
  * For now, we're using 2 MiB of private anonymous memory for all tests.
  */
index eed44322d1a635e6405bd6bc79eacf434a76697d..598159f3df1f246a088b7c145ebee7648d62bf62 100644 (file)
 #include <stdlib.h>
 #include <unistd.h>
 
-#ifndef MAP_FIXED_NOREPLACE
-#define MAP_FIXED_NOREPLACE 0x100000
-#endif
-
 static void dump_maps(void)
 {
        char cmd[32];
index 312889edb84ab799ed6ef99b5d6b15cca57542ae..193281560b61be23d3b55857030ea07b4ad3f95d 100644 (file)
 #define LENGTH (256UL*1024*1024)
 #define PROTECTION (PROT_READ | PROT_WRITE)
 
-#ifndef MAP_HUGETLB
-#define MAP_HUGETLB 0x40000 /* arch specific */
-#endif
-
-#ifndef MAP_HUGE_SHIFT
-#define MAP_HUGE_SHIFT 26
-#endif
-
-#ifndef MAP_HUGE_MASK
-#define MAP_HUGE_MASK 0x3f
-#endif
-
 /* Only ia64 requires this */
 #ifdef __ia64__
 #define ADDR (void *)(0x8000000000000000UL)
index 6b8aeaa0bf7a5df1dfa850be55a521a1dedf901f..240f2d9dae7a99c9f74a0ebf4df6d27dd14fc3d8 100644 (file)
@@ -17,9 +17,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#ifndef MMAP_SZ
 #define MMAP_SZ                4096
-#endif
 
 #define BUG_ON(condition, description)                                 \
        do {                                                            \
index 782ea94dee2f2801578b169958653c4347994901..1fba77df7f628eee87d7aa3b82cb928d0d084077 100644 (file)
@@ -7,6 +7,7 @@
 #include <sys/resource.h>
 #include <sys/capability.h>
 #include <sys/mman.h>
+#include <linux/mman.h>
 #include <fcntl.h>
 #include <string.h>
 #include <sys/ipc.h>
index 2a6e76c226bc300d64097888066da46d503c23a8..8e02991b313c8e574a38dce9f12de9b616779a34 100644 (file)
@@ -4,14 +4,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#ifndef MLOCK_ONFAULT
-#define MLOCK_ONFAULT 1
-#endif
-
-#ifndef MCL_ONFAULT
-#define MCL_ONFAULT (MCL_FUTURE << 1)
-#endif
-
 static int mlock2_(void *start, size_t len, int flags)
 {
 #ifdef __NR_mlock2
index 37b6d33b9e8458cc213075a2b7355e4c41bceac6..dca21042b679271d4bcd5e8ec8cb16fb6c72ed11 100644 (file)
@@ -9,18 +9,10 @@
 #include <stdlib.h>
 #include <sys/wait.h>
 #include <unistd.h>
+#include <asm-generic/unistd.h>
 #include "vm_util.h"
-
 #include "../kselftest.h"
 
-#ifndef __NR_pidfd_open
-#define __NR_pidfd_open -1
-#endif
-
-#ifndef __NR_process_mrelease
-#define __NR_process_mrelease -1
-#endif
-
 #define MB(x) (x << 20)
 #define MAX_SIZE_MB 1024
 
index f01dc4a85b0bec0d2645b63dc0cf96fc0df5d0f7..ca2359835e751b69c9a4c280129d6ca6200a11e9 100644 (file)
 
 #include "../kselftest.h"
 
-#ifndef MREMAP_DONTUNMAP
-#define MREMAP_DONTUNMAP 4
-#endif
-
 unsigned long page_size;
 char *page_buffer;
 
index 634d87dfb2a4ef5b1722839315c9abd88a2008f6..b5888d613f34ebe7f98017016f7a9d753452cf45 100644 (file)
@@ -6,10 +6,6 @@
 #include <sys/time.h>
 #include <sys/resource.h>
 
-#ifndef MCL_ONFAULT
-#define MCL_ONFAULT (MCL_FUTURE << 1)
-#endif
-
 static int test_limit(void)
 {
        int ret = 1;
index 1ebb586b2fbc2b3ab988676cb06fcb806907c187..ae5df26104e5fdc0f4fa34073d590f28b5e47114 100644 (file)
@@ -3,9 +3,6 @@
 #ifndef _PKEYS_POWERPC_H
 #define _PKEYS_POWERPC_H
 
-#ifndef SYS_mprotect_key
-# define SYS_mprotect_key      386
-#endif
 #ifndef SYS_pkey_alloc
 # define SYS_pkey_alloc                384
 # define SYS_pkey_free         385
index e32ae8a1cd997d1d014096e8dc92a84f4e33bf38..814758e109c0ba69d3b7bfdc4e116acfc5facbee 100644 (file)
@@ -5,29 +5,11 @@
 
 #ifdef __i386__
 
-#ifndef SYS_mprotect_key
-# define SYS_mprotect_key      380
-#endif
-
-#ifndef SYS_pkey_alloc
-# define SYS_pkey_alloc                381
-# define SYS_pkey_free         382
-#endif
-
 #define REG_IP_IDX             REG_EIP
 #define si_pkey_offset         0x14
 
 #else
 
-#ifndef SYS_mprotect_key
-# define SYS_mprotect_key      329
-#endif
-
-#ifndef SYS_pkey_alloc
-# define SYS_pkey_alloc                330
-# define SYS_pkey_free         331
-#endif
-
 #define REG_IP_IDX             REG_RIP
 #define si_pkey_offset         0x20
 
index 0381c34fdd565aff0a338a4d22d71937d53f3558..48dc151f8fca8ab8a1ef300860cb59e0f491a2a8 100644 (file)
@@ -294,15 +294,6 @@ void pkey_access_deny(int pkey)
        pkey_disable_set(pkey, PKEY_DISABLE_ACCESS);
 }
 
-/* Failed address bound checks: */
-#ifndef SEGV_BNDERR
-# define SEGV_BNDERR           3
-#endif
-
-#ifndef SEGV_PKUERR
-# define SEGV_PKUERR           4
-#endif
-
 static char *si_code_str(int si_code)
 {
        if (si_code == SEGV_MAPERR)
@@ -476,7 +467,7 @@ int sys_mprotect_pkey(void *ptr, size_t size, unsigned long orig_prot,
                        ptr, size, orig_prot, pkey);
 
        errno = 0;
-       sret = syscall(SYS_mprotect_key, ptr, size, orig_prot, pkey);
+       sret = syscall(__NR_pkey_mprotect, ptr, size, orig_prot, pkey);
        if (errno) {
                dprintf2("SYS_mprotect_key sret: %d\n", sret);
                dprintf2("SYS_mprotect_key prot: 0x%lx\n", orig_prot);
@@ -1684,7 +1675,7 @@ void test_mprotect_pkey_on_unsupported_cpu(int *ptr, u16 pkey)
                return;
        }
 
-       sret = syscall(SYS_mprotect_key, ptr, size, PROT_READ, pkey);
+       sret = syscall(__NR_pkey_mprotect, ptr, size, PROT_READ, pkey);
        pkey_assert(sret < 0);
 }
 
index e57ace1323a79f136b1564a24fe99da5fb8629c0..c7fa61f0dff8d963b2ad5f92554b94691f6a17c5 100644 (file)
@@ -60,13 +60,3 @@ int uffd_register_with_ioctls(int uffd, void *addr, uint64_t len,
 
 #define PAGEMAP_PRESENT(ent)   (((ent) & (1ull << 63)) != 0)
 #define PAGEMAP_PFN(ent)       ((ent) & ((1ull << 55) - 1))
-
-#ifndef MADV_PAGEOUT
-#define MADV_PAGEOUT 21
-#endif
-#ifndef MADV_POPULATE_READ
-#define MADV_POPULATE_READ 22
-#endif
-#ifndef MADV_COLLAPSE
-#define MADV_COLLAPSE 25
-#endif