Lines Matching +full:cpu +full:- +full:nr

1 // SPDX-License-Identifier: GPL-2.0-only
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
37 #include "uffd-common.h"
58 "./uffd-stress anon 100 99999\n\n"
60 "./uffd-stress shmem 1000 99\n\n"
62 "./uffd-stress hugetlb 256 50\n\n"
64 "./uffd-stress hugetlb-private 256 50\n\n"
65 "# 10MiB-~6GiB 999 bounces anonymous test, "
67 "while ./uffd-stress anon $[RANDOM % 6000 + 10] 999; do true; done\n\n";
71 fprintf(stderr, "\nUsage: ./uffd-stress <test type> <MiB> <bounces>\n\n"); in usage()
73 "hugetlb-private, shmem, shmem-private\n\n"); in usage()
84 args[i].cpu = i; in uffd_stats_reset()
94 unsigned long cpu = (unsigned long) arg; in locking_thread() local
99 page_nr = -bounces; in locking_thread()
101 page_nr += cpu * nr_pages_per_cpu; in locking_thread()
150 unsigned long cpu = (unsigned long) arg; in background_thread() local
153 start_nr = cpu * nr_pages_per_cpu; in background_thread()
154 end_nr = (cpu+1) * nr_pages_per_cpu; in background_thread()
162 * If we need to test uffd-wp, set it up now. Then we'll have in background_thread()
164 * can be write-protected for testing in background_thread()
182 unsigned long cpu; in stress() local
188 for (cpu = 0; cpu < nr_cpus; cpu++) { in stress()
189 if (pthread_create(&locking_threads[cpu], &attr, in stress()
190 locking_thread, (void *)cpu)) in stress()
193 if (pthread_create(&uffd_threads[cpu], &attr, uffd_poll_thread, &args[cpu])) in stress()
196 if (pthread_create(&uffd_threads[cpu], &attr, in stress()
198 (void *)&args[cpu])) in stress()
202 if (pthread_create(&background_threads[cpu], &attr, in stress()
203 background_thread, (void *)cpu)) in stress()
206 for (cpu = 0; cpu < nr_cpus; cpu++) in stress()
207 if (pthread_join(background_threads[cpu], NULL)) in stress()
215 * area_src (but they're guaranteed to get -EEXIST from in stress()
219 uffd_test_ops->release_pages(area_src); in stress()
222 for (cpu = 0; cpu < nr_cpus; cpu++) in stress()
223 if (pthread_join(locking_threads[cpu], NULL)) in stress()
226 for (cpu = 0; cpu < nr_cpus; cpu++) { in stress()
229 if (write(pipefd[cpu*2+1], &c, 1) != 1) in stress()
231 if (pthread_join(uffd_threads[cpu], in stress()
232 (void *)&args[cpu])) in stress()
235 if (pthread_cancel(uffd_threads[cpu])) in stress()
237 if (pthread_join(uffd_threads[cpu], NULL)) in stress()
248 unsigned long nr; in userfaultfd_stress() local
271 while (bounces--) { in userfaultfd_stress()
310 * return -EEXIST). The problem comes at the next in userfaultfd_stress()
315 * area_src would lead to -EEXIST failure during the in userfaultfd_stress()
326 uffd_test_ops->release_pages(area_dst); in userfaultfd_stress()
351 for (nr = 0; nr < nr_pages; nr++) in userfaultfd_stress()
352 if (*area_count(area_dst, nr) != count_verify[nr]) in userfaultfd_stress()
354 *area_count(area_src, nr), in userfaultfd_stress()
355 count_verify[nr], nr); in userfaultfd_stress()
378 } else if (!strcmp(type, "hugetlb-private")) { in set_test_type()
385 } else if (!strcmp(type, "shmem-private")) { in set_test_type()
425 uffd = -1; in parse_test_type_arg()