Lines Matching +full:test +full:- +full:cpu

1 // SPDX-License-Identifier: GPL-2.0-only
7 * This test allocates two virtual areas and bounces the physical
11 * There are three threads running per CPU:
13 * 1) one per-CPU thread takes a per-page pthread_mutex in a random
15 * area_src), and increments a per-page counter in the same page,
18 * 2) another per-CPU thread handles the userfaults generated by
22 * 3) one last per-CPU thread transfers the memory in the background
24 * 2). Each cpu thread takes cares of transferring a portion of the
32 * per-CPU threads 1 by triggering userfaults inside
36 #include <asm-generic/unistd.h>
37 #include "uffd-common.h"
56 "# Run anonymous memory test on 100MiB region with 99999 bounces:\n"
57 "./uffd-stress anon 100 99999\n\n"
58 "# Run share memory test on 1GiB region with 99 bounces:\n"
59 "./uffd-stress shmem 1000 99\n\n"
60 "# Run hugetlb memory test on 256MiB region with 50 bounces:\n"
61 "./uffd-stress hugetlb 256 50\n\n"
62 "# Run the same hugetlb test but using private file:\n"
63 "./uffd-stress hugetlb-private 256 50\n\n"
64 "# 10MiB-~6GiB 999 bounces anonymous test, "
66 "while ./uffd-stress anon $[RANDOM % 6000 + 10] 999; do true; done\n\n";
70 fprintf(stderr, "\nUsage: ./uffd-stress <test type> <MiB> <bounces>\n\n"); in usage()
71 fprintf(stderr, "Supported <test type>: anon, hugetlb, " in usage()
72 "hugetlb-private, shmem, shmem-private\n\n"); in usage()
83 args[i].cpu = i; in uffd_stats_reset()
93 unsigned long cpu = (unsigned long) arg; in locking_thread() local
98 page_nr = -bounces; in locking_thread()
100 page_nr += cpu * nr_pages_per_cpu; in locking_thread()
149 unsigned long cpu = (unsigned long) arg; in background_thread() local
152 start_nr = cpu * nr_pages_per_cpu; in background_thread()
153 end_nr = (cpu+1) * nr_pages_per_cpu; in background_thread()
161 * If we need to test uffd-wp, set it up now. Then we'll have in background_thread()
163 * can be write-protected for testing in background_thread()
181 unsigned long cpu; in stress() local
187 for (cpu = 0; cpu < nr_cpus; cpu++) { in stress()
188 if (pthread_create(&locking_threads[cpu], &attr, in stress()
189 locking_thread, (void *)cpu)) in stress()
192 if (pthread_create(&uffd_threads[cpu], &attr, uffd_poll_thread, &args[cpu])) in stress()
195 if (pthread_create(&uffd_threads[cpu], &attr, in stress()
197 (void *)&args[cpu])) in stress()
201 if (pthread_create(&background_threads[cpu], &attr, in stress()
202 background_thread, (void *)cpu)) in stress()
205 for (cpu = 0; cpu < nr_cpus; cpu++) in stress()
206 if (pthread_join(background_threads[cpu], NULL)) in stress()
214 * area_src (but they're guaranteed to get -EEXIST from in stress()
218 uffd_test_ops->release_pages(area_src); in stress()
221 for (cpu = 0; cpu < nr_cpus; cpu++) in stress()
222 if (pthread_join(locking_threads[cpu], NULL)) in stress()
225 for (cpu = 0; cpu < nr_cpus; cpu++) { in stress()
228 if (write(pipefd[cpu*2+1], &c, 1) != 1) in stress()
230 if (pthread_join(uffd_threads[cpu], in stress()
231 (void *)&args[cpu])) in stress()
234 if (pthread_cancel(uffd_threads[cpu])) in stress()
236 if (pthread_join(uffd_threads[cpu], NULL)) in stress()
270 while (bounces--) { in userfaultfd_stress()
309 * return -EEXIST). The problem comes at the next in userfaultfd_stress()
314 * area_src would lead to -EEXIST failure during the in userfaultfd_stress()
325 uffd_test_ops->release_pages(area_dst); in userfaultfd_stress()
377 } else if (!strcmp(type, "hugetlb-private")) { in set_test_type()
384 } else if (!strcmp(type, "shmem-private")) { in set_test_type()
395 err("failed to parse test type argument: '%s'", raw_type); in parse_test_type_arg()
406 err("Impossible to run this test"); in parse_test_type_arg()
409 * Whether we can test certain features depends not just on test type, in parse_test_type_arg()
424 uffd = -1; in parse_test_type_arg()