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"
57 "./uffd-stress anon 100 99999\n\n"
59 "./uffd-stress shmem 1000 99\n\n"
61 "./uffd-stress hugetlb 256 50\n\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()
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()
247 unsigned long nr; in userfaultfd_stress() local
266 while (bounces--) { in userfaultfd_stress()
305 * return -EEXIST). The problem comes at the next in userfaultfd_stress()
310 * area_src would lead to -EEXIST failure during the in userfaultfd_stress()
321 uffd_test_ops->release_pages(area_dst); in userfaultfd_stress()
344 for (nr = 0; nr < nr_pages; nr++) in userfaultfd_stress()
345 if (*area_count(area_dst, nr) != count_verify[nr]) in userfaultfd_stress()
347 *area_count(area_src, nr), in userfaultfd_stress()
348 count_verify[nr], nr); in userfaultfd_stress()
370 } else if (!strcmp(type, "hugetlb-private")) { in set_test_type()
377 } else if (!strcmp(type, "shmem-private")) { in set_test_type()
416 uffd = -1; in parse_test_type_arg()