From mboxrd@z Thu Jan 1 00:00:00 1970 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 EA5B1349CFE for ; Mon, 22 Jun 2026 19:43:27 +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=1782157410; cv=none; b=R6ZoaNWX4EPbq1CXOxbxX/jfBdbe5HtNWmxh1YDNv37TyYoUTxoGMTtrM73y+c8bsIX2jSHigdf1LrnLjEKYuB764QI0FRGaXiW8w0eV996L2LV3KqGnf6ldfRS1dfWPXz+bN5Gvc9zml/Zwf0mYaanRYYxccyQ3mkXHqruT+Ak= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782157410; c=relaxed/simple; bh=Kk3o03hgyW8kM5/HNI84/GHxr++YhhzFEuplQ1IujJA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tvFzZL0SbbuR2W8JytXGEfw9Tdk1w/JRpxHOA6N3QIRPXyfrPJ5D8r4+HEo90jGRogiwMdKWrU3fqwyjKgo4VE7i7HqSxbOobV+u9UurZPdDsLE8n6fWlqcnLGhOdveoo2IaE15wAaDXk85foT3TSJdzfPq+E1a6CYxw4ErOPJc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=ZpUfhsq/; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=ej27qgex; arc=none smtp.client-ip=170.10.133.124 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) header.d=redhat.com header.i=@redhat.com header.b="ZpUfhsq/"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="ej27qgex" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782157406; 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=HoMUloaAKg8ODmRbwKoyKyJ1xKK05TMqALvJhnJx1T4=; b=ZpUfhsq/s44aoCD3J6DhgDppxFblD9dNOOwnroOhYe3Bm6DnlImYnGL6m1/Euh4H50TX4S fPi5G7Ren853AMpqkenj0S61PIzzatoS2HekUn59a7krTsv6fHRiaQXfDo31DSBAHfP4Qh reuUCugQZG/B9/hgTJqcobpjOS1bxYc= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-180-vWvI79T9MQuhbDuK0XICPg-1; Mon, 22 Jun 2026 15:43:25 -0400 X-MC-Unique: vWvI79T9MQuhbDuK0XICPg-1 X-Mimecast-MFC-AGG-ID: vWvI79T9MQuhbDuK0XICPg_1782157405 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-92158791d14so341478385a.2 for ; Mon, 22 Jun 2026 12:43:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782157405; x=1782762205; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=HoMUloaAKg8ODmRbwKoyKyJ1xKK05TMqALvJhnJx1T4=; b=ej27qgextzr67ahtxU+KCPt/ouirG7ZlzjFtiWyGSlr68PvdjEJtdMHOhdQE3x6vRM TXxSVmh9+PnPZAim8d8S08n2nqs4iRRPUr1G/wmyciy4WiwzbBQhST1rOXcxqn75y63+ ekEwpwxJwzFk3+kR/ad2qiRLG6/jofrrywsnfrIvMvDjYhyWHL2JGGtVve89DcwX3RHo Swe+wtV2Ypi9VrZR4h/jm2QhYv9PRVXGbHTV5XsYBp2VmxTwCe3LRP17aydNNYUA/naH iZoiVxoi8NHIRZ19RfRSjO2BZDES+14SjkR4cTSN2veGAgcL5H3Ts3QOv7UXMUh7OHj6 yh5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782157405; x=1782762205; h=content-transfer-encoding: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; bh=HoMUloaAKg8ODmRbwKoyKyJ1xKK05TMqALvJhnJx1T4=; b=ZQ3l4skPqGeUhf5jqXOoYTn4ljF6R8NOqOCEXd89lxs+6eD+UU+8Dkv3SHidGSbT7x WyggaaAXeEvzXbWMO7lWW94GRP2cMH+msop9PunXmlVXLSIGZMuEXogqpc985DmWAtRl 3mSrf/nWD3LyueP+XN7bKrS6R6Jmd++KDmSmEvIrMlH19BMog+dd2cX6019Jx37f9OJ6 iC+pQWaRE14U/8D9AEfIugPrXLlunTHcPSA+3lXh29QveQ/dXU+3kzoyScbnZhtGZi7Q GuU0oF45Gdh+xgLG77gZrdVceB3KrhpqQjua5MzcZLhzPHojOkCcpUHdAJAKRVJIp1dQ YAZg== X-Forwarded-Encrypted: i=1; AFNElJ/yhaW4Q4IXNmBXWnZEkbFvlaQ7BODeNGUVZtQGRCDoEMF7TtFI973xlLz1kOpKheNWVyGpXwZJ8TrVXvI=@vger.kernel.org X-Gm-Message-State: AOJu0YzkKxDePMSY8AKBsNEkTnxTVfm8ai2rGdnSOr3LBDwDJXlgm5kV ur92AMRk1W3w1b17aFEJITdm/mV+xqeT2fkYhUsbrzaOscMWl4agkA24DiKtVUq0dX1wtNvQ2Cv NkPYIzLvrL08SJSFNSoqUChBRyrq79GGPmQ9D4do5Pwe5SNIjJH7QGdKFQbcebtpi3kFIod2KOg 6+ X-Gm-Gg: AfdE7cnO2cct5Rb8djhvhkhbbmdLkjQI1Yw6SCSua7HSxThWZRqEhDA8FdDDfvdlYTL TvGVgjb12/p7ks342nbRnDtC1+hEdTNKRz8loGMOKHwl2BI9xo9j/L8W5iFacHr/QPrqNbhn7fn HIWjQRAFaWJahTfAF6TjfuHLmxeh98LsNmAH/c5FJ896tF2pvs6kjRB2XspRRZctGy+albCbMR1 rX+8aebf5sfyEuXfc+6ybSTle84OTFJUHZbHYO0IvCo43aU73VZWOIamovnKkTWIZQRyI6KmWH9 Ex3Uuu2RotC3Ph8tHZJoEUEIVKy2uCNuUoMAHxjXpGbBcSaC4LR2IgYEKxECgoLgbQzqK6oA+CU yCejhLrZSZl4vGZtUHC5L9DYRBzfUu5q7Dw== X-Received: by 2002:a05:620a:2592:b0:922:92b1:9dfc with SMTP id af79cd13be357-92292b1aff4mr1606116685a.14.1782157404778; Mon, 22 Jun 2026 12:43:24 -0700 (PDT) X-Received: by 2002:a05:620a:2592:b0:922:92b1:9dfc with SMTP id af79cd13be357-92292b1aff4mr1606108685a.14.1782157404145; Mon, 22 Jun 2026 12:43:24 -0700 (PDT) Received: from oak (c-73-148-124-98.hsd1.va.comcast.net. [73.148.124.98]) by smtp.gmail.com with ESMTPSA id af79cd13be357-926000c1c39sm61506485a.26.2026.06.22.12.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2026 12:43:23 -0700 (PDT) From: Joe Simmons-Talbott To: Tejun Heo , Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Shuah Khan Cc: Joe Simmons-Talbott , cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] selftests/cgroup: Adjust cpu.max quota based on HZ Date: Mon, 22 Jun 2026 15:43:04 -0400 Message-ID: <20260622194305.601392-1-joest@redhat.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit For lower HZ values a quota of 1000us is much lower than the amount of microseconds per tick which makes the tests test_cpucg_max and test_cpugc_max_nested fail. Use the amount of microseconds per tick as the quota value. Signed-off-by: Joe Simmons-Talbott --- changes since v1: - Try checking /proc/config.gz to get the actual kernel HZ value and fallback to 1000 if the value cannot be determined. tools/testing/selftests/cgroup/test_cpu.c | 33 +++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_cpu.c b/tools/testing/selftests/cgroup/test_cpu.c index 7a40d76b9548..65e09555309f 100644 --- a/tools/testing/selftests/cgroup/test_cpu.c +++ b/tools/testing/selftests/cgroup/test_cpu.c @@ -639,6 +639,29 @@ test_cpucg_nested_weight_underprovisioned(const char *root) return run_cpucg_nested_weight_test(root, false); } +/* + * Best effort attempt to get the kernel's HZ value from the config. + * Return the HZ value if found otherwise return -1 to indicate failure. + */ +static long +_get_config_hz(void) +{ + long hz = -1; + FILE *f; + char cmd[256] = "zcat /proc/config.gz 2>/dev/null | grep '^CONFIG_HZ='"; + + f = popen(cmd, "r"); + + if (!f) + goto out; + + fscanf(f, "CONFIG_HZ=%ld", &hz); + +out: + pclose(f); + return hz; +} + /* * This test creates a cgroup with some maximum value within a period, and * verifies that a process in the cgroup is not overscheduled. @@ -646,7 +669,8 @@ test_cpucg_nested_weight_underprovisioned(const char *root) static int test_cpucg_max(const char *root) { int ret = KSFT_FAIL; - long quota_usec = 1000; + long hz = _get_config_hz(); + long quota_usec; long default_period_usec = 100000; /* cpu.max's default period */ long duration_seconds = 1; @@ -655,6 +679,8 @@ static int test_cpucg_max(const char *root) char *cpucg; char quota_buf[32]; + quota_usec = hz != -1 ? USEC_PER_SEC / hz : 1000; + snprintf(quota_buf, sizeof(quota_buf), "%ld", quota_usec); cpucg = cg_name(root, "cpucg_test"); @@ -710,7 +736,8 @@ static int test_cpucg_max(const char *root) static int test_cpucg_max_nested(const char *root) { int ret = KSFT_FAIL; - long quota_usec = 1000; + long quota_usec; + long hz = _get_config_hz(); long default_period_usec = 100000; /* cpu.max's default period */ long duration_seconds = 1; @@ -719,6 +746,8 @@ static int test_cpucg_max_nested(const char *root) char *parent, *child; char quota_buf[32]; + quota_usec = hz != -1 ? USEC_PER_SEC / hz : 1000; + snprintf(quota_buf, sizeof(quota_buf), "%ld", quota_usec); parent = cg_name(root, "cpucg_parent"); -- 2.54.0