Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1735397rdd; Thu, 11 Jan 2024 07:49:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IEo4hLwMORywAF3OkQ3PZ0KUzzApYqPNEA4NUdhjmqF8Xc9DwHtDwb8Wr9qWZpGy7FBArgw X-Received: by 2002:a05:6402:899:b0:557:1131:141b with SMTP id e25-20020a056402089900b005571131141bmr702915edy.83.1704988191113; Thu, 11 Jan 2024 07:49:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704988191; cv=none; d=google.com; s=arc-20160816; b=yEKPhO+uHr/cLsgJNa9lWG325P5fdgrOwj6KxB8Yoa8TiSyfakQDHxh2CwvKH9HtPy mFEPriPYtE9U6rwydVsCaHACYGRxQ3jdqwEAuthqElzgrn5d4kavjsW9W0mzuh4FMkOc xk/ThMQ9DM9OltzHgdcYAOf2ugoD5Oiye3hHQ8BZd3fKD+wYyEEsSIjpw1ljWy3BjAKS Cj1772vlNGi9tl7pmHGmzgNOJsQUwL+CfBXSkr+xSAtcT5MBM8fmeLvIgzN4nYBX4CSm KwoXSFVNBs7v9PP2Ci+ogtOjG/+AfNrSE53Wqeg7+lR4rCXbPBxWqnd5sMJdvZsng6mM u69A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=gDEuqUlPMEuX0ZAx/Zv2wy8y6A28pB5dCLkBym7DdGw=; fh=LL8fFJyOEtpDTsW+j6hN0G0zVhRoJ4sNESdk4IOYreY=; b=ABU5PC9CaCEYzy6QYvZO1sj2SdxGMa1LFcN12bI6q2XHJ9SS06a+ZHoAjPrrLucZ7/ WidRsX6vpMes2CysXotwrQ2F1vQJqENwUHO8Km55d1x/0aTNxr524ydkZ2Y6tBTfh7y9 XBSzhSrAZdX+2v1gD+cNxLRokYEEZc9nQudbZr1aP21qs7OAhQpmRYDFEGZHnziQy9pz 3GOn36xKYZMtW9Oq7Zl2efYO039OM1tKmzZQ/GihUnhwB3wV5C2wjVTQr2ekeahNcYI4 hc9/JgDqxv0unmpELT2wAg6kSmKI0MLibxU3W93IIKbwYNzOV/xQxMDveiV+Vj7sUUQ+ RY7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=N2iGFPVQ; spf=pass (google.com: domain of linux-kernel+bounces-23812-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23812-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i7-20020aa7c707000000b005581f0994d7si640373edq.532.2024.01.11.07.49.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 07:49:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23812-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=N2iGFPVQ; spf=pass (google.com: domain of linux-kernel+bounces-23812-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23812-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B0E9D1F22F21 for ; Thu, 11 Jan 2024 15:49:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1AB254D5B2; Thu, 11 Jan 2024 15:49:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="N2iGFPVQ" Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B9C94CDE9 for ; Thu, 11 Jan 2024 15:49:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1704988169; bh=CiSR0Tuk8JBUjA4HrB2X52STAqq56NnAYbyj25ClA9g=; h=From:To:Cc:Subject:Date:From; b=N2iGFPVQl/3OZWrtZHRqk055f6PMfMCN4b0gU0qjkpId3g1bWEM3Gc4tADi70dNaP 6iegc9DBiivGsD1wg6akSh2B209PRfnxDj381hVscFIXHh8pDNWz02gTI00HVaENbo Bazm5fG0PAwtFsL7PAYa53SKValB5TqYfMYdHr+hEk5NCsiYCwZWbvfYpo4+8dAnIa RNHRLwW4IqjtawhzVyQ9l1MFSp4E7onShLuoY1Il6wyANDCJn6BCdb+8jK0XOgwJpy ShZuhBl9Wfm24WiwUDLtH57AUovjm9FbATPS4z6n1He3eZXfb4T/4AaqrUoyIsKvpa EwirL1wEIL+2Q== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4T9py148ypzKTm; Thu, 11 Jan 2024 10:49:29 -0500 (EST) From: Mathieu Desnoyers To: Shuah Khan Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Peter Zijlstra , "Paul E. McKenney" , Boqun Feng Subject: [PATCH] selftests/rseq: Do not skip !allowed_cpus for mm_cid Date: Thu, 11 Jan 2024 10:49:22 -0500 Message-Id: <20240111154922.600919-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Indexing with mm_cid is incompatible with skipping disallowed cpumask, because concurrency IDs are based on a virtual ID allocation which is unrelated to the physical CPU mask. These issues can be reproduced by running the rseq selftests under a taskset which excludes CPU 0, e.g. taskset -c 10-20 ./run_param_test.sh Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: Peter Zijlstra Cc: "Paul E. McKenney" Cc: Boqun Feng --- .../selftests/rseq/basic_percpu_ops_test.c | 14 ++++++++++-- tools/testing/selftests/rseq/param_test.c | 22 ++++++++++++++----- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/rseq/basic_percpu_ops_test.c b/tools/testing/selftests/rseq/basic_percpu_ops_test.c index 887542961968..2348d2c20d0a 100644 --- a/tools/testing/selftests/rseq/basic_percpu_ops_test.c +++ b/tools/testing/selftests/rseq/basic_percpu_ops_test.c @@ -24,6 +24,11 @@ bool rseq_validate_cpu_id(void) { return rseq_mm_cid_available(); } +static +bool rseq_use_cpu_index(void) +{ + return false; /* Use mm_cid */ +} #else # define RSEQ_PERCPU RSEQ_PERCPU_CPU_ID static @@ -36,6 +41,11 @@ bool rseq_validate_cpu_id(void) { return rseq_current_cpu_raw() >= 0; } +static +bool rseq_use_cpu_index(void) +{ + return true; /* Use cpu_id as index. */ +} #endif struct percpu_lock_entry { @@ -274,7 +284,7 @@ void test_percpu_list(void) /* Generate list entries for every usable cpu. */ sched_getaffinity(0, sizeof(allowed_cpus), &allowed_cpus); for (i = 0; i < CPU_SETSIZE; i++) { - if (!CPU_ISSET(i, &allowed_cpus)) + if (rseq_use_cpu_index() && !CPU_ISSET(i, &allowed_cpus)) continue; for (j = 1; j <= 100; j++) { struct percpu_list_node *node; @@ -299,7 +309,7 @@ void test_percpu_list(void) for (i = 0; i < CPU_SETSIZE; i++) { struct percpu_list_node *node; - if (!CPU_ISSET(i, &allowed_cpus)) + if (rseq_use_cpu_index() && !CPU_ISSET(i, &allowed_cpus)) continue; while ((node = __percpu_list_pop(&list, i))) { diff --git a/tools/testing/selftests/rseq/param_test.c b/tools/testing/selftests/rseq/param_test.c index 20403d58345c..2f37961240ca 100644 --- a/tools/testing/selftests/rseq/param_test.c +++ b/tools/testing/selftests/rseq/param_test.c @@ -288,6 +288,11 @@ bool rseq_validate_cpu_id(void) { return rseq_mm_cid_available(); } +static +bool rseq_use_cpu_index(void) +{ + return false; /* Use mm_cid */ +} # ifdef TEST_MEMBARRIER /* * Membarrier does not currently support targeting a mm_cid, so @@ -312,6 +317,11 @@ bool rseq_validate_cpu_id(void) { return rseq_current_cpu_raw() >= 0; } +static +bool rseq_use_cpu_index(void) +{ + return true; /* Use cpu_id as index. */ +} # ifdef TEST_MEMBARRIER static int rseq_membarrier_expedited(int cpu) @@ -715,7 +725,7 @@ void test_percpu_list(void) /* Generate list entries for every usable cpu. */ sched_getaffinity(0, sizeof(allowed_cpus), &allowed_cpus); for (i = 0; i < CPU_SETSIZE; i++) { - if (!CPU_ISSET(i, &allowed_cpus)) + if (rseq_use_cpu_index() && !CPU_ISSET(i, &allowed_cpus)) continue; for (j = 1; j <= 100; j++) { struct percpu_list_node *node; @@ -752,7 +762,7 @@ void test_percpu_list(void) for (i = 0; i < CPU_SETSIZE; i++) { struct percpu_list_node *node; - if (!CPU_ISSET(i, &allowed_cpus)) + if (rseq_use_cpu_index() && !CPU_ISSET(i, &allowed_cpus)) continue; while ((node = __percpu_list_pop(&list, i))) { @@ -902,7 +912,7 @@ void test_percpu_buffer(void) /* Generate list entries for every usable cpu. */ sched_getaffinity(0, sizeof(allowed_cpus), &allowed_cpus); for (i = 0; i < CPU_SETSIZE; i++) { - if (!CPU_ISSET(i, &allowed_cpus)) + if (rseq_use_cpu_index() && !CPU_ISSET(i, &allowed_cpus)) continue; /* Worse-case is every item in same CPU. */ buffer.c[i].array = @@ -952,7 +962,7 @@ void test_percpu_buffer(void) for (i = 0; i < CPU_SETSIZE; i++) { struct percpu_buffer_node *node; - if (!CPU_ISSET(i, &allowed_cpus)) + if (rseq_use_cpu_index() && !CPU_ISSET(i, &allowed_cpus)) continue; while ((node = __percpu_buffer_pop(&buffer, i))) { @@ -1113,7 +1123,7 @@ void test_percpu_memcpy_buffer(void) /* Generate list entries for every usable cpu. */ sched_getaffinity(0, sizeof(allowed_cpus), &allowed_cpus); for (i = 0; i < CPU_SETSIZE; i++) { - if (!CPU_ISSET(i, &allowed_cpus)) + if (rseq_use_cpu_index() && !CPU_ISSET(i, &allowed_cpus)) continue; /* Worse-case is every item in same CPU. */ buffer.c[i].array = @@ -1160,7 +1170,7 @@ void test_percpu_memcpy_buffer(void) for (i = 0; i < CPU_SETSIZE; i++) { struct percpu_memcpy_buffer_node item; - if (!CPU_ISSET(i, &allowed_cpus)) + if (rseq_use_cpu_index() && !CPU_ISSET(i, &allowed_cpus)) continue; while (__percpu_memcpy_buffer_pop(&buffer, &item, i)) { -- 2.25.1