Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3347821rdh; Mon, 27 Nov 2023 11:51:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHG9gZjNN2MLDV9l9x/zbNmoTC78nhrLIrnM/EFB+e6JgkGTP5G+j2L9EsByzWU/oBiYumf X-Received: by 2002:a05:6a00:1c8f:b0:68f:cbd3:5b01 with SMTP id y15-20020a056a001c8f00b0068fcbd35b01mr24178852pfw.13.1701114693302; Mon, 27 Nov 2023 11:51:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701114693; cv=none; d=google.com; s=arc-20160816; b=Wf97bC6r1l7y3g7T3+V6vCZogKiK5hxct/u1da2Ym5UDVnTTMwMk7TYR44cjg0Cnzf yKd/Z7L7/VKL88nYK1XWTdz8a8eRM6x02+EZ2LDFDPUl5Mu6hLLYUU1tZZ3qUmVOmZon /fnlwMKXiby04oi6XY0rbJbUzBDNHhKHKYM15Cc3g81qP67jHO6f1E44tdMTl3FoCfy9 +H8ls3JP+Ff6EERf7whUzF41lclQrHkhbxdDBQiJIYB564RSyFWHvQN+GSnWDEy4g3/y Fo3SW5gc/yOSoo89Ky/VMq8KrDc9CCAMpfVjKturQzL4B/uCRmH2c/GaNs/+tqDUB4hd ICow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=yetQtQw07rU4YZ4FG3ra/SKREh1x+pvvLVJIVKSvN98=; fh=O8FNonD+/HhConl0qaAQgDnoN70tr3h//IJJLWPkPY4=; b=0a+Das+/HLsHYwq06BP/YEGxokIRzDBz7AhmSBL+YN5hxCghg1ctNd7pTtYWf9HBJx 27faJmU4jtVZLigPtSpRKsmEGlSYFzAuh3rAK/7EIRok4HNCQUzjUArg7qMEdM8qKoyW gHI5c3VAzJqCnoyPz405NCXTFD5iQNgq08geuviMM4o/LUTJupO5zo9sxQUWdIr1LeGd bCSuRjDFEpfhfd436atd7p7601XC8bYtJ/asTWoAAmi0O4x4whuOQWAGGttdawy/WSwQ 4z8E06WNLenk6HGKAedMHjAb32hpoFgfnEtfeZ01S0lUiK2d2WCvZuIRtYo0tdYm3DL5 oiOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=D1LmlbiF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id f13-20020a056a001acd00b006cb6a3acfafsi10692850pfv.21.2023.11.27.11.51.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 11:51:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=D1LmlbiF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 5CB528062931; Mon, 27 Nov 2023 11:51:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232667AbjK0TvP (ORCPT + 99 others); Mon, 27 Nov 2023 14:51:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231174AbjK0TvL (ORCPT ); Mon, 27 Nov 2023 14:51:11 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67460DC for ; Mon, 27 Nov 2023 11:51:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701114676; 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; bh=yetQtQw07rU4YZ4FG3ra/SKREh1x+pvvLVJIVKSvN98=; b=D1LmlbiF+W4pKuMqgZWssNHBqCkXS+C44ljypm/wlpIF4dDmDrYopCtv6sm9miRO6VtGNn 0L+oYplAmGU+QUCFwmUggZNs9vsmf0KvET7s/Vx88fsUWS71oyHFTgpkQAUgId93QDUO7L OPbZMtWkFrILn/ggmkHjW8CCnlVSoR0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-68-8QI2V3YVMdKdlmPH0cmaFA-1; Mon, 27 Nov 2023 14:51:13 -0500 X-MC-Unique: 8QI2V3YVMdKdlmPH0cmaFA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id A75F6185A780; Mon, 27 Nov 2023 19:51:12 +0000 (UTC) Received: from llong.com (unknown [10.22.8.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D435492BE9; Mon, 27 Nov 2023 19:51:12 +0000 (UTC) From: Waiman Long To: Tejun Heo , Zefan Li , Johannes Weiner , Jonathan Corbet , Shuah Khan Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Waiman Long Subject: [PATCH] cgroup/cpuset: Expose cpuset.cpus.isolated Date: Mon, 27 Nov 2023 14:51:05 -0500 Message-Id: <20231127195105.290402-1-longman@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 27 Nov 2023 11:51:29 -0800 (PST) The root-only cpuset.cpus.isolated control file shows the current set of isolated CPUs in isolated partitions. This control file is currently exposed only with the cgroup_debug boot command line option which also adds the ".__DEBUG__." prefix. This is actually a useful control file if users want to find out which CPUs are currently in an isolated state by the cpuset controller. Remove CFTYPE_DEBUG flag for this control file and make it available by default without any prefix. The test_cpuset_prs.sh test script and the cgroup-v2.rst documentation file are also updated accordingly. Minor code change is also made in test_cpuset_prs.sh to avoid false test failure when running on debug kernel. Signed-off-by: Waiman Long --- Documentation/admin-guide/cgroup-v2.rst | 7 ++++ kernel/cgroup/cpuset.c | 2 +- .../selftests/cgroup/test_cpuset_prs.sh | 32 +++++++++++-------- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst index cf5651a11df8..30f6ff2eba47 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -2316,6 +2316,13 @@ Cpuset Interface Files treated to have an implicit value of "cpuset.cpus" in the formation of local partition. + cpuset.cpus.isolated + A read-only and root cgroup only multiple values file. + + This file shows the set of all isolated CPUs used in existing + isolated partitions. It will be empty if no isolated partition + is created. + cpuset.cpus.partition A read-write single value file which exists on non-root cpuset-enabled cgroups. This flag is owned by the parent cgroup diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 1bad4007ff4b..2a16df86c55c 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -3974,7 +3974,7 @@ static struct cftype dfl_files[] = { .name = "cpus.isolated", .seq_show = cpuset_common_seq_show, .private = FILE_ISOLATED_CPULIST, - .flags = CFTYPE_ONLY_ON_ROOT | CFTYPE_DEBUG, + .flags = CFTYPE_ONLY_ON_ROOT, }, { } /* terminate */ diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh index 7b7c4c2b6d85..b5eb1be2248c 100755 --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh @@ -508,7 +508,7 @@ dump_states() XECPUS=$DIR/cpuset.cpus.exclusive.effective PRS=$DIR/cpuset.cpus.partition PCPUS=$DIR/.__DEBUG__.cpuset.cpus.subpartitions - ISCPUS=$DIR/.__DEBUG__.cpuset.cpus.isolated + ISCPUS=$DIR/cpuset.cpus.isolated [[ -e $CPUS ]] && echo "$CPUS: $(cat $CPUS)" [[ -e $XCPUS ]] && echo "$XCPUS: $(cat $XCPUS)" [[ -e $ECPUS ]] && echo "$ECPUS: $(cat $ECPUS)" @@ -593,17 +593,17 @@ check_cgroup_states() # # Get isolated (including offline) CPUs by looking at -# /sys/kernel/debug/sched/domains and *cpuset.cpus.isolated control file, +# /sys/kernel/debug/sched/domains and cpuset.cpus.isolated control file, # if available, and compare that with the expected value. # # Note that isolated CPUs from the sched/domains context include offline # CPUs as well as CPUs in non-isolated 1-CPU partition. Those CPUs may -# not be included in the *cpuset.cpus.isolated control file which contains +# not be included in the cpuset.cpus.isolated control file which contains # only CPUs in isolated partitions. # # $1 - expected isolated cpu list(s) {,} # - expected sched/domains value -# - *cpuset.cpus.isolated value = if not defined +# - cpuset.cpus.isolated value = if not defined # check_isolcpus() { @@ -611,7 +611,7 @@ check_isolcpus() ISOLCPUS= LASTISOLCPU= SCHED_DOMAINS=/sys/kernel/debug/sched/domains - ISCPUS=${CGROUP2}/.__DEBUG__.cpuset.cpus.isolated + ISCPUS=${CGROUP2}/cpuset.cpus.isolated if [[ $EXPECT_VAL = . ]] then EXPECT_VAL= @@ -692,14 +692,18 @@ test_fail() null_isolcpus_check() { [[ $VERBOSE -gt 0 ]] || return 0 - pause 0.02 - check_isolcpus "." - if [[ $? -ne 0 ]] - then - echo "Unexpected isolated CPUs: $ISOLCPUS" - dump_states - exit 1 - fi + # Retry a few times before printing error + RETRY=0 + while [[ $RETRY -lt 5 ]] + do + pause 0.01 + check_isolcpus "." + [[ $? -eq 0 ]] && return 0 + ((RETRY++)) + done + echo "Unexpected isolated CPUs: $ISOLCPUS" + dump_states + exit 1 } # @@ -776,7 +780,7 @@ run_state_test() # NEWLIST=$(cat cpuset.cpus.effective) RETRY=0 - while [[ $NEWLIST != $CPULIST && $RETRY -lt 5 ]] + while [[ $NEWLIST != $CPULIST && $RETRY -lt 8 ]] do # Wait a bit longer & recheck a few times pause 0.01 -- 2.39.3