From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj2-f41.google.com (mail-pj2-f41.google.com [74.125.227.169]) (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 C8DBF344DB7 for ; Wed, 30 Sep 2026 06:03:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.227.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790748216; cv=none; b=ApUjBM0a7zraE0WC7xHmLeU29O4WTTCoIh+Kv+H4ya01D8Izzm4/aU9l5G+UBkd3RO+1jeyytuJaCpg9BqQjepTBU/Ml11bgSNYgno5X8mXAiZD51L2RUaBYfJhjBhouGZ/TkqIFq/1zohv43WvFDR2v9kgg+t2Xp5u+OQ694vs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790748216; c=relaxed/simple; bh=axdDbCUJzEf1U4BkmExcoQBin+GjinUVGoYj1DB4yNg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=XiTnvArsezTW7DSd/T4TUsFoduVJ2PEeCXdLgSqgLxWWBhPVpK7JEjMUlC+pBBF/G2/6tPzsvfCxz3YtbNRQP1Wy5tJBH2sgoKEYT7Vjp9MYF47oW1wJlJIFmtQa2162ZPopZcGyGvVyOE/UVHEwo/htjI7apkuNT9coEyi/KRs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=sKQIjK45; arc=none smtp.client-ip=74.125.227.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sKQIjK45" Received: by mail-pj2-f41.google.com with SMTP id d9443c01a7336-2df90e859e8so16172755ad.0 for ; Tue, 29 Sep 2026 23:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790748214; x=1791353014; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=x3ttmE9X6/fAonyMgTPG4YUEsTGdFYYGeA/sfbV45M8=; b=sKQIjK45wPoS1dNuHPFH3ByFc5m6coPbzzQAuc8gEFd7k6yOoXmNJKc9FsXk6PMS88 Mzqqgqx4i/UuNZr2Lc4dpqOJg8Ht18WmpkHl+1jwZ7j2601gMNWeSyP0ZRlOC7b7ZGVV E4P+yLuNZLVBwj5+o1RLqzOCVZFT8usKP7Sac2j2GaPjgZc2JApop1JrTKLRgK7B+HLX WE/Z8xke+gtBJBUEm8LEOxbHjnldneWHVvqKStMkdE2if+kQUbPzaV8rZJ/YUUXBDHUN V2XWJkxrL3ZOngYhNS18GJPZGazNobY/mlITvBgD8ge+0cIJ1FdEYGVv/I4aub/eakDc TZ6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790748214; x=1791353014; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=x3ttmE9X6/fAonyMgTPG4YUEsTGdFYYGeA/sfbV45M8=; b=i/HxNjEH+mug2r7EmJ05F+JuVjmV7woUstuUSnpdmrnKzqdIJ5bS+ZgkM80marSbQE DsJP6Cm8p1c7XPsl3egIW40iTBym6lW2VmrP1hQhg5MOsVD1nwZBt6qKwBs/faw/4ghj 56M6kkZ/DfkSeNn+GyrZH6baL6VnG1IebilzC3jg/nrCawNOxnm/Rnter+t4TPcHKg61 Cky4GVv2KmVQnjA6b3IREL2b3f3u19knvtWJLfH2IXviZAeqisdCmKfEA+vSuaQ17GSK U09rLdNrGuS2aPkom2wZG6H1Y54+/RuwQS++zv8UIxOfqIe/vBBDaMRVzIdrrslnODGD Qaug== X-Forwarded-Encrypted: i=1; AKwUvBwNq2XF0HaoHwxv02oUKVTgW90abk0rPLzbs309QKhuylqITItZfX54myDsx6BMFvoYIdEIUiNbn6CfMQk=@vger.kernel.org X-Gm-Message-State: AFq9FYLtx8BVBHyxEavkqMvr3FWOWcGQGf2LzrbCqYrNefz4O2MS+/kk gU4qmB3o/lQgExhdLqFGNvnYvUuJhnaGVy/FBlBE6p/DDEoAQjSOdNcl X-Gm-Gg: AYBFou1ZzO3SkLhca2fqVnmD2z7T7zrTCfkJFysFGpA0ZNddJncc3scjDaGNLPDY9nn 3O6dWxRaqEsExNTN3fTKKb3DGVpzysQJ8xeEswD9GZdK0vEPbHDbH3Hb5prIsIXV/Mb4iSjJXPt AtEPdyAYmi/OVeRPmtyGEs0jNFBDP9j6Aead658ZUsv2nA/VQTwxiZ2grkQfoVszWrqrVwExZet wRcI2bmy09iPHXa6KdZIDOeZhMim5K0QfDJOb4e2IDrcxIOJGTlQrVojh2kuXn36IQIO5oPkIXS FSfOLey3nI1LdbmUDSpHF87L7dayyb1FzrEtaX+WjfAR1sB/T6rNCeULsOUhfdIR6SQB4T3D10p Tokwyz0slIDAHQmI1lx1+iGzqqqAiDxq/7suCAZUTV8vdyfo3PxJOEYU3Njywlo98EtYCdnTSux RfhgTD02i4EuHLv31iACnqeI1oWsD+JtAg0In3uGVeJycss3imn+X2CnIGDsWDhhNy7o/qCxex6 Iw= X-Received: by 2002:a17:903:2947:b0:2e2:d3ef:125 with SMTP id d9443c01a7336-2e2e4edf4a8mr1557185ad.5.1790748213905; Tue, 29 Sep 2026 23:03:33 -0700 (PDT) Received: from omarchy ([2404:7a81:bb40:2400:e077:4928:9847:63b3]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2e2e5c39578sm1465025ad.76.2026.09.29.23.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2026 23:03:33 -0700 (PDT) From: Ren Tamura To: tj@kernel.org Cc: hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org, void@manifault.com, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] selftests: cgroup: enable the cpu controller in test_cpu Date: Wed, 30 Sep 2026 15:03:24 +0900 Message-ID: <179074810117.139422.8287518907118199923@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_cpu uses cg_read_strstr() to check for "cpu" in the root cgroup's cgroup.subtree_control. The substring also matches "cpuset", so a hierarchy with only cpuset enabled skips writing "+cpu" during setup. The tests then run without the required controller enabled and report failures. When cpu is unavailable in that hierarchy, the suite also reports failures instead of skipping. Always write "+cpu" during setup and skip if the write fails. Enabling a controller that is already enabled is a no-op, so a separate presence check is unnecessary. This requires write access to cgroup.subtree_control even when cpu is already enabled. Fixes: 820a4f88ee46 ("cgroup: Add new test_cpu.c test suite in cgroup selftests") Assisted-by: LLM Signed-off-by: Ren Tamura --- Validation (2026-09-24, mainline 62f4c998b297): ran the full, unfiltered test_cpu binary as root on a freshly built mainline kernel in a four-vCPU KVM guest. With only cpuset enabled, the original reports two passes and seven failures; the modified binary passes all nine tests. With cpu already enabled, both pass all nine tests in the comparison with vCPUs pinned to separate physical cores. With cpu disabled at boot and only cpuset enabled, the original reports test failures while the modified binary skips with exit status 4. The guest validation used a writable root cgroup. LLM assistance: finding small cgroup fixes, drafting code and commit messages, and preparing validation. tools/testing/selftests/cgroup/test_cpu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_cpu.c b/tools/testing/selftests/cgroup/test_cpu.c index 735a53bb222ba98812d5c6ace221c3154362d859..3456e3e988c68aa6105a0d862fdc51fa0cb10d6a 100644 --- a/tools/testing/selftests/cgroup/test_cpu.c +++ b/tools/testing/selftests/cgroup/test_cpu.c @@ -835,9 +835,8 @@ int main(int argc, char *argv[]) if (cg_find_unified_root(root, sizeof(root), NULL)) ksft_exit_skip("cgroup v2 isn't mounted\n"); - if (cg_read_strstr(root, "cgroup.subtree_control", "cpu")) - if (cg_write(root, "cgroup.subtree_control", "+cpu")) - ksft_exit_skip("Failed to set cpu controller\n"); + if (cg_write(root, "cgroup.subtree_control", "+cpu")) + ksft_exit_skip("Failed to set cpu controller\n"); ksft_set_plan(ARRAY_SIZE(tests)); for (i = 0; i < ARRAY_SIZE(tests); i++) { base-commit: 551c722f40809618230001baccf219193e22fc5a