From nobody Mon Apr 6 18:24:12 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 0D3AA31F9AC; Mon, 6 Apr 2026 09:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775467531; cv=none; b=BCPOmMbyrfX73417EKGvRuocsOmN8q3dGs9ZK4LXZABjvMoZa2XoCmoYTGsuCwoSsWLPREoNscA86mQM5iPy7uU7kClFOR/+TeGJAi6jwXKJXAdkeubmE6Cle3kS17E80tPrFk1rNimd6X7LvGe4j9o3H9JOZXmfy2MTlkcp5W4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775467531; c=relaxed/simple; bh=TBivPQxHmaNysTpdOmRPWDSPtZEyhE5HKiSFibmWmVM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XXuj9Sf4qW45QrR/KOMDs0hRTRNpfuaniOpkmiBg7FHD1xyoHsKxDbRxRw4IIcaIkf+dKcwL5d1rXtDFiLgZB/XBTAo3gPsLELj0xTd5jDBrMtdO2TNWWcfpzshZj5oPqNkOfKIu+hkvQpn12YiKkbe4cUpiY8YM0rZ+yGOy6cQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=nWMmeEwC; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="nWMmeEwC" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 635JItm83401733; Mon, 6 Apr 2026 09:20:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=02TqPKdDkja2MpVuM CfvhJ458T3TTNRCHN+YZuDZHV4=; b=nWMmeEwC4XC456PgD1gYYt4ejtHvvwFSD nQkVNZYCL5pYZkSyMqu+NFE5PnxBsX/CKE+Od6p9SuC/MdLyAA7YpS58vLhpqd3s JwOtLdLsJa0ZvST1ea5KM5o9rTBZa/uDfj78xZel3qhGDPaLDDWOcx7Myx+PGg4s y/ZovTlEg5YxN9FQjMAIZmYsFHW/+v7BXHEQC9DA9DL3lyk6x7c7FucMgRs1ncu6 +tv8I9CLfx3j/omeWPbCNFfy0cDqG+MFVGhh+ptIoRyWrscj32eH8BA2LU2foRPc 4iu0rHhFX4idgEAxKzgtTaO+4/bOldwzLD0jwl95/ZwVfJB32g6lw== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dar2gdnxv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Apr 2026 09:20:06 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 63661WNL022892; Mon, 6 Apr 2026 09:20:05 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dbefkc0vv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Apr 2026 09:20:05 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6369K15h45351312 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 6 Apr 2026 09:20:01 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B875020043; Mon, 6 Apr 2026 09:20:01 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 422A520040; Mon, 6 Apr 2026 09:19:58 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 6 Apr 2026 09:19:58 +0000 (GMT) From: Sayali Patil To: Andrew Morton , Shuah Khan , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Ritesh Harjani Cc: David Hildenbrand , Zi Yan , Michal Hocko , Oscar Salvador , Lorenzo Stoakes , Dev Jain , Liam.Howlett@oracle.com, linuxppc-dev@lists.ozlabs.org, Miaohe Lin , Venkat Rao Bagalkote , Sayali Patil Subject: [PATCH v4 05/15] selftests/mm: fix cgroup task placement and drop memory.current checks in hugetlb_reparenting_test.sh Date: Mon, 6 Apr 2026 14:49:24 +0530 Message-ID: <9c395e89454325ac8a3f93f191e5238214103551.1775466329.git.sayalip@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: 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-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: XsY-ZtQhlx9BN500-tgNidd91_t8gsDr X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA2MDA5MCBTYWx0ZWRfX7ThhIelpwuLz ytrnXuZ9c2L6NXvWwzrjFzlgVqi6boKVUllyPHnbzSKcmCDBWhvHgPLhh+BB1i9YMtFNBVcIpdh 8b8jE9A806hHhGlwlknSwJRKCr/KihU1DrjRgjCh3lJPeX2+ebUdS2L2KH5zkU5due2KGWmrcWY k0NDe2mqpEXoXmUaU6oMjaMIocdStzVvsurTOLWKIAvUcGuwvpeIOZhoOkD2iZ4dKJ1fK+ziJXs CVlAI8aCvuHX2OmYKwjKqjGMo8UeJ2KNsCa2nVLXOBitV2nwg4KktILuElKnD8jASIpBoi+H7Uk pI2NUUaQieMjI1UurzOKOpFQqfvC1CmY8s9tndU/K7eyw1gzwFvd2GJnLtsK1aTBJ6KjZT4+WEC xtz15vSkAHdOLs+CcYIL/4LGABzSlK75ww5pXY+oeFH5eRPlnHXEgK/LFj1Dvl3CqyRwtylCJrr 70iB61rJhTTp7IF0Gyw== X-Authority-Analysis: v=2.4 cv=b+u/I9Gx c=1 sm=1 tr=0 ts=69d37ac7 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=8tHZRRs_kCUVPtXYaVMA:9 a=O8hF6Hzn-FEA:10 X-Proofpoint-ORIG-GUID: MoOBKZyzIcJoG71OrRn6y-5oOM0A1wyO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-06_02,2026-04-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 spamscore=0 priorityscore=1501 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2604060090 Content-Type: text/plain; charset="utf-8" The test currently moves the calling shell ($$) into the target cgroup before executing write_to_hugetlbfs. This results in the shell and any intermediate allocations being charged to the cgroup, introducing noise and nondeterminism in accounting. It also requires moving the shell back to the root cgroup after execution. Spawn a helper process that joins the target cgroup and exec()'s write_to_hugetlbfs. This ensures that only the workload is accounted to the cgroup and avoids unintended charging from the shell. The test currently validates both hugetlb usage and memory.current. However, memory.current includes internal memcg allocations and per-CPU batched accounting (MEMCG_CHARGE_BATCH), which are not synchronized and can vary across systems, leading to non-deterministic results. Since hugetlb memory is accounted via hugetlb..current, memory.current is not a reliable indicator here. Drop memory.current checks and rely only on hugetlb controller statistics for stable and accurate validation. Fixes: 29750f71a9b4 ("hugetlb_cgroup: add hugetlb_cgroup reservation tests") Signed-off-by: Sayali Patil --- .../selftests/mm/hugetlb_reparenting_test.sh | 41 ++++++++----------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh b/tools= /testing/selftests/mm/hugetlb_reparenting_test.sh index 00f3f3cd8909..014201cb6427 100755 --- a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh +++ b/tools/testing/selftests/mm/hugetlb_reparenting_test.sh @@ -105,22 +105,17 @@ function assert_with_retry() { } =20 function assert_state() { - local expected_a=3D"$1" - local expected_a_hugetlb=3D"$2" - local expected_b=3D"" + local expected_a_hugetlb=3D"$1" local expected_b_hugetlb=3D"" =20 - if [ ! -z ${3:-} ] && [ ! -z ${4:-} ]; then - expected_b=3D"$3" - expected_b_hugetlb=3D"$4" + if [ ! -z ${2:-} ]; then + expected_b_hugetlb=3D"$2" fi =20 - assert_with_retry "$CGROUP_ROOT/a/memory.$usage_file" "$expected_a" assert_with_retry \ "$CGROUP_ROOT/a/hugetlb.${MB_DISPLAY}${UNIT}.$usage_file" "$expected_a_= hugetlb" =20 - if [[ -n "$expected_b" && -n "$expected_b_hugetlb" ]]; then - assert_with_retry "$CGROUP_ROOT/a/b/memory.$usage_file" "$expected_b" + if [[ -n "$expected_b_hugetlb" ]]; then assert_with_retry \ "$CGROUP_ROOT/a/b/hugetlb.${MB_DISPLAY}${UNIT}.$usage_file" "$expected_= b_hugetlb" fi @@ -154,18 +149,16 @@ write_hugetlbfs() { local size=3D"$3" =20 if [[ $cgroup2 ]]; then - echo $$ >$CGROUP_ROOT/$cgroup/cgroup.procs + cg_file=3D"$CGROUP_ROOT/$cgroup/cgroup.procs" else echo 0 >$CGROUP_ROOT/$cgroup/cpuset.mems echo 0 >$CGROUP_ROOT/$cgroup/cpuset.cpus - echo $$ >"$CGROUP_ROOT/$cgroup/tasks" - fi - ./write_to_hugetlbfs -p "$path" -s "$size" -m 0 -o - if [[ $cgroup2 ]]; then - echo $$ >$CGROUP_ROOT/cgroup.procs - else - echo $$ >"$CGROUP_ROOT/tasks" + cg_file=3D"$CGROUP_ROOT/$cgroup/tasks" fi + + # Spawn helper to join cgroup before exec to ensure correct cgroup accou= nting + bash -c "echo \$\$ > '$cg_file'; exec ./write_to_hugetlbfs -p '$path' -s= '$size' -m 0 -o" & pid=3D$! + wait "$pid" echo } =20 @@ -203,21 +196,21 @@ if [[ ! $cgroup2 ]]; then write_hugetlbfs a "$MNT"/test $size =20 echo Assert memory charged correctly for parent use. - assert_state 0 $size 0 0 + assert_state $size 0 =20 write_hugetlbfs a/b "$MNT"/test2 $size =20 echo Assert memory charged correctly for child use. - assert_state 0 $(($size * 2)) 0 $size + assert_state $(($size * 2)) $size =20 rmdir "$CGROUP_ROOT"/a/b echo Assert memory reparent correctly. - assert_state 0 $(($size * 2)) + assert_state $(($size * 2)) =20 rm -rf "$MNT"/* umount "$MNT" echo Assert memory uncharged correctly. - assert_state 0 0 + assert_state 0 =20 cleanup fi @@ -231,16 +224,16 @@ echo write write_hugetlbfs a/b "$MNT"/test2 $size =20 echo Assert memory charged correctly for child only use. -assert_state 0 $(($size)) 0 $size +assert_state $(($size)) $size =20 rmdir "$CGROUP_ROOT"/a/b echo Assert memory reparent correctly. -assert_state 0 $size +assert_state $size =20 rm -rf "$MNT"/* umount "$MNT" echo Assert memory uncharged correctly. -assert_state 0 0 +assert_state 0 =20 cleanup =20 --=20 2.52.0