From nobody Mon Apr 6 11:53:28 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 C13FF38E5C7 for ; Thu, 19 Mar 2026 17:39:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773941957; cv=none; b=TxZNA2xj+Hlefqy7CcVZRXmtyKoXAO5VqnsqkvFz+W6CvyQXm0wl3ElXqM07IhxwSVr5qgCptAMNFeS8W4a6c1NI21JgT4jVyxhF958swP8V4UtQcCcnvJb/q4i5Y1Lza5B0MyRWuI8zFW2NRHG3ouxHenK9Qhq1UCobskJ85tk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773941957; c=relaxed/simple; bh=1YF3Po/hWcN908df/JjlPnlSCsp5XMq/OPhqEQrLq8U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qr7/AZ04tjO0fhKTYEKCGQiK1k4ICIJNfR8iUIXpqem7gL+JQgm0bdbMtMQsgDq2Et2aB3HEpDQdoIk7zHd/pVct9tagthZfel27zZG73HU8mmmR9SqSddwsnKrsr7Xpgo3+cyyGPySOHnJJjMS7MkqLYcm101Wq/W7zHdJZiPg= 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=OOO4ZMVF; arc=none smtp.client-ip=170.10.129.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="OOO4ZMVF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773941948; 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=dNJ6Lq8/T1XPjKqwxrWp5F2Bbd2jRHO9QNryMAsqUQU=; b=OOO4ZMVFhScpPzOoYSLfj5bt6vGenhlvUgWfQxjfJFZv017K5Yeju1eoeVBigYZIWimkc/ GOlCONI0Z19z89z1VTvYi2Zk+AHs9siBon2DXVomLrSypIfS1pe7Nt4S6PPFF9tmHvPuAX eCiwsuI7N4qUoTSgpWqy5hydDF54W1E= Received: from mx-prod-mc-03.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-687-31Ev_X7TNdGagwe5I4LhcA-1; Thu, 19 Mar 2026 13:39:05 -0400 X-MC-Unique: 31Ev_X7TNdGagwe5I4LhcA-1 X-Mimecast-MFC-AGG-ID: 31Ev_X7TNdGagwe5I4LhcA_1773941942 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8A0481944F05; Thu, 19 Mar 2026 17:39:02 +0000 (UTC) Received: from llong-thinkpadp16vgen1.westford.csb (unknown [10.22.80.194]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7068D30001A1; Thu, 19 Mar 2026 17:38:59 +0000 (UTC) From: Waiman Long To: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Tejun Heo , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Shuah Khan , Mike Rapoport Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Sean Christopherson , James Houghton , Sebastian Chlad , Guopeng Zhang , Li Wang , Waiman Long Subject: [PATCH 4/7] selftests: memcg: Increase error tolerance in accordance with page size Date: Thu, 19 Mar 2026 13:37:49 -0400 Message-ID: <20260319173752.1472864-5-longman@redhat.com> In-Reply-To: <20260319173752.1472864-1-longman@redhat.com> References: <20260319173752.1472864-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: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" It was found that some of the tests in test_memcontrol can fail more readily if system page size is larger than 4k. It is because the actual memory.current value deviates more from the expected value with larger page size. To avoid this failure, the error tolerance is now increased in accordance to the current system page size value. The page size scale factor is set to 2 for 64k page and 1 for 16k page. Changes are made in alloc_pagecache_max_30M(), test_memcg_protection() and alloc_anon_50M_check_swap() to increase the error tolerance for memory.current for larger page size. The current set of values are chosen to ensure that the relevant test_memcontrol tests no longer have any test failure in a 100 repeated run of test_memcontrol with a 4k/16k/64k page size kernels on an arm64 system. Signed-off-by: Waiman Long --- .../cgroup/lib/include/cgroup_util.h | 1 + .../selftests/cgroup/test_memcontrol.c | 23 ++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/cgroup/lib/include/cgroup_util.h b/too= ls/testing/selftests/cgroup/lib/include/cgroup_util.h index 77f386dab5e8..c25228a78b8b 100644 --- a/tools/testing/selftests/cgroup/lib/include/cgroup_util.h +++ b/tools/testing/selftests/cgroup/lib/include/cgroup_util.h @@ -6,6 +6,7 @@ #define PAGE_SIZE 4096 #endif =20 +#define KB(x) (x << 10) #define MB(x) (x << 20) =20 #define USEC_PER_SEC 1000000L diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testi= ng/selftests/cgroup/test_memcontrol.c index 3cc8a432be91..2c3a838536ae 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -26,6 +26,7 @@ static bool has_localevents; static bool has_recursiveprot; static int page_size; +static int pscale_factor; /* Page size scale factor */ =20 int get_temp_fd(void) { @@ -571,16 +572,17 @@ static int test_memcg_protection(const char *root, bo= ol min) if (cg_run(parent[2], alloc_anon, (void *)MB(148))) goto cleanup; =20 - if (!values_close(cg_read_long(parent[1], "memory.current"), MB(50), 3)) + if (!values_close(cg_read_long(parent[1], "memory.current"), MB(50), + 3 + (min ? 0 : 4) * pscale_factor)) goto cleanup; =20 for (i =3D 0; i < ARRAY_SIZE(children); i++) c[i] =3D cg_read_long(children[i], "memory.current"); =20 - if (!values_close(c[0], MB(29), 15)) + if (!values_close(c[0], MB(29), 15 + 3 * pscale_factor)) goto cleanup; =20 - if (!values_close(c[1], MB(21), 20)) + if (!values_close(c[1], MB(21), 20 + pscale_factor)) goto cleanup; =20 if (c[3] !=3D 0) @@ -596,7 +598,8 @@ static int test_memcg_protection(const char *root, bool= min) } =20 current =3D min ? MB(50) : MB(30); - if (!values_close(cg_read_long(parent[1], "memory.current"), current, 3)) + if (!values_close(cg_read_long(parent[1], "memory.current"), current, + 9 + (min ? 0 : 6) * pscale_factor)) goto cleanup; =20 if (!reclaim_until(children[0], MB(10))) @@ -684,7 +687,7 @@ static int alloc_pagecache_max_30M(const char *cgroup, = void *arg) goto cleanup; =20 current =3D cg_read_long(cgroup, "memory.current"); - if (!values_close(current, MB(30), 5)) + if (!values_close(current, MB(30), 5 + (pscale_factor ? 2 : 0))) goto cleanup; =20 ret =3D 0; @@ -1004,7 +1007,7 @@ static int alloc_anon_50M_check_swap(const char *cgro= up, void *arg) *ptr =3D 0; =20 mem_current =3D cg_read_long(cgroup, "memory.current"); - if (!mem_current || !values_close(mem_current, mem_max, 3)) + if (!mem_current || !values_close(mem_current, mem_max, 6 + pscale_factor= )) goto cleanup; =20 swap_current =3D cg_read_long(cgroup, "memory.swap.current"); @@ -1681,6 +1684,14 @@ int main(int argc, char **argv) int i, proc_status; =20 page_size =3D sysconf(_SC_PAGE_SIZE); + /* + * It is found that the actual memory.current value can deviate more + * from the expected value with larger page size. So error tolerance + * will have to be increased a bit more for larger page size. + */ + if (page_size > KB(4)) + pscale_factor =3D (page_size >=3D KB(64)) ? 2 : 1; + ksft_print_header(); ksft_set_plan(ARRAY_SIZE(tests)); if (cg_find_unified_root(root, sizeof(root), NULL)) --=20 2.53.0