Skip to content

Commit

Permalink
selftests: mm: remove duplicate unneeded defines
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Muhammad Usama Anjum authored and Andrew Morton committed Jun 19, 2023
1 parent 1e6d1e3 commit 0183d77
Show file tree
Hide file tree
Showing 17 changed files with 6 additions and 100 deletions.
1 change: 1 addition & 0 deletions tools/testing/selftests/mm/cow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 0 additions & 4 deletions tools/testing/selftests/mm/hugepage-shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
#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)
Expand Down
4 changes: 0 additions & 4 deletions tools/testing/selftests/mm/hugepage-vmemmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@

#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)
Expand Down
1 change: 1 addition & 0 deletions tools/testing/selftests/mm/khugepaged.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
7 changes: 0 additions & 7 deletions tools/testing/selftests/mm/madv_populate.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
#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.
*/
Expand Down
4 changes: 0 additions & 4 deletions tools/testing/selftests/mm/map_fixed_noreplace.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
#include <stdlib.h>
#include <unistd.h>

#ifndef MAP_FIXED_NOREPLACE
#define MAP_FIXED_NOREPLACE 0x100000
#endif

static void dump_maps(void)
{
char cmd[32];
Expand Down
12 changes: 0 additions & 12 deletions tools/testing/selftests/mm/map_hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,6 @@
#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)
Expand Down
2 changes: 0 additions & 2 deletions tools/testing/selftests/mm/map_populate.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
#include <string.h>
#include <unistd.h>

#ifndef MMAP_SZ
#define MMAP_SZ 4096
#endif

#define BUG_ON(condition, description) \
do { \
Expand Down
1 change: 1 addition & 0 deletions tools/testing/selftests/mm/mlock-random-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
8 changes: 0 additions & 8 deletions tools/testing/selftests/mm/mlock2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 1 addition & 9 deletions tools/testing/selftests/mm/mrelease_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 0 additions & 4 deletions tools/testing/selftests/mm/mremap_dontunmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@

#include "../kselftest.h"

#ifndef MREMAP_DONTUNMAP
#define MREMAP_DONTUNMAP 4
#endif

unsigned long page_size;
char *page_buffer;

Expand Down
4 changes: 0 additions & 4 deletions tools/testing/selftests/mm/on-fault-limit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions tools/testing/selftests/mm/pkey-powerpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 0 additions & 18 deletions tools/testing/selftests/mm/pkey-x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 2 additions & 11 deletions tools/testing/selftests/mm/protection_keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down
10 changes: 0 additions & 10 deletions tools/testing/selftests/mm/vm_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0183d77

Please sign in to comment.