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 D7A3634BA50 for ; Tue, 23 Jun 2026 11:51:58 +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=1782215520; cv=none; b=ozXmMXPFCpBN18dnLnaJ39hbrJQPHoQJK7cUKjgeLo6smo8H5lPbxbIz1PdThwOPZVNIvJY0/ythElOOgLikO+zl1e8vlgRiWa7PCKvuVwmk/hBLhL2CC1aJlf1aLG2n+/82sPqQuPOxCTsVFfdMSdKizDnJUdM/zKmE7Kg8xDI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782215520; c=relaxed/simple; bh=/l47Kc9yJkx+XNz925xiZzIZRoSo2GKP0MroQbjp7kQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DXaMWwLGqZJwTPLBaH/0t34G0GuhHNRJ4nvEXiqNslGaN4wYAd9n/Bo18ndqG2NlyxwCVFzVBiNPQl/fabu5IBt6cvtb09VLyqRtrvpTiA+Wz2fl5WHZbd12R6XpmOhBXRqjKPpuGYBIdgMBc4l2e9JkPlDXAeqHEntp2NGUEB4= 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=gwnl0kX3; 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="gwnl0kX3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782215517; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S74gSn64dmM2ax5iC5oLh+bId+plYMetRVPgRAIEZk0=; b=gwnl0kX3lCQ4H46m7LCjvJLApD7drFuwiWi9o/3DDoL8d6AXdD3HhQQxCGM/SW3NighlO6 ARRQ+6YFUhnPV2SXCh90JtP4EUseCaoiI3Hnk7fZk4B39pupbtBEndszbZp+0xDIjH4eZW aLma87x7EQy8blgexaTcLGWXBPjGt5Y= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-542-SM2MpXe8Pie_BkmvQbQ-aQ-1; Tue, 23 Jun 2026 07:51:56 -0400 X-MC-Unique: SM2MpXe8Pie_BkmvQbQ-aQ-1 X-Mimecast-MFC-AGG-ID: SM2MpXe8Pie_BkmvQbQ-aQ_1782215515 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 66B951955F44; Tue, 23 Jun 2026 11:51:54 +0000 (UTC) Received: from oak (unknown [10.22.80.162]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A820A1956052; Tue, 23 Jun 2026 11:51:52 +0000 (UTC) Date: Tue, 23 Jun 2026 07:51:33 -0400 From: Joe Simmons-Talbott To: Tao Cui Cc: Joe Simmons-Talbott , Tejun Heo , Johannes Weiner , Michal =?iso-8859-1?Q?Koutn=FD?= , Shuah Khan , cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] selftests/cgroup: Adjust cpu.max quota based on HZ Message-ID: <20260623115110.GA8885@oak> References: <20260622194305.601392-1-joest@redhat.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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 On Tue, Jun 23, 2026 at 01:32:08PM +0800, Tao Cui wrote: > > Hi Joe, > > One comment on the fallback: > > quota_usec = hz != -1 ? USEC_PER_SEC / hz : 1000; > > When HZ can't be determined (no CONFIG_IKCONFIG_PROC, or zcat missing), > the fallback to 1000 is the exact value that fails at low HZ — so this > doesn't actually fix such kernels. A larger fallback (e.g. 10000, the > HZ=100 equivalent) would make the tests robust regardless of whether the > config is exposed. Hi Tao Cui, Thank you for your review. I am happy to use 10000 as the fallback value. I will address this as well as the sashiko comments in v3. Thanks, Joe > > 在 2026/6/23 03:43, Joe Simmons-Talbott 写道: > > 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"); > >