From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.151 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796561173; b=gFcraIXgslm1Ir1/tE6r7ado7kKB7Hy+l5738fwRfNNpvi1kITcmmugCliG/HOxMkceR EF2BmKMdCduReDlWChwgzjoqNqnSAznyOnBuwuM4lX0dA03sF79LgwQJ97X2ec26BpSLc 1UkTG0DEadZxWz3nyKXzSzhzVhYNPcVK3f2oEzEpKJUCQbZatWIeDJeEDzqlvzpiEaA+k OsWajypdimrHKJ0fTVycnqAOuqt7bt5pHhPmJredwpN1xZrHnBg6bMK1IWhHbRi5/tcv8 RDDn1Sz7kIqmQOHiQlHKTuO+pCcgF5A+Z3FhnS0nJiI7H57LRBJqGE4xPkUcfgvD/8A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796561173; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:X-B4-Tracking:To:Cc: X-Mailer; bh=YRxMUPmnNV9/lDk82uV5RaaDwxwFEEeVsI++33kf9vg=; b=nxasUfX8mbjNE8c8ws4aRjVfTUsOIyJYTRlDmPVyAWM2Jtlki7igWXf3QctGVSTDzTiz qUM/P4pmrBUtDAWxxiFeCR6vC84b54Q9PP/t4HA3AZ+A0a6cGhI6rtsN7S4xEbNVDEUsP wnrstUBbSFQX8BulZUz+Osq4p8YOZFDl+nFow+dITNQrXrqzGM6zBo4MeCdOyBQk0obvx zQa4j22K8cVjTZ4bR8gZmKN6cnwW2jqa6+GXW+1yUsH2fa0F600PJ+tGth7ClOp7o69Uo o9Ff/h144TAClG5iPh5Cccv8p3SvHgKtnc1OLQVKdS5E1L0PbRJPrmHLI4JJc6uypVA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=LLCK+RyF; arc=none smtp.remote-ip=95.215.58.151 Received: from mta1.migadu.com (out-151.mta1.migadu.com [95.215.58.151]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AC5D606A321 for ; Sun, 6 Dec 2026 12:46:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4AC5D606A321 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=LLCK+RyF X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=p36zpBT5zt7qnbOYHunNicscc7okBisKvlvADLXI22k=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796561171; v=1; x=1797165971; b=LLCK+RyFCBs5WCG/W6UeJdXqsZuhAYUB1PjdcSJTKXXknEXyDcMho8ZC3ggax34/ejLQJ5L+ 8HPyKa+UII5vyfR5IevUuzrlSOXIXpZfCKE9d8FADT4pCEGGR5aMK/dAt6M2sXD8dpUuWlMIZDO wvQ7pwec5MZBd23rXDaf32PM= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id aa0171c6f518511a; Sun, 06 Dec 2026 12:46:10 +0000 X-Mizu-Trace-ID: aa0171c6f518511a X-Migadu-Flow: FLOW_OUT From: Qiliang Yuan Date: Sun, 06 Dec 2026 07:46:01 -0500 Subject: [PATCH] selftests/sched: skip cs_prctl_test without core scheduling support X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261206-fix-selftests-sched-cs-prctl-skip-v1-1-b8bf6e7cd711@linux.dev> X-B4-Tracking: v=1; b=H4sIAAhZFWsC/x2NQQqEQAwEvyI5GxiHxYNfWTxoJq5BcYfpQQTx7 xv2WNDVdRO0mIKG5qaip8G+h0PXNiTrdHyULTlTDLHvYuh5sYuh+1IVFQxZNbGAc5G6MzbLLGE OPp3mJC/yn1zUpX/jPT7PD/ROW3lzAAAA To: Shuah Khan , Peter Zijlstra Cc: Chris Hyser , Sinadin Shan , Yifei Liu , Shrikanth Hegde , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 PR_SCHED_CORE fails with ENODEV when SMT is not active, and with EINVAL when the kernel is built without CONFIG_SCHED_CORE. In both cases core scheduling cannot be tested. cs_prctl_test does not check for either and runs anyway, so it reports a failure on any machine without SMT or with such a kernel: Not a core sched system tid=2445, / tgid=2445 / pgid=2445: ffffffffffffffff ... (283) FAILED: get_cs_cookie(0) == 0 ... (cs_prctl_test.c:287) - core_sched create failed -- PGID: Invalid argument Read the cookie of the test itself before anything else and exit with KSFT_SKIP on ENODEV or EINVAL, saying which one applies. Any other error still fails the test. Fixes: 9f26990074931 ("kselftest: Add test for core sched prctl interface") Signed-off-by: Qiliang Yuan --- Sinadin Shan [1] and Yifei Liu [2] posted fixes for this before, and neither was merged. [2] returns 1 after reporting the skip, so the runner still counts a failure, and it does not cover kernels without CONFIG_SCHED_CORE. [1] probes with pid_max + 1 and treats any error but ESRCH as unsupported. This one reads the test's own cookie and skips only on ENODEV or EINVAL. [1] https://lore.kernel.org/r/20250225200910.260569-3-sinadin.shan@oracle.com [2] https://lore.kernel.org/r/20251120230235.2857291-1-yifei.l.liu@oracle.com --- tools/testing/selftests/sched/cs_prctl_test.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/testing/selftests/sched/cs_prctl_test.c b/tools/testing/selftests/sched/cs_prctl_test.c index 52d97fae4dbd8..727cbe0459816 100644 --- a/tools/testing/selftests/sched/cs_prctl_test.c +++ b/tools/testing/selftests/sched/cs_prctl_test.c @@ -20,6 +20,7 @@ */ #define _GNU_SOURCE +#include #include #include #include @@ -32,6 +33,8 @@ #include #include +#include "../kselftest.h" + #if __GLIBC_PREREQ(2, 30) == 0 #include static pid_t gettid(void) @@ -109,6 +112,24 @@ static void handle_usage(int rc, char *msg) exit(rc); } +/* Skip unless this kernel can do core scheduling on this machine */ +static void check_core_sched(void) +{ + /* Keep it aligned or PR_SCHED_CORE_GET fails with EINVAL */ + __aligned_u64 cookie; + + if (!prctl(PR_SCHED_CORE, PR_SCHED_CORE_GET, 0, PIDTYPE_PID, + (unsigned long)&cookie)) + return; + + if (errno == ENODEV) + ksft_exit_skip("core scheduling needs SMT, which is not active\n"); + if (errno == EINVAL) + ksft_exit_skip("core scheduling is not supported (CONFIG_SCHED_CORE)\n"); + + handle_error("core_sched get failed"); +} + static unsigned long get_cs_cookie(int pid) { unsigned long long cookie; @@ -270,6 +291,8 @@ int main(int argc, char *argv[]) if (keypress) delay = -1; + check_core_sched(); + srand(time(NULL)); /* put into separate process group */ --- base-commit: d14d00a5fea1ee2540be6a2238314b7ba1e41f86 change-id: 20261206-fix-selftests-sched-cs-prctl-skip-c0b0120abdc4 Best regards, -- Qiliang Yuan