From patchwork Thu Jan 11 15:49:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 187428 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1538329dyi; Thu, 11 Jan 2024 07:49:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IELAg0u/DhWvyoxsAv/QXWOY6vXBILuzDOdqzXqBu5WAYv+Zg3oywrMz9iC5OmFLIUrI7gz X-Received: by 2002:aa7:d90f:0:b0:547:9f26:e581 with SMTP id a15-20020aa7d90f000000b005479f26e581mr667841edr.37.1704988198341; Thu, 11 Jan 2024 07:49:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704988198; cv=none; d=google.com; s=arc-20160816; b=YqAhx1dDcNCORH4AIZdb7k5XVp0cz8FVSiEU/dxulrjbStTUvRlGcpj6NhCm4Ze5lZ 0wXU9DSd2YiQGt1TAaEjT733DyTWfuLw24jxaZEHWVYRbpo0A/9h+m324+2hFcNN9fnY 3qgSI4ENbu+hcR5+QXXDe5aDMPF81MH5tb99HL/8RygGVYIlupcs/Krj/k+bFa8V4Eft AgDxTLcNPSM6er/j4jvq/pp2pA0ycnlspixjGm1152oCdR8p6GZeIDFGD0K3wg3Uhat/ 2C5TtLAwGKVp0UwMmaFLdnxlBvaRnjObEPna4kHzDb9jpLyocIpo+9gC7XuwC5mxPHKE NVlg== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23812-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e25-20020a056402089900b00558548ea483si618595edy.493.2024.01.11.07.49.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 07:49:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23812-ouuuleilei=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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23812-ouuuleilei=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 EDEE51F23A3C for ; Thu, 11 Jan 2024 15:49:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 117274F60B; Thu, 11 Jan 2024 15:49:49 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787809705041201309 X-GMAIL-MSGID: 1787809705041201309 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)) {