From nobody Tue Dec 16 19:43:00 2025 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCED71C8636 for ; Tue, 11 Mar 2025 13:18:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741699109; cv=none; b=rdoF/GFS7KJ7Bf+eTmG928uhGIXiio3V3mQjCsqzPkv2RCe8D779zJ+TZX8HkpYoRt+3b67GMa3q5v6MQ9uK1EYLQaLvBhrdxI4LmidWYuaVwTpa4cAyTOx0I1VY3gWFczWfv7FDPBBb+2fX1JND3qgsVlKxythqnCJ/Omg+8fo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741699109; c=relaxed/simple; bh=7cu9Mo5jePwqRqrQo8QLwmI2cqs8fPM09Kmi4kZUvjs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=jnY9dH5T723J9ody4uWdYv8uk2q+rwn7XlFXQBfMaSA/TJClCoKNhlslTrMjONLbK4QTZ/Nkxtm/iGjjOaz6D8nmmoJOP2RCz0SYpqSFOKNoSs0HX1v/Qccz8RNa+S47vBq4ay26drNdl5BK0jCp3VfjeTXsuV1dEsh8TQRivww= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=n7rBrxT2; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="n7rBrxT2" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-43d01024089so11529915e9.1 for ; Tue, 11 Mar 2025 06:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741699106; x=1742303906; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=5QUtJ68S5WVMBdPVxDoGekz8XvAVXh0h8UUq5TqoFAw=; b=n7rBrxT2Yk8Ff/HuAbhiwpQDQKDuYlr7cRXL7aJjI61NU3ZU734PgVzJSawdaxQRdJ blvMsdcYwwUzdtosHTMe9ywU+Tcsk/mlYq/n6/4lO1TeY8FvOyXLKhBGZKQpnqflEf6s slXmCM1byGNUDvZYm0opb8lh2Bl/uUzlDrcuMWdicbJKNTMzKc/ZhSbc5zU5lwuwBcDN d+OrCMqqVz18FN/MfKZgQFX+CEwcyEIyiKkgldDSXLMa6hv8y6fzLArN1VwqAthWLdbX Yd32i2kq50JBSvAz92bF3U8u/dW66B9uA2cNqSR8Z63OA9WDpAcNG2uPv5F5rH0EAao+ HCWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741699106; x=1742303906; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5QUtJ68S5WVMBdPVxDoGekz8XvAVXh0h8UUq5TqoFAw=; b=upSiTVU2tvnX9KwJ+yfqub7XfI1t1oXmYCpH0CJPVNiyGTgyFFdQledJEnIbEKNNNr xiK+6Uh+w3UsHeGg28+ilvtHBG2CueM4bBVxWaJajMkOXaZW3//8M7R8L+7Qpp+t3FD5 TZxKBoNjyz2zwJLg6Qidwgi7WWd3AYV8rAQyutOGUWsvhKb8CdYVztw7hR7Emt3G3rMf mM/PNGp4YZwUaYR/drDoP48+23ASTDtWNqTvPqomV3by2SagtT4uwnvsp13CkTRN7fHZ GM4TZ/FDPVcSscpSTjfdkhfLb/pc7c1CZmj3NUf+xTEJKGl82kNOTMXQbmmru0ZmI0dm VR9g== X-Forwarded-Encrypted: i=1; AJvYcCX/Ua8n3pioRKDgQZr+Fp0DOz1PD8KaPYZR9AqCrjORm6rm4Kp3I9UytF0C5g3JXjq7YXTBqMMRxPTyvBg=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7+x/0Np1ImqxBjVGp7h+F6xjw0g/qlFGV67GBFAQ2N5vslukb /ZyVTtIeF397HJeV6EzHN95qaVzB2ayYY5HRKompQB781DJSaSeJHkxqwtcWD2NOJPZsXgsFYYT DhmSub7sBxg== X-Google-Smtp-Source: AGHT+IHToyTOs3PPNxoBJUiCtaIlgO3ErHmKsYxSiQO/bRF9eUGsPTje1OCUomarBDaBQGTLwh5n+zuKNOR9zw== X-Received: from wmbet7.prod.google.com ([2002:a05:600c:8187:b0:43c:fad4:7595]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:3554:b0:43c:fffc:787b with SMTP id 5b1f17b1804b1-43cfffc7b0fmr77724175e9.12.1741699106174; Tue, 11 Mar 2025 06:18:26 -0700 (PDT) Date: Tue, 11 Mar 2025 13:18:15 +0000 In-Reply-To: <20250311-mm-selftests-v4-0-dec210a658f5@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250311-mm-selftests-v4-0-dec210a658f5@google.com> X-Mailer: b4 0.14.2 Message-ID: <20250311-mm-selftests-v4-4-dec210a658f5@google.com> Subject: [PATCH v4 04/12] selftests/mm/uffd: Rename nr_cpus -> nr_parallel From: Brendan Jackman To: Lorenzo Stoakes , Andrew Morton , Shuah Khan Cc: Dev Jain , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Brendan Jackman Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable A later commit will bound this variable so it no longer necessarily matches the number of CPUs. Rename it appropriately. Reviewed-by: Dev Jain Signed-off-by: Brendan Jackman --- tools/testing/selftests/mm/uffd-common.c | 8 ++++---- tools/testing/selftests/mm/uffd-common.h | 2 +- tools/testing/selftests/mm/uffd-stress.c | 28 ++++++++++++++----------= ---- tools/testing/selftests/mm/uffd-unit-tests.c | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/mm/uffd-common.c b/tools/testing/selft= ests/mm/uffd-common.c index 7ad6ba660c7d6f1f5762d0b231b92b05e971a3c5..dd01d2c95175b0329a75e220d2f= 43c915261090c 100644 --- a/tools/testing/selftests/mm/uffd-common.c +++ b/tools/testing/selftests/mm/uffd-common.c @@ -10,7 +10,7 @@ #define BASE_PMD_ADDR ((void *)(1UL << 30)) =20 volatile bool test_uffdio_copy_eexist =3D true; -unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size; +unsigned long nr_parallel, nr_pages, nr_pages_per_cpu, page_size; char *area_src, *area_src_alias, *area_dst, *area_dst_alias, *area_remap; int uffd =3D -1, uffd_flags, finished, *pipefd, test_type; bool map_shared; @@ -269,7 +269,7 @@ void uffd_test_ctx_clear(void) size_t i; =20 if (pipefd) { - for (i =3D 0; i < nr_cpus * 2; ++i) { + for (i =3D 0; i < nr_parallel * 2; ++i) { if (close(pipefd[i])) err("close pipefd"); } @@ -365,10 +365,10 @@ int uffd_test_ctx_init(uint64_t features, const char = **errmsg) */ uffd_test_ops->release_pages(area_dst); =20 - pipefd =3D malloc(sizeof(int) * nr_cpus * 2); + pipefd =3D malloc(sizeof(int) * nr_parallel * 2); if (!pipefd) err("pipefd"); - for (cpu =3D 0; cpu < nr_cpus; cpu++) + for (cpu =3D 0; cpu < nr_parallel; cpu++) if (pipe2(&pipefd[cpu * 2], O_CLOEXEC | O_NONBLOCK)) err("pipe"); =20 diff --git a/tools/testing/selftests/mm/uffd-common.h b/tools/testing/selft= ests/mm/uffd-common.h index a70ae10b5f6206daecc8e19ed3e3bbb388e265aa..7700cbfa397563d2f2bc82be45f= 96f2fc2032bbe 100644 --- a/tools/testing/selftests/mm/uffd-common.h +++ b/tools/testing/selftests/mm/uffd-common.h @@ -98,7 +98,7 @@ struct uffd_test_case_ops { }; typedef struct uffd_test_case_ops uffd_test_case_ops_t; =20 -extern unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size; +extern unsigned long nr_parallel, nr_pages, nr_pages_per_cpu, page_size; extern char *area_src, *area_src_alias, *area_dst, *area_dst_alias, *area_= remap; extern int uffd, uffd_flags, finished, *pipefd, test_type; extern bool map_shared; diff --git a/tools/testing/selftests/mm/uffd-stress.c b/tools/testing/selft= ests/mm/uffd-stress.c index 91174e9425cde2500b459db78cb27adda6647b55..d6b57e5a2e1d7611aa1588ee416= 01ce16117a574 100644 --- a/tools/testing/selftests/mm/uffd-stress.c +++ b/tools/testing/selftests/mm/uffd-stress.c @@ -180,12 +180,12 @@ static void *background_thread(void *arg) static int stress(struct uffd_args *args) { unsigned long cpu; - pthread_t locking_threads[nr_cpus]; - pthread_t uffd_threads[nr_cpus]; - pthread_t background_threads[nr_cpus]; + pthread_t locking_threads[nr_parallel]; + pthread_t uffd_threads[nr_parallel]; + pthread_t background_threads[nr_parallel]; =20 finished =3D 0; - for (cpu =3D 0; cpu < nr_cpus; cpu++) { + for (cpu =3D 0; cpu < nr_parallel; cpu++) { if (pthread_create(&locking_threads[cpu], &attr, locking_thread, (void *)cpu)) return 1; @@ -203,7 +203,7 @@ static int stress(struct uffd_args *args) background_thread, (void *)cpu)) return 1; } - for (cpu =3D 0; cpu < nr_cpus; cpu++) + for (cpu =3D 0; cpu < nr_parallel; cpu++) if (pthread_join(background_threads[cpu], NULL)) return 1; =20 @@ -219,11 +219,11 @@ static int stress(struct uffd_args *args) uffd_test_ops->release_pages(area_src); =20 finished =3D 1; - for (cpu =3D 0; cpu < nr_cpus; cpu++) + for (cpu =3D 0; cpu < nr_parallel; cpu++) if (pthread_join(locking_threads[cpu], NULL)) return 1; =20 - for (cpu =3D 0; cpu < nr_cpus; cpu++) { + for (cpu =3D 0; cpu < nr_parallel; cpu++) { char c; if (bounces & BOUNCE_POLL) { if (write(pipefd[cpu*2+1], &c, 1) !=3D 1) @@ -246,11 +246,11 @@ static int userfaultfd_stress(void) { void *area; unsigned long nr; - struct uffd_args args[nr_cpus]; + struct uffd_args args[nr_parallel]; uint64_t mem_size =3D nr_pages * page_size; int flags =3D 0; =20 - memset(args, 0, sizeof(struct uffd_args) * nr_cpus); + memset(args, 0, sizeof(struct uffd_args) * nr_parallel); =20 if (features & UFFD_FEATURE_WP_UNPOPULATED && test_type =3D=3D TEST_ANON) flags =3D UFFD_FEATURE_WP_UNPOPULATED; @@ -325,7 +325,7 @@ static int userfaultfd_stress(void) */ uffd_test_ops->release_pages(area_dst); =20 - uffd_stats_reset(args, nr_cpus); + uffd_stats_reset(args, nr_parallel); =20 /* bounce pass */ if (stress(args)) { @@ -359,7 +359,7 @@ static int userfaultfd_stress(void) =20 swap(area_src_alias, area_dst_alias); =20 - uffd_stats_report(args, nr_cpus); + uffd_stats_report(args, nr_parallel); } uffd_test_ctx_clear(); =20 @@ -453,9 +453,9 @@ int main(int argc, char **argv) return KSFT_SKIP; } =20 - nr_cpus =3D sysconf(_SC_NPROCESSORS_ONLN); + nr_parallel =3D sysconf(_SC_NPROCESSORS_ONLN); =20 - nr_pages_per_cpu =3D bytes / page_size / nr_cpus; + nr_pages_per_cpu =3D bytes / page_size / nr_parallel; if (!nr_pages_per_cpu) { _err("invalid MiB"); usage(); @@ -466,7 +466,7 @@ int main(int argc, char **argv) _err("invalid bounces"); usage(); } - nr_pages =3D nr_pages_per_cpu * nr_cpus; + nr_pages =3D nr_pages_per_cpu * nr_parallel; =20 printf("nr_pages: %lu, nr_pages_per_cpu: %lu\n", nr_pages, nr_pages_per_cpu); diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/s= elftests/mm/uffd-unit-tests.c index 74c8bc02b5063f4667c4284c432edc7dee7ba3a5..24ea82ee223184612781adc8524= 60138c4fe28f0 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -198,7 +198,7 @@ uffd_setup_environment(uffd_test_args_t *args, uffd_tes= t_case_t *test, =20 nr_pages =3D UFFD_TEST_MEM_SIZE / page_size; /* TODO: remove this global var.. it's so ugly */ - nr_cpus =3D 1; + nr_parallel =3D 1; =20 /* Initialize test arguments */ args->mem_type =3D mem_type; --=20 2.49.0.rc0.332.g42c0ae87b1-goog