From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792433462; b=c7QGiMe8XohzHwheUup6Hdzy7SZ8gQYeit4/Z76BkBRuCacDEiYbWBQMSbz45BdNhYgH 0wZZqPyO5mWYJ8eU6NUOW6WRHYH5CZtWcHXmnc5jmdM8a+ce3OlpUpvm8OtbJPoGOavxw K7Jz0ga/xwy0eVvdkex3D0XlJW3GoaAqKb2VE78dthAZ99iOPUp+oOiKDi6ZQmQaUx49H 2olVSk6q62tn9kQZdS2MpBd6ui/HmNy5DpeM1iQ7xw8ahX+iIZmtASRs1ctuMVStJj7DG YKha0yaGpl00XKgXsuNdc4EBADR4Hcc7iLtxO1SYQ82OE6bHekmOi3rI06dZqf1eF4Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792433462; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=fRpRjOsNXnarjnEQWZ+ErDczW+pYEljbQ5Lk8t6C4EY=; b=bGAHQpTCOH3J6KO+9WsRjWIVo7opGh4HHISn3vw+56rtIs+erUOAQP7lH2bvw1sJZ654 3LYgHPrf+MJdkMMWXRqI82/Ch2ijmgvTGcQkBfCNoEM922I9Bz0qrZE86k91eoperwn6c 9xoeBmreWFxuSaD2gyE2lC+Dtl5rF5iuWpwhBizVJbfeEqsQHtmmZZ0q9c97Pe5j3i/PY 8NLYUsraw4FMKcwTgMCU6kPbaFkahUa486PQ/4bo1cVRnQ+melanp/80cEXoMRQXR0REN hdncoNbmwLRBEPkrI37m/mzm2kE+rLG8OaGf7DaZlzhbDrc+8nvDx47SDyqVw76dVYA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Yax34QwX; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC58F60A3834 for ; Mon, 19 Oct 2026 18:11:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AC58F60A3834 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Yax34QwX DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792433460; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fRpRjOsNXnarjnEQWZ+ErDczW+pYEljbQ5Lk8t6C4EY=; b=Yax34QwX1dXiUQdqPtxYbl9n28+Yji6JoDszPeEcTRf0wXd/dVlJhehb0V58WnvEsiFsrs GgglfBTCSdYeRgsU205KocUJmNXj3g278I/4vKwv303hLBSwXJHXywGNJgs5GeZTewkT+l RkeQUmZJ1z7nWZ8WXdk8HjeiGlhFYfc= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-497-109DXJwlOFq_-0n6tQukrA-1; Mon, 19 Oct 2026 18:10:57 +0000 X-MC-Unique: 109DXJwlOFq_-0n6tQukrA-1 X-Mimecast-MFC-AGG-ID: 109DXJwlOFq_-0n6tQukrA_1792433455 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id ABF18195609F; Mon, 19 Oct 2026 18:10:55 +0000 (UTC) Received: from llong-thinkpadp16vgen1.rmtusnh.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B4469418; Mon, 19 Oct 2026 18:10:53 +0000 (UTC) From: Waiman Long To: Ridong Chen , Tejun Heo , Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Shuah Khan , Jonathan Corbet , Randy Dunlap Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Hui Peng , Guopeng Zhang , Waiman Long Subject: [PATCH-next v4 9/9] selftests/cgroup: Skip test_cpuset_prs.sh test if some required CPUs are offline Date: Mon, 19 Oct 2026 14:10:20 -0400 Message-ID: <20261019181020.1069325-10-longman@redhat.com> In-Reply-To: <20261019181020.1069325-1-longman@redhat.com> References: <20261019181020.1069325-1-longman@redhat.com> X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 The test_cpuset_prs.sh test assumes that all the relevant CPUs being tested are online. If some of them are offline, some of the test cases may fail. So skip the test if the required CPUs are either offline or not present. While at it, the cleanup() and online_cpus() functions as well as the trap statement to run cleanup() on exit are moved earlier to make sure the cleanup function will be run if the test is somehow aborted early. Signed-off-by: Waiman Long --- .../selftests/cgroup/test_cpuset_prs.sh | 64 +++++++++++++------ 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh index 7639e9f11cf9..d04aad697b96 100755 --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh @@ -67,6 +67,30 @@ then echo Y > /sys/kernel/debug/sched/verbose fi +cleanup() +{ + online_cpus + cd $CGROUP2 + rmdir A1/A2/A3 A1/A2 A1 B1 test/A1 test/B1 test > /dev/null 2>&1 + rmdir rtest/p1/c11 rtest/p1/c12 rtest/p2/c21 \ + rtest/p2/c22 rtest/p1 rtest/p2 rtest > /dev/null 2>&1 + [[ -n "$SCHED_DEBUG" ]] && + echo "$SCHED_DEBUG" > /sys/kernel/debug/sched/verbose +} + +online_cpus() +{ + [[ -n "$OFFLINE_CPUS" ]] && { + for C in $OFFLINE_CPUS + do + write_cpu_online ${C}=1 + done + } +} + +# Clean up the cgroupfs directory if the test is aborted. +trap cleanup 0 2 3 6 + cd $CGROUP2 echo +cpuset > cgroup.subtree_control @@ -143,16 +167,25 @@ TEST_ISOLCPUS= skip_test "Current isolated CPUs ($CURRENT_ISOLCPUS) don't match boot isolated CPUs!" } -cleanup() -{ - online_cpus - cd $CGROUP2 - rmdir A1/A2/A3 A1/A2 A1 B1 test/A1 test/B1 test > /dev/null 2>&1 - rmdir rtest/p1/c11 rtest/p1/c12 rtest/p2/c21 \ - rtest/p2/c22 rtest/p1 rtest/p2 rtest > /dev/null 2>&1 - [[ -n "$SCHED_DEBUG" ]] && - echo "$SCHED_DEBUG" > /sys/kernel/debug/sched/verbose -} +# +# This test assumes that all the relevant CPUs being tested are online. +# If some of them are offline, some of the tests may fail. So we are going to +# skip running this test script if some of the required CPUs may be offline. +# The required CPUs include CPUs 0-7 and the first boot time isolated CPU if +# present. However the check below is not exhaustive and can be a false +# positive, but users should not run this test if some CPUs are offline. +# +ONLINE_CPUS=$(cat /sys/devices/system/cpu/online | sed -e "s/,.*//") +ONLINE_FIRST=$(echo $ONLINE_CPUS | sed -e "s/-.*//") +ONLINE_LAST=$(echo $ONLINE_CPUS | sed -e "s/.*-//") +if [[ -n "$FIRST_ISOLCPUS" ]] +then + LAST_REQUIRED_CPU=$FIRST_ISOLCPUS +else + LAST_REQUIRED_CPU=7 +fi +[[ $ONLINE_FIRST != 0 || $ONLINE_LAST -lt $LAST_REQUIRED_CPU ]] && + skip_test "Some of the required CPUs are offline or not present!" # Pause in ms pause() @@ -754,16 +787,6 @@ set_ctrl_state_noerr() } } -online_cpus() -{ - [[ -n "$OFFLINE_CPUS" ]] && { - for C in $OFFLINE_CPUS - do - write_cpu_online ${C}=1 - done - } -} - # # Remove all the test cgroup directories # @@ -1397,7 +1420,6 @@ test_inotify() echo "" > cpuset.cpus } -trap cleanup 0 2 3 6 run_state_test TEST_MATRIX run_remote_state_test REMOTE_TEST_MATRIX TEST_ISOLCPUS=1 run_state_test ISOLCPUS_TEST_MATRIX -- 2.55.0