From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C70CC3600C for ; Tue, 8 Apr 2025 03:46:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A7736B0022; Mon, 7 Apr 2025 23:46:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 62F026B0026; Mon, 7 Apr 2025 23:46:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A9826B0028; Mon, 7 Apr 2025 23:46:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2A8BE6B0022 for ; Mon, 7 Apr 2025 23:46:18 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C40D481A63 for ; Tue, 8 Apr 2025 03:46:17 +0000 (UTC) X-FDA: 83309488794.14.1F681E3 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf15.hostedemail.com (Postfix) with ESMTP id 927ACA0003 for ; Tue, 8 Apr 2025 03:46:15 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="T2/M0gA/"; spf=pass (imf15.hostedemail.com: domain of donettom@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=donettom@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744083975; h=from:from:sender: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:dkim-signature; bh=BUJUFaB36sJxqSLzap8VGtMLtvbnpP+bEYqH+PwFuIU=; b=ip11M5ADGI84yeUrkyhn6+jeosuQn7O5FwKYVGQvPqd7dbNvJQ4wBN8s+l+fXZX92h6zBU Kk+Dy3tcoK9Vz8n7pYftlloifB8Hr05e4ELxs5wowW3zcjQe7nZ01HPMAqtgQlKsCsr6zK gQpP0ddoQC1Z6To9ktS93N68s6FhzzA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744083975; a=rsa-sha256; cv=none; b=Ls+lO8sS4oc6jvekC35dEmfbzBdbmQvhENWSPOVuqWoqnt1/xsU6buhmj5d7WSm7wOQT03 w4gikWJSB4WPVjkvFcbh0bex/COwV8i31hMFvL7aztY78KMQWHWt+UWt+Z23YVSOEThH2n vElRIwYEtsOHUviC/Oia0wylxP4MJ68= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="T2/M0gA/"; spf=pass (imf15.hostedemail.com: domain of donettom@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=donettom@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 537JVObL000328; Tue, 8 Apr 2025 03:46:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=BUJUFa B36sJxqSLzap8VGtMLtvbnpP+bEYqH+PwFuIU=; b=T2/M0gA/otPuCIKVC8Hbps AOoK1LvA1Rtbd/l8XbspAWP7G8K3km9g6nrOPpjJnlv+Bc0JOVrzgFJUR8jCGFvm ShjxyIou/TQEyGQ6+GTqDM9CK6fJo/jEwt1okJCmYAt+pJqddKpQqTUmqsDzKV/6 OQYnBN37cvu0+az1u7+WLhQrUf8GDBIAxnD3nZiQKnGs+keY0NQ6l1mSAm++8DBq nHKJkayt4Xyr+NR97E5s95iapm6KvfGjVQ/KJih4PCriX6BbeHE/x7EgHZE/HfMB kWf0XDGoHjS4XT6YG2dA0oEenzs9svSqeeGc+h+QI/OJx2G8eSC+qx9YSY9TiTsg == Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 45ver7bwmm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Apr 2025 03:46:09 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 53820ohr024583; Tue, 8 Apr 2025 03:46:08 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 45ueut9388-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Apr 2025 03:46:08 +0000 Received: from smtpav06.wdc07v.mail.ibm.com (smtpav06.wdc07v.mail.ibm.com [10.39.53.233]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5383k8iD4588242 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Apr 2025 03:46:08 GMT Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 080BD58056; Tue, 8 Apr 2025 03:46:08 +0000 (GMT) Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9A7495804E; Tue, 8 Apr 2025 03:46:04 +0000 (GMT) Received: from [9.109.245.113] (unknown [9.109.245.113]) by smtpav06.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 8 Apr 2025 03:46:04 +0000 (GMT) Message-ID: Date: Tue, 8 Apr 2025 09:16:02 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] selftest/mm: Make hugetlb_reparenting_test tolerant to async reparenting To: Li Wang , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Waiman Long , Anshuman Khandual , Dev Jain , "Kirill A. Shuemov" , Shuah Khan References: <20250407084201.74492-1-liwang@redhat.com> Content-Language: en-US From: Donet Tom In-Reply-To: <20250407084201.74492-1-liwang@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 8trCQhXusk4TAQQ4rTfhU88qiJ9Io20U X-Proofpoint-GUID: 8trCQhXusk4TAQQ4rTfhU88qiJ9Io20U X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-08_01,2025-04-07_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 mlxlogscore=999 clxscore=1011 impostorscore=0 adultscore=0 mlxscore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2502280000 definitions=main-2504080022 X-Stat-Signature: b78xhj7p3n3ugt3iacfk68jmkfcepes8 X-Rspam-User: X-Rspamd-Queue-Id: 927ACA0003 X-Rspamd-Server: rspam08 X-HE-Tag: 1744083975-441087 X-HE-Meta: U2FsdGVkX1/kHiThyfXf7p5hW0loTnIihlgsSoPpLg4EcuxDBbwDwBFpOf3KPajtSR+xbNQjpEUquAtFXXyEQ/WU/f5GdL1mbbXGftnNwYKhIJxVaTaCWQZwzor+vhP3zgd6eKMGAliho6I7clu3hxxlMyGhKtHw8SyVmz6ki/5xDUCyeTo5+46Cszz+Q4SeAl5i3d2dzpXUxUmI4eWiXFE5ulaE9YMWtO2/vo1s6qevELHdKD2by+AkpfJC1zxKIbmRMEBpZvzWRfkgbS+7Rfqr2Vse3YkhuoTI1kg+zxxJqSIZLRxvwv34Ve5E9Wu0nfJNfGwgM5vJGFO+Rl/JVdJRnNHnGkUjuxmsz1cQneuxg6EIPaZES44eVeVFTWKF193bxVHS2cdvOEgr2aNZeDjpRM8faYpiDZT4EkLw9NnQU1tPQ7NWEX6Ec5kpXCsYhIV5HD7LX4k7FyIwRdio5+a857nB2/v7IMnZwfyB89pc/oHmDjkvKpW2+Qsrk2ZEHIy6GL02cFJsGjlhSEGi0YsiMcigdbJ494BroIdGjbOlPAgPJcLmZM11v37+OZzlqw6VvzxPaIceDp0mDKLejNgjS1Ix7t0WjbQ2qw8aDEax4BHvAgIjoP/o+8RSeY2giXk2yEd95lcUALdyy4tZ0ez0v0I2IHKG85vJKfaIGEzh47ph4/tdY825j8IeCJ0drfB6J/dlHE130x5dwINsrgm3pk+1qybtfAH4HZnGfuW1JaC+871uENgoqTVTSBPqCRiASstNMgRJFgmBryGL/wlfm2ucXI6AYBtz8q5Sr8RTtvsLWi6n4n5TzhPGVY9AGnbPEDHKe+MppxRsyc/Mo7FJNeyBnVG0B+zK9ZO6CO5U4Xz2fUr6tBTncCX7owJFkDMjoFeJMv5ho+lNzyflFBDPD9B1Q+kXALXEqnp/FeLmmQm5hHpAJLdw3uOlRbkjM3zRXs8fTWv/xR2pOp5 meTbjb4F wsLM7bdK+DNoDjxcBFz5w6UUlNBMz85nCSaLdsq7wNDCERzZxiGhIMhNuN7ye7w9izYt6 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 4/7/25 2:12 PM, Li Wang wrote: > In cgroup v2, memory and hugetlb usage reparenting is asynchronous. > This can cause test flakiness when immediately asserting usage after > deleting a child cgroup. To address this, add a helper function > `assert_with_retry()` that checks usage values with a timeout-based retry. > This improves test stability without relying on fixed sleep delays. > > Also bump up the tolerance size to 7MB. > > To avoid False Positives: > ... > # Assert memory charged correctly for child only use. > # actual a = 11 MB > # expected a = 0 MB > # fail > # cleanup > # [FAIL] > not ok 11 hugetlb_reparenting_test.sh -cgroup-v2 # exit=1 > # 0 > # SUMMARY: PASS=10 SKIP=0 FAIL=1 I was also seeing this failure. I have tested this patch on my powerPC setup and it is passing now. ./hugetlb_reparenting_test.sh -cgroup-v2 cleanup Test charge, rmdir, uncharge mkdir write Writing to this path: /mnt/huge/test Writing this size: 52428800 Populating. Not writing to memory. Using method=0 Shared mapping. RESERVE mapping. Allocating using HUGETLBFS. rmdir uncharge cleanup done Test child only hugetlb usage setup write Writing to this path: /mnt/huge/test2 Writing this size: 52428800 Populating. Not writing to memory. Using method=0 Shared mapping. RESERVE mapping. Allocating using HUGETLBFS. Assert memory charged correctly for child only use. actual = 10 MB expected = 0 MB cleanup Feel free to add Tested-by Donet Tom > > Signed-off-by: Li Wang > Cc: Waiman Long > Cc: Anshuman Khandual > Cc: Dev Jain > Cc: Kirill A. Shuemov > Cc: Shuah Khan > --- > .../selftests/mm/hugetlb_reparenting_test.sh | 96 ++++++++----------- > 1 file changed, 41 insertions(+), 55 deletions(-) > > diff --git a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh b/tools/testing/selftests/mm/hugetlb_reparenting_test.sh > index 11f9bbe7dc22..1c172c6999f4 100755 > --- a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh > +++ b/tools/testing/selftests/mm/hugetlb_reparenting_test.sh > @@ -36,7 +36,7 @@ else > do_umount=1 > fi > fi > -MNT='/mnt/huge/' > +MNT='/mnt/huge' > > function get_machine_hugepage_size() { > hpz=$(grep -i hugepagesize /proc/meminfo) > @@ -60,6 +60,41 @@ function cleanup() { > set -e > } > > +function assert_with_retry() { > + local actual_path="$1" > + local expected="$2" > + local tolerance=$((7 * 1024 * 1024)) > + local timeout=20 > + local interval=1 > + local start_time > + local now > + local elapsed > + local actual > + > + start_time=$(date +%s) > + > + while true; do > + actual="$(cat "$actual_path")" > + > + if [[ $actual -ge $(($expected - $tolerance)) ]] && > + [[ $actual -le $(($expected + $tolerance)) ]]; then > + return 0 > + fi > + > + now=$(date +%s) > + elapsed=$((now - start_time)) > + > + if [[ $elapsed -ge $timeout ]]; then > + echo "actual = $((${actual%% *} / 1024 / 1024)) MB" > + echo "expected = $((${expected%% *} / 1024 / 1024)) MB" > + cleanup > + exit 1 > + fi > + > + sleep $interval > + done > +} > + > function assert_state() { > local expected_a="$1" > local expected_a_hugetlb="$2" > @@ -70,58 +105,13 @@ function assert_state() { > expected_b="$3" > expected_b_hugetlb="$4" > fi > - local tolerance=$((5 * 1024 * 1024)) > - > - local actual_a > - actual_a="$(cat "$CGROUP_ROOT"/a/memory.$usage_file)" > - if [[ $actual_a -lt $(($expected_a - $tolerance)) ]] || > - [[ $actual_a -gt $(($expected_a + $tolerance)) ]]; then > - echo actual a = $((${actual_a%% *} / 1024 / 1024)) MB > - echo expected a = $((${expected_a%% *} / 1024 / 1024)) MB > - echo fail > - > - cleanup > - exit 1 > - fi > - > - local actual_a_hugetlb > - actual_a_hugetlb="$(cat "$CGROUP_ROOT"/a/hugetlb.${MB}MB.$usage_file)" > - if [[ $actual_a_hugetlb -lt $(($expected_a_hugetlb - $tolerance)) ]] || > - [[ $actual_a_hugetlb -gt $(($expected_a_hugetlb + $tolerance)) ]]; then > - echo actual a hugetlb = $((${actual_a_hugetlb%% *} / 1024 / 1024)) MB > - echo expected a hugetlb = $((${expected_a_hugetlb%% *} / 1024 / 1024)) MB > - echo fail > - > - cleanup > - exit 1 > - fi > - > - if [[ -z "$expected_b" || -z "$expected_b_hugetlb" ]]; then > - return > - fi > - > - local actual_b > - actual_b="$(cat "$CGROUP_ROOT"/a/b/memory.$usage_file)" > - if [[ $actual_b -lt $(($expected_b - $tolerance)) ]] || > - [[ $actual_b -gt $(($expected_b + $tolerance)) ]]; then > - echo actual b = $((${actual_b%% *} / 1024 / 1024)) MB > - echo expected b = $((${expected_b%% *} / 1024 / 1024)) MB > - echo fail > - > - cleanup > - exit 1 > - fi > > - local actual_b_hugetlb > - actual_b_hugetlb="$(cat "$CGROUP_ROOT"/a/b/hugetlb.${MB}MB.$usage_file)" > - if [[ $actual_b_hugetlb -lt $(($expected_b_hugetlb - $tolerance)) ]] || > - [[ $actual_b_hugetlb -gt $(($expected_b_hugetlb + $tolerance)) ]]; then > - echo actual b hugetlb = $((${actual_b_hugetlb%% *} / 1024 / 1024)) MB > - echo expected b hugetlb = $((${expected_b_hugetlb%% *} / 1024 / 1024)) MB > - echo fail > + assert_with_retry "$CGROUP_ROOT/a/memory.$usage_file" "$expected_a" > + assert_with_retry "$CGROUP_ROOT/a/hugetlb.${MB}MB.$usage_file" "$expected_a_hugetlb" > > - cleanup > - exit 1 > + if [[ -n "$expected_b" && -n "$expected_b_hugetlb" ]]; then > + assert_with_retry "$CGROUP_ROOT/a/b/memory.$usage_file" "$expected_b" > + assert_with_retry "$CGROUP_ROOT/a/b/hugetlb.${MB}MB.$usage_file" "$expected_b_hugetlb" > fi > } > > @@ -174,7 +164,6 @@ size=$((${MB} * 1024 * 1024 * 25)) # 50MB = 25 * 2MB hugepages. > > cleanup > > -echo > echo > echo Test charge, rmdir, uncharge > setup > @@ -195,7 +184,6 @@ cleanup > > echo done > echo > -echo > if [[ ! $cgroup2 ]]; then > echo "Test parent and child hugetlb usage" > setup > @@ -212,7 +200,6 @@ if [[ ! $cgroup2 ]]; then > assert_state 0 $(($size * 2)) 0 $size > > rmdir "$CGROUP_ROOT"/a/b > - sleep 5 > echo Assert memory reparent correctly. > assert_state 0 $(($size * 2)) > > @@ -224,7 +211,6 @@ if [[ ! $cgroup2 ]]; then > cleanup > fi > > -echo > echo > echo "Test child only hugetlb usage" > echo setup