From nobody Mon Feb 9 17:35:14 2026 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (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 3C321280A23 for ; Fri, 28 Feb 2025 16:55:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740761709; cv=none; b=faCpYrvUzAAgT0VtpYqtkAkxWhLtwhfeNSs9jyCimeamdWPohDMwXjok8R7w92UKPJ9OxpPYfrvJ/DXcT6bOxHaJrTb21h3ZKLCJExYMmbT0eaK/sm7npkdoBHg9KlLE/g50vEqKOSl5MmSjM60rvOzjRPa/qxCoAuh2YxvAAHA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740761709; c=relaxed/simple; bh=tfftHGPyv69HoB/ZMJmRXyKhQu/kB66LBoTZIdp1nOQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WWttA8nj8IYQ9n19FSvGNwIeZmgDDoSTQuHItP9mR8L6ZNLObHvitjsDviR//XexCQ8UQ7tF0H8vnFj/HeIKWz72RneUqtPtBgYkZJPQETv9qU/dCdApOawVmjUpHg8voPVR7KUD3W97Z8RZiWeU+PvQbcWS2Qpx8tfKDoBaQBM= 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=KjsjYz8T; arc=none smtp.client-ip=209.85.128.73 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="KjsjYz8T" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-43995bff469so15744745e9.2 for ; Fri, 28 Feb 2025 08:55:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1740761704; x=1741366504; 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=S9QxBMT1dy5QbhO22yQnX/sY19xHXMzPESl6Emh05kM=; b=KjsjYz8Ta89Uy7JNeUGklshpIb0f/79zaiXV5ylxV0sTlC8eFLYGI64EAiB4PXiNXo MLuuYRZGbSsZ5QYEr98GW1OC8wTyKVcGV3ZxxgeukLhnDw8pYjgArgzCTmZnpQSezj5I QQc8e67aME9afa7F4I4d/XYyEDI9v9flnP4rwzVQf0GU914JxrkEp8Ln3swAc4xn3Wzp DW0jT0xH8p/+pNk0PppkniRnDuDKHj8fbqYtLyJdKyhBFzSk0L0X4LeJ+I2knqzNiGE1 RxSRB0yrXDedd130L8fDXoVVoWmN4IWu2vReV7Xu5vWHJbVhmynNRMZq3axd52lNFDwL Kmhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740761704; x=1741366504; 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=S9QxBMT1dy5QbhO22yQnX/sY19xHXMzPESl6Emh05kM=; b=ObuhD9qsAKylF6N8/QZ6hw3yELnn3z9cxmUH5MO+7OkwZurT5J0e/GhI5fur7txrii XeqrA4MJUCH2m4MrfuZeUqdgNb1TaerjfocPaDN69IxWvfsAzU7bbbqnGC6D2alnx1+o TkDkwQZ9UUjYP6tp1twONyKNzGo4y5AEAXGnn7yAMYZ3Mj+HjSjO00Yt1hMIJVrSTYQC FeHIUqleDhwDvXNXGz0TCS1rlfY8YMeGezTP4b0zuMrZZfVISk89+2wDNK8jS+LPbFOX cge0URBuznWOYFhxImJ+vK4tgc1g4xN1mG/FhdcDCC6E0zCrP+Um9Hq/2Q9Mjh+WccWo pXXw== X-Forwarded-Encrypted: i=1; AJvYcCVQU3RYropPp87BGE5wunpAlovrMUYygPU6ecvFDrONX9r/542eoIpXiHYYSNwoTVvuUeCsxFyGB3N8cVg=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7rpCb8yTRZFn91ElkXC1xJJ9aZzW9msO9XWuh841Sk4OAPgGt +Rv1aXbba2zLf1yyqtdR161+skulZa6FTDGdZR/hXjARP5SMOkw2aVaJsDxowqXWXBA2dZe6Rrn CsoIBteuooA== X-Google-Smtp-Source: AGHT+IH0IbPgf0WZB4YwqpZ6IMtQ3dgzowLYjozZVKkhVKhCwE0plHrNAT013hhx4TNDxRckM/EIsEy0iSzC0A== X-Received: from wrbfy2.prod.google.com ([2002:a05:6000:2d82:b0:390:e463:27fd]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:2c4:b0:390:ec10:9dca with SMTP id ffacd0b85a97d-390eca414e4mr3842391f8f.45.1740761704683; Fri, 28 Feb 2025 08:55:04 -0800 (PST) Date: Fri, 28 Feb 2025 16:54:52 +0000 In-Reply-To: <20250228-mm-selftests-v3-0-958e3b6f0203@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250228-mm-selftests-v3-0-958e3b6f0203@google.com> X-Mailer: b4 0.15-dev Message-ID: <20250228-mm-selftests-v3-4-958e3b6f0203@google.com> Subject: [PATCH v3 04/10] selftests/mm/uffd: Rename nr_cpus -> nr_threads 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. Signed-off-by: Brendan Jackman Reviewed-by: Dev Jain --- 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 717539eddf98754250e70e564cd9a59f398bd7ea..a72a2ed5e89480ed06c81b03496= 7ed5ae5f8cad5 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_threads, 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_threads * 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_threads * 2); if (!pipefd) err("pipefd"); - for (cpu =3D 0; cpu < nr_cpus; cpu++) + for (cpu =3D 0; cpu < nr_threads; 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..604e3572fe17280ae346b031e2e= 867e039578f95 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_threads, 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 ed68436fac62c76e2ca7060c661487f2f8a6ab45..ec842bbb9f18e291fa51de0ed8d= 1fbf9aaf14372 100644 --- a/tools/testing/selftests/mm/uffd-stress.c +++ b/tools/testing/selftests/mm/uffd-stress.c @@ -179,12 +179,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_threads]; + pthread_t uffd_threads[nr_threads]; + pthread_t background_threads[nr_threads]; =20 finished =3D 0; - for (cpu =3D 0; cpu < nr_cpus; cpu++) { + for (cpu =3D 0; cpu < nr_threads; cpu++) { if (pthread_create(&locking_threads[cpu], &attr, locking_thread, (void *)cpu)) return 1; @@ -202,7 +202,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_threads; cpu++) if (pthread_join(background_threads[cpu], NULL)) return 1; =20 @@ -218,11 +218,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_threads; 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_threads; cpu++) { char c; if (bounces & BOUNCE_POLL) { if (write(pipefd[cpu*2+1], &c, 1) !=3D 1) @@ -245,11 +245,11 @@ static int userfaultfd_stress(void) { void *area; unsigned long nr; - struct uffd_args args[nr_cpus]; + struct uffd_args args[nr_threads]; 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_threads); =20 if (features & UFFD_FEATURE_WP_UNPOPULATED && test_type =3D=3D TEST_ANON) flags =3D UFFD_FEATURE_WP_UNPOPULATED; @@ -324,7 +324,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_threads); =20 /* bounce pass */ if (stress(args)) { @@ -358,7 +358,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_threads); } uffd_test_ctx_clear(); =20 @@ -452,9 +452,9 @@ int main(int argc, char **argv) return KSFT_SKIP; } =20 - nr_cpus =3D sysconf(_SC_NPROCESSORS_ONLN); + nr_threads =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_threads; if (!nr_pages_per_cpu) { _err("invalid MiB"); usage(); @@ -465,7 +465,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_threads; =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 9ff71fa1f9bf09b3ae599250663a25bbe2c13b8a..2f84fae5642c6f91b75fbf5f5d5= 9ae64a1c15f92 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -197,7 +197,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_threads =3D 1; =20 /* Initialize test arguments */ args->mem_type =3D mem_type; --=20 2.48.1.711.g2feabab25a-goog