Skip to content

Commit a5c6bc5

Browse files
johnhubbardakpm00
authored andcommitted
selftests/mm: remove local __NR_* definitions
This continues the work on getting the selftests to build without requiring people to first run "make headers" [1]. Now that the system call numbers are in the correct, checked-in locations in the kernel tree (./tools/include/uapi/asm/unistd*.h), make sure that the mm selftests include that file (indirectly). Doing so provides guaranteed definitions at build time, so remove all of the checks for "ifdef __NR_xxx" in the mm selftests, because they will always be true (defined). [1] commit e076eac ("selftests: break the dependency upon local header files") Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: John Hubbard <[email protected]> Acked-by: David Hildenbrand <[email protected]> Cc: Jeff Xu <[email protected]> Cc: Andrei Vagin <[email protected]> Cc: Axel Rasmussen <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Kees Cook <[email protected]> Cc: Kent Overstreet <[email protected]> Cc: Liam R. Howlett <[email protected]> Cc: Muhammad Usama Anjum <[email protected]> Cc: Peter Xu <[email protected]> Cc: Rich Felker <[email protected]> Cc: Shuah Khan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent d40f74a commit a5c6bc5

File tree

10 files changed

+9
-62
lines changed

10 files changed

+9
-62
lines changed

tools/testing/selftests/mm/hugepage-mremap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#define _GNU_SOURCE
1616
#include <stdlib.h>
1717
#include <stdio.h>
18-
#include <unistd.h>
18+
#include <asm-generic/unistd.h>
1919
#include <sys/mman.h>
2020
#include <errno.h>
2121
#include <fcntl.h> /* Definition of O_* constants */

tools/testing/selftests/mm/ksm_functional_tests.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <string.h>
1212
#include <stdbool.h>
1313
#include <stdint.h>
14-
#include <unistd.h>
14+
#include <asm-generic/unistd.h>
1515
#include <errno.h>
1616
#include <fcntl.h>
1717
#include <sys/mman.h>
@@ -369,7 +369,6 @@ static void test_unmerge_discarded(void)
369369
munmap(map, size);
370370
}
371371

372-
#ifdef __NR_userfaultfd
373372
static void test_unmerge_uffd_wp(void)
374373
{
375374
struct uffdio_writeprotect uffd_writeprotect;
@@ -430,7 +429,6 @@ static void test_unmerge_uffd_wp(void)
430429
unmap:
431430
munmap(map, size);
432431
}
433-
#endif
434432

435433
/* Verify that KSM can be enabled / queried with prctl. */
436434
static void test_prctl(void)
@@ -686,9 +684,7 @@ int main(int argc, char **argv)
686684
exit(test_child_ksm());
687685
}
688686

689-
#ifdef __NR_userfaultfd
690687
tests++;
691-
#endif
692688

693689
ksft_print_header();
694690
ksft_set_plan(tests);
@@ -700,9 +696,7 @@ int main(int argc, char **argv)
700696
test_unmerge();
701697
test_unmerge_zero_pages();
702698
test_unmerge_discarded();
703-
#ifdef __NR_userfaultfd
704699
test_unmerge_uffd_wp();
705-
#endif
706700

707701
test_prot_none();
708702

tools/testing/selftests/mm/memfd_secret.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include <stdlib.h>
1919
#include <string.h>
20-
#include <unistd.h>
20+
#include <asm-generic/unistd.h>
2121
#include <errno.h>
2222
#include <stdio.h>
2323
#include <fcntl.h>
@@ -28,8 +28,6 @@
2828
#define pass(fmt, ...) ksft_test_result_pass(fmt, ##__VA_ARGS__)
2929
#define skip(fmt, ...) ksft_test_result_skip(fmt, ##__VA_ARGS__)
3030

31-
#ifdef __NR_memfd_secret
32-
3331
#define PATTERN 0x55
3432

3533
static const int prot = PROT_READ | PROT_WRITE;
@@ -334,13 +332,3 @@ int main(int argc, char *argv[])
334332

335333
ksft_finished();
336334
}
337-
338-
#else /* __NR_memfd_secret */
339-
340-
int main(int argc, char *argv[])
341-
{
342-
printf("skip: skipping memfd_secret test (missing __NR_memfd_secret)\n");
343-
return KSFT_SKIP;
344-
}
345-
346-
#endif /* __NR_memfd_secret */

tools/testing/selftests/mm/mkdirty.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
#include <fcntl.h>
1111
#include <signal.h>
12-
#include <unistd.h>
12+
#include <asm-generic/unistd.h>
1313
#include <string.h>
1414
#include <errno.h>
1515
#include <stdlib.h>
@@ -265,7 +265,6 @@ static void test_pte_mapped_thp(void)
265265
munmap(mmap_mem, mmap_size);
266266
}
267267

268-
#ifdef __NR_userfaultfd
269268
static void test_uffdio_copy(void)
270269
{
271270
struct uffdio_register uffdio_register;
@@ -322,7 +321,6 @@ static void test_uffdio_copy(void)
322321
munmap(dst, pagesize);
323322
free(src);
324323
}
325-
#endif /* __NR_userfaultfd */
326324

327325
int main(void)
328326
{
@@ -335,9 +333,7 @@ int main(void)
335333
thpsize / 1024);
336334
tests += 3;
337335
}
338-
#ifdef __NR_userfaultfd
339336
tests += 1;
340-
#endif /* __NR_userfaultfd */
341337

342338
ksft_print_header();
343339
ksft_set_plan(tests);
@@ -367,9 +363,7 @@ int main(void)
367363
if (thpsize)
368364
test_pte_mapped_thp();
369365
/* Placing a fresh page via userfaultfd may set the PTE dirty. */
370-
#ifdef __NR_userfaultfd
371366
test_uffdio_copy();
372-
#endif /* __NR_userfaultfd */
373367

374368
err = ksft_get_fail_cnt();
375369
if (err)

tools/testing/selftests/mm/mlock2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <errno.h>
44
#include <stdio.h>
55
#include <stdlib.h>
6+
#include <asm-generic/unistd.h>
67

78
static int mlock2_(void *start, size_t len, int flags)
89
{

tools/testing/selftests/mm/pagemap_ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <sys/ioctl.h>
1616
#include <sys/stat.h>
1717
#include <math.h>
18-
#include <asm/unistd.h>
18+
#include <asm-generic/unistd.h>
1919
#include <pthread.h>
2020
#include <sys/resource.h>
2121
#include <assert.h>

tools/testing/selftests/mm/protection_keys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#include <sys/wait.h>
4343
#include <sys/stat.h>
4444
#include <fcntl.h>
45-
#include <unistd.h>
45+
#include <asm-generic/unistd.h>
4646
#include <sys/ptrace.h>
4747
#include <setjmp.h>
4848

tools/testing/selftests/mm/uffd-common.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,11 +673,7 @@ int uffd_open_dev(unsigned int flags)
673673

674674
int uffd_open_sys(unsigned int flags)
675675
{
676-
#ifdef __NR_userfaultfd
677676
return syscall(__NR_userfaultfd, flags);
678-
#else
679-
return -1;
680-
#endif
681677
}
682678

683679
int uffd_open(unsigned int flags)

tools/testing/selftests/mm/uffd-stress.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@
3333
* pthread_mutex_lock will also verify the atomicity of the memory
3434
* transfer (UFFDIO_COPY).
3535
*/
36-
36+
#include <asm-generic/unistd.h>
3737
#include "uffd-common.h"
3838

39-
#ifdef __NR_userfaultfd
40-
4139
#define BOUNCE_RANDOM (1<<0)
4240
#define BOUNCE_RACINGFAULTS (1<<1)
4341
#define BOUNCE_VERIFY (1<<2)
@@ -466,15 +464,3 @@ int main(int argc, char **argv)
466464
nr_pages, nr_pages_per_cpu);
467465
return userfaultfd_stress();
468466
}
469-
470-
#else /* __NR_userfaultfd */
471-
472-
#warning "missing __NR_userfaultfd definition"
473-
474-
int main(void)
475-
{
476-
printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n");
477-
return KSFT_SKIP;
478-
}
479-
480-
#endif /* __NR_userfaultfd */

tools/testing/selftests/mm/uffd-unit-tests.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
* Copyright (C) 2015-2023 Red Hat, Inc.
66
*/
77

8+
#include <asm-generic/unistd.h>
89
#include "uffd-common.h"
910

1011
#include "../../../../mm/gup_test.h"
1112

12-
#ifdef __NR_userfaultfd
13-
1413
/* The unit test doesn't need a large or random size, make it 32MB for now */
1514
#define UFFD_TEST_MEM_SIZE (32UL << 20)
1615

@@ -1554,14 +1553,3 @@ int main(int argc, char *argv[])
15541553
return ksft_get_fail_cnt() ? KSFT_FAIL : KSFT_PASS;
15551554
}
15561555

1557-
#else /* __NR_userfaultfd */
1558-
1559-
#warning "missing __NR_userfaultfd definition"
1560-
1561-
int main(void)
1562-
{
1563-
printf("Skipping %s (missing __NR_userfaultfd)\n", __file__);
1564-
return KSFT_SKIP;
1565-
}
1566-
1567-
#endif /* __NR_userfaultfd */

0 commit comments

Comments
 (0)