diff options
author | Ingo Molnar <mingo@kernel.org> | 2015-10-07 05:24:24 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-10-07 05:24:24 -0400 |
commit | 25a9a924c0c8723ced99179eb639e8c5372a2557 (patch) | |
tree | 83170168d50b9703486327b5b3a0bfb1d8da9b2b /tools/testing | |
parent | 0b101e62afe626ecae60173f92f1e0ec72151653 (diff) | |
parent | a0eeb8dd34f21fddfe85b37832b5f3d02ee6e34b (diff) |
Merge branch 'linus' into x86/asm, to pick up fixes before applying new changes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/testing')
-rw-r--r-- | tools/testing/selftests/membarrier/Makefile | 7 | ||||
-rw-r--r-- | tools/testing/selftests/membarrier/membarrier_test.c | 5 | ||||
-rw-r--r-- | tools/testing/selftests/vm/Makefile | 9 | ||||
-rw-r--r-- | tools/testing/selftests/vm/userfaultfd.c | 54 |
4 files changed, 39 insertions, 36 deletions
diff --git a/tools/testing/selftests/membarrier/Makefile b/tools/testing/selftests/membarrier/Makefile index 877a50355d7f..a1a97085847d 100644 --- a/tools/testing/selftests/membarrier/Makefile +++ b/tools/testing/selftests/membarrier/Makefile | |||
@@ -1,11 +1,10 @@ | |||
1 | CFLAGS += -g -I../../../../usr/include/ | 1 | CFLAGS += -g -I../../../../usr/include/ |
2 | 2 | ||
3 | all: | ||
4 | $(CC) $(CFLAGS) membarrier_test.c -o membarrier_test | ||
5 | |||
6 | TEST_PROGS := membarrier_test | 3 | TEST_PROGS := membarrier_test |
7 | 4 | ||
5 | all: $(TEST_PROGS) | ||
6 | |||
8 | include ../lib.mk | 7 | include ../lib.mk |
9 | 8 | ||
10 | clean: | 9 | clean: |
11 | $(RM) membarrier_test | 10 | $(RM) $(TEST_PROGS) |
diff --git a/tools/testing/selftests/membarrier/membarrier_test.c b/tools/testing/selftests/membarrier/membarrier_test.c index dde312508007..535f0fef4d0b 100644 --- a/tools/testing/selftests/membarrier/membarrier_test.c +++ b/tools/testing/selftests/membarrier/membarrier_test.c | |||
@@ -1,9 +1,6 @@ | |||
1 | #define _GNU_SOURCE | 1 | #define _GNU_SOURCE |
2 | #define __EXPORTED_HEADERS__ | ||
3 | |||
4 | #include <linux/membarrier.h> | 2 | #include <linux/membarrier.h> |
5 | #include <asm-generic/unistd.h> | 3 | #include <syscall.h> |
6 | #include <sys/syscall.h> | ||
7 | #include <stdio.h> | 4 | #include <stdio.h> |
8 | #include <errno.h> | 5 | #include <errno.h> |
9 | #include <string.h> | 6 | #include <string.h> |
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index d36fab7d8ebd..3c53cac15de1 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile | |||
@@ -1,6 +1,6 @@ | |||
1 | # Makefile for vm selftests | 1 | # Makefile for vm selftests |
2 | 2 | ||
3 | CFLAGS = -Wall | 3 | CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) |
4 | BINARIES = compaction_test | 4 | BINARIES = compaction_test |
5 | BINARIES += hugepage-mmap | 5 | BINARIES += hugepage-mmap |
6 | BINARIES += hugepage-shm | 6 | BINARIES += hugepage-shm |
@@ -12,8 +12,11 @@ BINARIES += userfaultfd | |||
12 | all: $(BINARIES) | 12 | all: $(BINARIES) |
13 | %: %.c | 13 | %: %.c |
14 | $(CC) $(CFLAGS) -o $@ $^ -lrt | 14 | $(CC) $(CFLAGS) -o $@ $^ -lrt |
15 | userfaultfd: userfaultfd.c | 15 | userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h |
16 | $(CC) $(CFLAGS) -O2 -o $@ $^ -lpthread | 16 | $(CC) $(CFLAGS) -O2 -o $@ $< -lpthread |
17 | |||
18 | ../../../../usr/include/linux/kernel.h: | ||
19 | make -C ../../../.. headers_install | ||
17 | 20 | ||
18 | TEST_PROGS := run_vmtests | 21 | TEST_PROGS := run_vmtests |
19 | TEST_FILES := $(BINARIES) | 22 | TEST_FILES := $(BINARIES) |
diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 7c1d958857d2..d77ed41b2094 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c | |||
@@ -64,19 +64,9 @@ | |||
64 | #include <sys/syscall.h> | 64 | #include <sys/syscall.h> |
65 | #include <sys/ioctl.h> | 65 | #include <sys/ioctl.h> |
66 | #include <pthread.h> | 66 | #include <pthread.h> |
67 | #include "../../../../include/uapi/linux/userfaultfd.h" | 67 | #include <linux/userfaultfd.h> |
68 | 68 | ||
69 | #ifdef __x86_64__ | 69 | #ifdef __NR_userfaultfd |
70 | #define __NR_userfaultfd 323 | ||
71 | #elif defined(__i386__) | ||
72 | #define __NR_userfaultfd 374 | ||
73 | #elif defined(__powewrpc__) | ||
74 | #define __NR_userfaultfd 364 | ||
75 | #elif defined(__s390__) | ||
76 | #define __NR_userfaultfd 355 | ||
77 | #else | ||
78 | #error "missing __NR_userfaultfd definition" | ||
79 | #endif | ||
80 | 70 | ||
81 | static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size; | 71 | static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size; |
82 | 72 | ||
@@ -432,7 +422,7 @@ static int userfaultfd_stress(void) | |||
432 | struct uffdio_register uffdio_register; | 422 | struct uffdio_register uffdio_register; |
433 | struct uffdio_api uffdio_api; | 423 | struct uffdio_api uffdio_api; |
434 | unsigned long cpu; | 424 | unsigned long cpu; |
435 | int uffd_flags; | 425 | int uffd_flags, err; |
436 | unsigned long userfaults[nr_cpus]; | 426 | unsigned long userfaults[nr_cpus]; |
437 | 427 | ||
438 | if (posix_memalign(&area, page_size, nr_pages * page_size)) { | 428 | if (posix_memalign(&area, page_size, nr_pages * page_size)) { |
@@ -475,6 +465,14 @@ static int userfaultfd_stress(void) | |||
475 | *area_mutex(area_src, nr) = (pthread_mutex_t) | 465 | *area_mutex(area_src, nr) = (pthread_mutex_t) |
476 | PTHREAD_MUTEX_INITIALIZER; | 466 | PTHREAD_MUTEX_INITIALIZER; |
477 | count_verify[nr] = *area_count(area_src, nr) = 1; | 467 | count_verify[nr] = *area_count(area_src, nr) = 1; |
468 | /* | ||
469 | * In the transition between 255 to 256, powerpc will | ||
470 | * read out of order in my_bcmp and see both bytes as | ||
471 | * zero, so leave a placeholder below always non-zero | ||
472 | * after the count, to avoid my_bcmp to trigger false | ||
473 | * positives. | ||
474 | */ | ||
475 | *(area_count(area_src, nr) + 1) = 1; | ||
478 | } | 476 | } |
479 | 477 | ||
480 | pipefd = malloc(sizeof(int) * nr_cpus * 2); | 478 | pipefd = malloc(sizeof(int) * nr_cpus * 2); |
@@ -501,6 +499,7 @@ static int userfaultfd_stress(void) | |||
501 | pthread_attr_init(&attr); | 499 | pthread_attr_init(&attr); |
502 | pthread_attr_setstacksize(&attr, 16*1024*1024); | 500 | pthread_attr_setstacksize(&attr, 16*1024*1024); |
503 | 501 | ||
502 | err = 0; | ||
504 | while (bounces--) { | 503 | while (bounces--) { |
505 | unsigned long expected_ioctls; | 504 | unsigned long expected_ioctls; |
506 | 505 | ||
@@ -581,20 +580,13 @@ static int userfaultfd_stress(void) | |||
581 | /* verification */ | 580 | /* verification */ |
582 | if (bounces & BOUNCE_VERIFY) { | 581 | if (bounces & BOUNCE_VERIFY) { |
583 | for (nr = 0; nr < nr_pages; nr++) { | 582 | for (nr = 0; nr < nr_pages; nr++) { |
584 | if (my_bcmp(area_dst, | ||
585 | area_dst + nr * page_size, | ||
586 | sizeof(pthread_mutex_t))) { | ||
587 | fprintf(stderr, | ||
588 | "error mutex 2 %lu\n", | ||
589 | nr); | ||
590 | bounces = 0; | ||
591 | } | ||
592 | if (*area_count(area_dst, nr) != count_verify[nr]) { | 583 | if (*area_count(area_dst, nr) != count_verify[nr]) { |
593 | fprintf(stderr, | 584 | fprintf(stderr, |
594 | "error area_count %Lu %Lu %lu\n", | 585 | "error area_count %Lu %Lu %lu\n", |
595 | *area_count(area_src, nr), | 586 | *area_count(area_src, nr), |
596 | count_verify[nr], | 587 | count_verify[nr], |
597 | nr); | 588 | nr); |
589 | err = 1; | ||
598 | bounces = 0; | 590 | bounces = 0; |
599 | } | 591 | } |
600 | } | 592 | } |
@@ -611,7 +603,7 @@ static int userfaultfd_stress(void) | |||
611 | printf("\n"); | 603 | printf("\n"); |
612 | } | 604 | } |
613 | 605 | ||
614 | return 0; | 606 | return err; |
615 | } | 607 | } |
616 | 608 | ||
617 | int main(int argc, char **argv) | 609 | int main(int argc, char **argv) |
@@ -620,8 +612,8 @@ int main(int argc, char **argv) | |||
620 | fprintf(stderr, "Usage: <MiB> <bounces>\n"), exit(1); | 612 | fprintf(stderr, "Usage: <MiB> <bounces>\n"), exit(1); |
621 | nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); | 613 | nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); |
622 | page_size = sysconf(_SC_PAGE_SIZE); | 614 | page_size = sysconf(_SC_PAGE_SIZE); |
623 | if ((unsigned long) area_count(NULL, 0) + sizeof(unsigned long long) > | 615 | if ((unsigned long) area_count(NULL, 0) + sizeof(unsigned long long) * 2 |
624 | page_size) | 616 | > page_size) |
625 | fprintf(stderr, "Impossible to run this test\n"), exit(2); | 617 | fprintf(stderr, "Impossible to run this test\n"), exit(2); |
626 | nr_pages_per_cpu = atol(argv[1]) * 1024*1024 / page_size / | 618 | nr_pages_per_cpu = atol(argv[1]) * 1024*1024 / page_size / |
627 | nr_cpus; | 619 | nr_cpus; |
@@ -639,3 +631,15 @@ int main(int argc, char **argv) | |||
639 | nr_pages, nr_pages_per_cpu); | 631 | nr_pages, nr_pages_per_cpu); |
640 | return userfaultfd_stress(); | 632 | return userfaultfd_stress(); |
641 | } | 633 | } |
634 | |||
635 | #else /* __NR_userfaultfd */ | ||
636 | |||
637 | #warning "missing __NR_userfaultfd definition" | ||
638 | |||
639 | int main(void) | ||
640 | { | ||
641 | printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n"); | ||
642 | return 0; | ||
643 | } | ||
644 | |||
645 | #endif /* __NR_userfaultfd */ | ||