Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp60964lqp; Thu, 4 Apr 2024 07:10:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXTsRIZe5Z+pSr8knZMJRSKMT1tp9NYQxLGZ/hOaQLn6Sm7mz3JZ5gq+0hfFNYXgk86sj4pfWsTEQUPPKd0N2hhRIl9AZl26bblcr3WDQ== X-Google-Smtp-Source: AGHT+IFtcg0yVsluuu9ZpLqsir/DV98Wi+OJOLhZUln+r6ObZS8u9/HNNWYJ79P9slbaHdr6ttEp X-Received: by 2002:a17:90a:c58a:b0:2a2:c353:7c38 with SMTP id l10-20020a17090ac58a00b002a2c3537c38mr2211432pjt.24.1712239830916; Thu, 04 Apr 2024 07:10:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712239830; cv=pass; d=google.com; s=arc-20160816; b=q4ROtfZRN2KO6k5b0jKzlOtz2cmyF8JxNmyb/iFNQFGsCvCi+FtD7UxrCbrrW2xYoO ZCEn1Vr9TMBm07PskVUG2xijoDCaKtDrpZ0EJZm30ZrKUM5vl/NfN5ciGo2x1PUu+hvt 0w7UEHE04IuaFxnpP0Nh4VoFAIw73nBDFwQ6Wkg1aMNifk/kSoFwSWQsSyQRgxncxeNY qi5oVd7fUonjuP/oeOFkWDNtsEBCCCQVWEMuJBCSYEb2kfQPQxl8RGMs8wFdO7F3f4fw wKuWs1dUVLeWLwsEdk4884eVSQqBG241++/+TNTZTV9Cay3lL9OzIiN02Pva/kJNQ+68 otkA== ARC-Message-Signature: i=2; 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hl4pfGBrbON0r6A5JWj3i+j4YMcyleP+1dPbuGF0SPU=; fh=poKe6GciFQF9x146sxSMYSKKws+3e4Cqcu3Udn5FQq4=; b=OobJ8mZ1Qm4VKfVUk/ag0+hMiArYlRQoNcElnyIP5G/2tgXWb4f9K6zzLdDxRO5Ybe l3aLAtlwx/4IyoXjJVHTeQYb4mxCa/SO51Wz/Sidnj83SWB9t7z9xbHY9wQisBtPf+lm eqRIT+INuZ82rGAHRWA315GcRkGiGDM6WcbOWYnhlPEM9I0HLucYP0TKq3atCbhIoATC MeCusupO+jVJ8XsBGj1Keu2Xe46/i1DD8AM/JuzVBmB3ZjNBiOXrucjPsmlZoWflFBx0 +/ikIEPj3qTA1+SRFWnAHGkTeSfvo5/4jtj3+BbA3YIpjlxvWp1E+RMfQRNWjiKPLrPE rWQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=G0v7R962; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-131533-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131533-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id o8-20020a17090a55c800b002a2a877e246si1761850pjm.35.2024.04.04.07.10.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 07:10:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131533-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=G0v7R962; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-131533-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131533-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 197BCB280DC for ; Thu, 4 Apr 2024 13:48:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2910312880A; Thu, 4 Apr 2024 13:48:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="G0v7R962" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 690351292E6 for ; Thu, 4 Apr 2024 13:48:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712238499; cv=none; b=gqrEfat9mqrBs19j6Ft41S/U0TFUgh3HkMA/j8fI3yOdoJrfPBgXxlYYC0TqUX1BHdbwFSanrjGeFxs7X4NuS4J5KiGSCC3gN2cgcJc9mV2pFNPdZQ5e1fzFuUaRSwMkh3f6fdTrjv3aPBx6gb2fhYZXS6Bk1jChAuK7Ae2QXkE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712238499; c=relaxed/simple; bh=y6/IshHk0uv9fDFkEevt+RsUXDV7iaRgIf3llsfiB/A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l5F7+wNuEomCTA1eS4qqmJzoj4nJOVxzYB3rd+1C8IYlVPgN+QEmNa2fSPP113JA1w6crCxbUqlpw4O4uat7kN9q8vbqqShReoJ87JqB3zkshqVUtdhUW95klhZloTr4LIww6YVfvrOd06LgeEIdVR37Oy1soM+n6Ltvi3SxapM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=G0v7R962; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712238496; 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=hl4pfGBrbON0r6A5JWj3i+j4YMcyleP+1dPbuGF0SPU=; b=G0v7R9622EoO9+kppii1b+YdAuHpmmlZsnciL5uWZE3302bgn59NuT/UoAvbtCmMryeZur dhYrPN/Ngty0/q4cSRjxNdhmdTg86yWTjlCUyP/Oi7XFc6trq99nN2LJlhEJAI8b98oZYw ZQDPAzfM/uPHCeOcFmIEZ75hiJIWFQ0= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-260-zJ0kA69APuKU_kbfP0Pa-g-1; Thu, 04 Apr 2024 09:48:09 -0400 X-MC-Unique: zJ0kA69APuKU_kbfP0Pa-g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 BEFD228043E4; Thu, 4 Apr 2024 13:48:07 +0000 (UTC) Received: from llong.com (unknown [10.22.9.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F3F13C54; Thu, 4 Apr 2024 13:48:06 +0000 (UTC) From: Waiman Long To: Tejun Heo , Zefan Li , Johannes Weiner , Thomas Gleixner , Peter Zijlstra , "Rafael J. Wysocki" , Len Brown , Pavel Machek , Shuah Khan Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-pm@vger.kernel.org, linux-kselftest@vger.kernel.org, Frederic Weisbecker , "Paul E. McKenney" , Ingo Molnar , Valentin Schneider , Anna-Maria Behnsen , Alex Shi , Vincent Guittot , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Waiman Long Subject: [PATCH v2 2/2] cgroup/cpuset: Add test_cpuset_v1_hp.sh Date: Thu, 4 Apr 2024 09:47:49 -0400 Message-Id: <20240404134749.2857852-3-longman@redhat.com> In-Reply-To: <20240404134749.2857852-1-longman@redhat.com> References: <20240404134749.2857852-1-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 Add a simple test to verify that an empty v1 cpuset will force its tasks to be moved to an ancestor node. It is based on the test case documented in commit 76bb5ab8f6e3 ("cpuset: break kernfs active protection in cpuset_write_resmask()"). Signed-off-by: Waiman Long --- tools/testing/selftests/cgroup/Makefile | 2 +- .../selftests/cgroup/test_cpuset_v1_hp.sh | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/cgroup/test_cpuset_v1_hp.sh diff --git a/tools/testing/selftests/cgroup/Makefile b/tools/testing/selftests/cgroup/Makefile index 00b441928909..16461dc0ffdf 100644 --- a/tools/testing/selftests/cgroup/Makefile +++ b/tools/testing/selftests/cgroup/Makefile @@ -4,7 +4,7 @@ CFLAGS += -Wall -pthread all: ${HELPER_PROGS} TEST_FILES := with_stress.sh -TEST_PROGS := test_stress.sh test_cpuset_prs.sh +TEST_PROGS := test_stress.sh test_cpuset_prs.sh test_cpuset_v1_hp.sh TEST_GEN_FILES := wait_inotify TEST_GEN_PROGS = test_memcontrol TEST_GEN_PROGS += test_kmem diff --git a/tools/testing/selftests/cgroup/test_cpuset_v1_hp.sh b/tools/testing/selftests/cgroup/test_cpuset_v1_hp.sh new file mode 100755 index 000000000000..3f45512fb512 --- /dev/null +++ b/tools/testing/selftests/cgroup/test_cpuset_v1_hp.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# Test the special cpuset v1 hotplug case where a cpuset become empty of +# CPUs will force migration of tasks out to an ancestor. +# + +skip_test() { + echo "$1" + echo "Test SKIPPED" + exit 4 # ksft_skip +} + +[[ $(id -u) -eq 0 ]] || skip_test "Test must be run as root!" + +# Find cpuset v1 mount point +CPUSET=$(mount -t cgroup | grep cpuset | head -1 | awk -e '{print $3}') +[[ -n "$CPUSET" ]] || skip_test "cpuset v1 mount point not found!" + +# +# Create a test cpuset, put a CPU and a task there and offline that CPU +# +TDIR=test$$ +[[ -d $CPUSET/$TDIR ]] || mkdir $CPUSET/$TDIR +echo 1 > $CPUSET/$TDIR/cpuset.cpus +echo 0 > $CPUSET/$TDIR/cpuset.mems +sleep 10& +TASK=$! +echo $TASK > $CPUSET/$TDIR/tasks +NEWCS=$(cat /proc/$TASK/cpuset) +[[ $NEWCS != "/$TDIR" ]] && { + echo "Unexpected cpuset $NEWCS, test FAILED!" + exit 1 +} + +echo 0 > /sys/devices/system/cpu/cpu1/online +sleep 0.5 +echo 1 > /sys/devices/system/cpu/cpu1/online +NEWCS=$(cat /proc/$TASK/cpuset) +rmdir $CPUSET/$TDIR +[[ $NEWCS != "/" ]] && { + echo "cpuset $NEWCS, test FAILED!" + exit 1 +} +echo "Test PASSED" +exit 0 -- 2.39.3