From nobody Thu Jun 18 07:54:50 2026 Received: from out-174.mta0.migadu.com (out-174.mta0.migadu.com [91.218.175.174]) (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 E5B9C2E2663 for ; Fri, 1 May 2026 02:21:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777602085; cv=none; b=Mpa63SHgidVMlK9SVK5OjqUmevqUrU4wZZZl4ONK53PKt1kV1CS6N3zkxNcUndvEBOWIVnDDue9WBz5dypc0/PLwpJRMvlwQ7joYPYFhE2VBwBy0uV052DRupsdZ/OQmC9N9hEq7b/6IHkhIFItzlduPSVQ5RVonQk8lmo08OC4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777602085; c=relaxed/simple; bh=nWZpn+zuYeF1V9x/teR05sIUTrIzFNN47Ulj38ZPNeA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HaVZyeoFpnzAJWSCI+rYrAVtxIEpy4GveNaqH42lwQxaVLrfu4awGPRbEpprkrO2zshxLOrQYiFv+DEJtsWj7U78tZmeS+rTXf4iq+sUrleD+Qr52oeyjFzw/4W3NN/wvk/58bmoG8+nEFoeDFPzKdq4gMVpOhVu+n4T55kHEww= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=pFLCKW17; arc=none smtp.client-ip=91.218.175.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="pFLCKW17" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1777602080; 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=NBtGLtjRvE4baHy0eRK4mwql+K6PPxqXdGnpl9fPIQ0=; b=pFLCKW176QPS1YiBgSYn6EPexE20q/Nhgy7otY2RejVxCOOgcgct00JRvsqeP7snox6NOo L0jeV/ZbzDieXaq2pKtdp48NdkClEIMNtOl1U0wUHV6rLg5k7Gc6uwrAZwD1WqMD4u2qf8 yRgg/5V2jD5mHAAOUVvV1ymCYwLzyc0= From: Li Wang To: akpm@linux-foundation.org, hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, tj@kernel.org, mkoutny@suse.com, shuah@kernel.org Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Waiman Long , Christoph Lameter , Shakeel Butt , Vlastimil Babka Subject: [PATCH v2 1/2] selftests/cgroup: Fix hardcoded page size in test_percpu_basic Date: Fri, 1 May 2026 10:20:57 +0800 Message-ID: <20260501022058.18024-2-li.wang@linux.dev> In-Reply-To: <20260501022058.18024-1-li.wang@linux.dev> References: <20260501022058.18024-1-li.wang@linux.dev> 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-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" MAX_VMSTAT_ERROR uses a hardcoded page size of 4096, which assumes 4K pages. This causes test_percpu_basic to fail on systems where the kernel is configured with a larger page size, such as aarch64 systems using 16K or 64K pages, where the maximum permissible discrepancy between memory.current and percpu charges is proportionally larger. Replace the hardcoded 4096 with sysconf(_SC_PAGESIZE) to correctly derive the page size at runtime regardless of the underlying architecture or kernel configuration. Signed-off-by: Li Wang Cc: Waiman Long Cc: Christoph Lameter Cc: Johannes Weiner Cc: Michal Hocko Cc: Shakeel Butt Cc: Tejun Heo Cc: Vlastimil Babka Acked-by: Waiman Long Reviewed-by: Sayali Patil --- tools/testing/selftests/cgroup/test_kmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/cgroup/test_kmem.c b/tools/testing/sel= ftests/cgroup/test_kmem.c index eeabd34bf08..249d7911306 100644 --- a/tools/testing/selftests/cgroup/test_kmem.c +++ b/tools/testing/selftests/cgroup/test_kmem.c @@ -24,7 +24,7 @@ * the maximum discrepancy between charge and vmstat entries is number * of cpus multiplied by 64 pages. */ -#define MAX_VMSTAT_ERROR (4096 * 64 * get_nprocs()) +#define MAX_VMSTAT_ERROR (sysconf(_SC_PAGESIZE) * 64 * get_nprocs()) =20 #define KMEM_DEAD_WAIT_RETRIES 80 =20 --=20 2.54.0 From nobody Thu Jun 18 07:54:50 2026 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 DEC272EA732 for ; Fri, 1 May 2026 02:21:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777602090; cv=none; b=faIrOgaoXMdKz3fOzB0tclrcooap0uoFPdKGMp79SBzsRhaFK9lB+mxAvOfGCm4y6Eckr7L6ZD94r9F8gO9RMxiJyXkMmfglMsUuP/pD7D2BYbm4/wYOP0QkBiFih2qI87Jr9y1+JBXLr4dbT16tg2VAio8aUce5MBvIBvt/eY0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777602090; c=relaxed/simple; bh=85yqVfc9aiA3OqKgXtUAbwLO/KOrXwWM03KlTyAOUow=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hJXrZTE0HG4smH8Xc/xqhZi5J8RsrokUNhuvviE5b4F/m4sTiczpzLd4ZD0qOHCdbKwqDWGjkWGLqykg18MxnR9qQ//8+svYKS/GEEQbBGGOTtevr2OmSUJa153wSWFSbjTdxjgh7l2GPr1aYnXTYHh1ue0r3SXLAYZvNUym9Ro= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=vzRjGgtu; arc=none smtp.client-ip=91.218.175.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vzRjGgtu" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1777602086; 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=O2N4+x1Sn+wQRdLiVZolUUHuNzDmAcEVcLCFnksgkqM=; b=vzRjGgtuFJ1JAtGsc21WhF7K4u4Px7oOGVVXWwhcVFAaoFiF4WrwGixClRcwplk3TT/yOA YKlrafWQIZddgGjYIzxPPtgfc9+svL48E8wXWBqVqG+/JNkB9NSt/0BLp+9ktmyYGf4BR0 //dM0MNYWNijWA4/VQynOLmUvtjXGQg= From: Li Wang To: akpm@linux-foundation.org, hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, tj@kernel.org, mkoutny@suse.com, shuah@kernel.org Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Waiman Long , Christoph Lameter , Shakeel Butt , Vlastimil Babka Subject: [PATCH v2 2/2] selftests/cgroup: include slab in test_percpu_basic memory check Date: Fri, 1 May 2026 10:20:58 +0800 Message-ID: <20260501022058.18024-3-li.wang@linux.dev> In-Reply-To: <20260501022058.18024-1-li.wang@linux.dev> References: <20260501022058.18024-1-li.wang@linux.dev> 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-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" test_percpu_basic() currently compares memory.current against only memory.stat:percpu after creating 1000 child cgroups. Observed failure: #./test_kmem ok 1 test_kmem_basic ok 2 test_kmem_memcg_deletion ok 3 test_kmem_proc_kpagecgroup ok 4 test_kmem_kernel_stacks ok 5 test_kmem_dead_cgroups memory.current 11530240 percpu 8440000 not ok 6 test_percpu_basic That assumption is too strict: child cgroup creation also allocates slab-backed metadata, so memory.current is expected to be larger than percpu alone. One visible path is: cgroup_mkdir() cgroup_create() cgroup_addrm_file() cgroup_add_file() __kernfs_create_file() __kernfs_new_node() kmem_cache_zalloc() These kernfs allocations are charged as slab and show up in memory.stat:slab. Update the check to compare memory.current against (percpu + slab) within MAX_VMSTAT_ERROR, and print slab/delta in the failure message to improve diagnostics. Signed-off-by: Li Wang Cc: Waiman Long Cc: Christoph Lameter Cc: Johannes Weiner Cc: Michal Hocko Cc: Shakeel Butt Cc: Tejun Heo Cc: Vlastimil Babka Reviewed-by: Waiman Long --- tools/testing/selftests/cgroup/test_kmem.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_kmem.c b/tools/testing/sel= ftests/cgroup/test_kmem.c index 249d7911306..4b579969889 100644 --- a/tools/testing/selftests/cgroup/test_kmem.c +++ b/tools/testing/selftests/cgroup/test_kmem.c @@ -353,7 +353,7 @@ static int test_percpu_basic(const char *root) { int ret =3D KSFT_FAIL; char *parent, *child; - long current, percpu; + long current, percpu, slab; int i; =20 parent =3D cg_name(root, "percpu_basic_test"); @@ -379,13 +379,14 @@ static int test_percpu_basic(const char *root) =20 current =3D cg_read_long(parent, "memory.current"); percpu =3D cg_read_key_long(parent, "memory.stat", "percpu "); + slab =3D cg_read_key_long(parent, "memory.stat", "slab "); =20 - if (current > 0 && percpu > 0 && labs(current - percpu) < - MAX_VMSTAT_ERROR) + if (current > 0 && percpu > 0 && slab >=3D 0 && + labs(current - (percpu + slab)) < MAX_VMSTAT_ERROR) ret =3D KSFT_PASS; else - printf("memory.current %ld\npercpu %ld\n", - current, percpu); + printf("memory.current %ld\npercpu %ld\nslab %ld\ndelta %ld\n", + current, percpu, slab, current - (percpu + slab)); =20 cleanup_children: for (i =3D 0; i < 1000; i++) { --=20 2.54.0