From nobody Sun May 24 21:36:40 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 BA316221F20; Thu, 21 May 2026 06:39:24 +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=1779345567; cv=none; b=X77q9Fg7vb7EvIpV9In3nhrVnchLHc1NZkxfGqSNAwDswT15OxH9VnnWwPYB4WjDAf0je+nkMp+h0xDw36o+W7YenHAvdv2n9lErgsllHAXIdAzN8swL/xBFEp/j/DHbnaTdcmlyHWUgzmhYIvCdqwAAUkkg11SSR90+XiY89f4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779345567; c=relaxed/simple; bh=IN5L6ThafTi9EFIA+WnMTzgU9QH9jsywJqx+izYz7G0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bNTRQ77Nr/I7zQTlv6SJzYkSOonuMq2aFTt5FBymzXQTjAQVOpo9wD5foH8TIBgqrVIg1a8dHsBkUqK7scYESqXge5PnuBkSiEjif2ibKkdpJCPxy/HJM7ZTzM5sW3MiHzrJbIoGj+0LxIGXln1Sot5wfIRUt8m/GztWIBEDwR4= 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=gKtXGcef; 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="gKtXGcef" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64KE1IB83442044; Thu, 21 May 2026 06:34:00 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=w2yZGEA3lho6ftsax Vq+LrAKP95Gff3FxI3cY3B/TaU=; b=gKtXGcef/sC4+x8bGU14KBnEmqDoi9P7O CsnM9Qkq0D3J27qIswyWNk2wfmNu5qKhB6rBGr6ij84VkBO6i1Hz1r8vgRVKyjl9 3IFqzzMu0iDedPgv8ut8NhUZj/1VhpE5MzgcmSvf6iuiOjN7nCV6xoHbFxjLF9Gl /q2lueaE8XxJo1PSzi9R2A2aQsRMJ4QxTgHFSofDwnejD+IT+r14qIaBQ6ta88ql XMa5WqmbMaaaIIRLBYovvmSKDWDIq6kSYtWAdGazLyndlNZ0+mPLGYiq3UChwX5w n5OeRO2CcA/GUa6C/9rVhQANziKzELSWhQXcZ4sHMROVsZZQrGFyQ== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e6hawcbr3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:33:59 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64L6O8VP020623; Thu, 21 May 2026 06:33:58 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e754gjjam-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:33:58 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64L6Xtrq24117612 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 May 2026 06:33:55 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 16CD02004B; Thu, 21 May 2026 06:33:55 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6B02A20040; Thu, 21 May 2026 06:33:48 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 21 May 2026 06:33:48 +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 v7 01/13] selftests/mm: restore default nr_hugepages value via exit trap in charge_reserved_hugetlb.sh Date: Thu, 21 May 2026 12:03:27 +0530 Message-ID: <5b8fbb29cd6ceffe6752e0af104f60cec072aa10.1779296493.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-Spam-Details-Enc: AW1haW4tMjYwNTIxMDA1NyBTYWx0ZWRfX7BiSBC/BH+q3 WNHXD3L9QBm4oBcc1dXRLOme/yBryy4Phu4Dk2NsjQvBHFPkfv0sNsRKStSd7gmvGGDyKK0fTOk JTdM/sSlmPpDGTBCiIT2v/y5D3Hn/0xv/fBFK1ShO669pnME6mCL3u8JKaocq5UQojKUf1CRHJ2 alyPxsBf5qGcgIJl83tz2UukoonXdqG7WV4KABVtiY3gHvxKOPVmDB9OOnMfl4j9/Vxv4RMaphK VjX4/dVwJxWp4L4OoQPgLqaxFdEw6xPrwD1a1d65+Hwqub5ELbafR4ooiUQUf5Dei/ENWN9gTGs TudQou9qEBE8iMbhb8BENJUpytRoG/DcTFLJRDg8wwr4aWxmUeb4REALljJ26bKURBUISsNmN32 8iil/F1vvIU1UJOh28RdZ6q1C2qfd6zUGCeUlh5DGPnXnTlXUfK791pOzxMEtC85aNOmmgNl9Q4 i19gGqlJta/Mc5zNZrg== X-Authority-Analysis: v=2.4 cv=Np/htcdJ c=1 sm=1 tr=0 ts=6a0ea758 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=Ikd4Dj_1AAAA:8 a=VnNF1IyMAAAA:8 a=vtM6K80SjIFNW2yxelUA:9 X-Proofpoint-ORIG-GUID: V0oBOkychhHPDJnWgUrLS-jFsIr72PlK X-Proofpoint-GUID: scVNd80hmPse-gtev7kSfVtikji2rMeK 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-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210057 Content-Type: text/plain; charset="utf-8" cleanup() resets nr_hugepages to 0 on every invocation, while the test reconfigures it again in the next iteration. This leads to repeated allocation and freeing of large numbers of hugepages, especially when the original value is high. Additionally, with set -e, failures in earlier cleanup steps (e.g., rmdir or umount returning EBUSY while background activity is still ongoing) can cause the script to exit before restoring the original value, leaving the system in a modified state. Introduce a trap on EXIT, INT, and TERM to restore the original nr_hugepages value once at script termination. This avoids unnecessary allocation churn and ensures the original value is reliably restored on all exit paths. Fixes: 7d695b1c3695b ("selftests/mm: save and restore nr_hugepages value") Acked-by: Zi Yan Tested-by: Venkat Rao Bagalkote Signed-off-by: Sayali Patil --- tools/testing/selftests/mm/charge_reserved_hugetlb.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh b/tools/= testing/selftests/mm/charge_reserved_hugetlb.sh index 44f4e703deb9..e1945901fd20 100755 --- a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh +++ b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh @@ -17,6 +17,7 @@ if ! command -v killall >/dev/null 2>&1; then fi =20 nr_hugepgs=3D$(cat /proc/sys/vm/nr_hugepages) +trap 'echo "$nr_hugepgs" > /proc/sys/vm/nr_hugepages' EXIT INT TERM =20 fault_limit_file=3Dlimit_in_bytes reservation_limit_file=3Drsvd.limit_in_bytes @@ -70,7 +71,6 @@ function cleanup() { if [[ -e $cgroup_path/hugetlb_cgroup_test2 ]]; then rmdir $cgroup_path/hugetlb_cgroup_test2 fi - echo 0 >/proc/sys/vm/nr_hugepages echo CLEANUP DONE } =20 @@ -599,4 +599,3 @@ if [[ $do_umount ]]; then rmdir $cgroup_path fi =20 -echo "$nr_hugepgs" > /proc/sys/vm/nr_hugepages --=20 2.52.0 From nobody Sun May 24 21:36:40 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 D44FA221F20; Thu, 21 May 2026 06:34:35 +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=1779345277; cv=none; b=j+IdA89zmP4XyXYlc7muy1BtNBJE54X9NZZcJ4FokRbbolYWHUbZZ+WzosxIjFnN7XIgoV/xS6qlhU9jU7c+ICmdv1Y3u9zzyY5/dKpBNJL+6gm7FaD0O8PbErRArzRlKIftYu2O+sR7Iv8ETUdM0aNkV86/X7mBCA120zmJi/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779345277; c=relaxed/simple; bh=yfWVdIZpiB24KGCnk7Tyh0cuvXx53E/QuQ/iqyBlXS4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WbPn9GyOKzrECVhasNR/xHAQIkI4GcedHvNZF/Sgg5LugDF6LBNIZAzNsn/TQ6va0VnW02MRK9yNWEq48zhf6vj1YeETf3/o2sTsZnBgkkr60ynZ+FtUztvLZmAfcQNjKC9uwk7o4OyoRL3C5AplFiVOCeMpmnYnTMWA40bzi9I= 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=kyaoG8R6; 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="kyaoG8R6" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64L5oYLv3690499; Thu, 21 May 2026 06:34:04 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=EgPvStPGREceM4mKr 9/dWDqLQj7sY9BELv0RlZiiqEs=; b=kyaoG8R6Md6Go+p/1ydpucSbS/fcHTDsz lK2WfSPicaIzn5E+8ZtZAGCU8Ct3Qgo9BZKV4h60j91nc++bckIIGJpf5iwmR4cG V95s0WvUi9qQ7iv4uTbTCAxqOyjRQL7yjeCksJZhZiT2o/bxbC/gwL2hUp1Z6WFp frj1zEGUUKY8N/Zbn6QcyqUneN7OMEIc2feSPTHBevfGFh/zJ5Z9Dn+Rdh4TakKx P/B0lP7waa/l1sWhbP6TzHf3NxoVCt5cyUaePFqN7gVRStcJwtmaH/vnULeOh/fT tgjo/Cl2Lq9lVaT90zQwVys+w3k+lOuVe9hsl9LNLdlsKTmy3GlUg== 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 4e6hawcbrd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:34:03 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64L6O9sJ026822; Thu, 21 May 2026 06:34:03 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e74dhtq6q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:34:03 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64L6XxPH30474932 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 May 2026 06:33:59 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 171E32004B; Thu, 21 May 2026 06:33:59 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7AC2F20040; Thu, 21 May 2026 06:33:55 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 21 May 2026 06:33:55 +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 v7 02/13] selftests/mm: fix hugetlb pathname construction in charge_reserved_hugetlb.sh Date: Thu, 21 May 2026 12:03:28 +0530 Message-ID: <04b6b49e4a2acf46319f627caf82b09e6dc1ad7f.1779296493.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-Spam-Details-Enc: AW1haW4tMjYwNTIxMDA1NyBTYWx0ZWRfXy2zZ1SaT9IdJ rTates2YpOfzmmG4rnGF85LultnSzYXsfTYWf5pAn2B8TK3UQVHgWvRRz1F5UXKApl6izvikpDd DT9gq5UNUBTvbLE00i5JHr9Imu3p+brbIfLl59deP4tAzdfiB729wudt6M+RoP+qZw57AkOxAml Nxzhg2R0ZI/sh05Ac733qeu3A/eT1cDGoZGXZVU3TryBQo5Ac0VjdK7fOwmxmxkWyYSJB0ZSNUy f44sZnEhgsrk5/gxX79oN7dYrPTyq0tp7emH1ZXUoXzM6P19PjBTZBOXHAk1U34FnuqtktAgVPO k4mOc/m2zrxspqeKldTfcoaEfx+XCsuPO0LaiWl/81QkCBB2fAUJMU063HNSwL4/QkU85aLLkm5 /A7Q30Gb8/NVzBRWzeWkEMmkkgFgn1PdkXDcIZu73kXHGpKEol8VnfpXzU+w4FzrnB9X6O9l9S7 KR+q13s7iAUWqzr3RIQ== X-Authority-Analysis: v=2.4 cv=Np/htcdJ c=1 sm=1 tr=0 ts=6a0ea75c cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=Ikd4Dj_1AAAA:8 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=TdliVB_93dTD34Rfq5YA:9 X-Proofpoint-ORIG-GUID: N0OmnNEPCXgKEKiDcOtdJjyUD_NIpF_m X-Proofpoint-GUID: iZqF1tYzYIkORx5DQxZSgFOKaFmfIvHY 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-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210057 Content-Type: text/plain; charset="utf-8" The charge_reserved_hugetlb.sh script assumes hugetlb cgroup memory interface file names use the "MB" format (e.g. hugetlb.1024MB.current). This assumption breaks on systems with larger huge pages such as 1GB, where the kernel exposes normalized units: hugetlb.1GB.current hugetlb.1GB.max hugetlb.1GB.rsvd.max ... As a result, the script attempts to access files like hugetlb.1024MB.current, which do not exist when the kernel reports the size in GB. Normalize the huge page size and construct the pathname using the appropriate unit (MB or GB), matching the hugetlb controller naming. Fixes: 209376ed2a84 ("selftests/vm: make charge_reserved_hugetlb.sh work wi= th existing cgroup setting") Fixes: 29750f71a9b4 ("hugetlb_cgroup: add hugetlb_cgroup reservation tests") Reviewed-by: Zi Yan Acked-by: David Hildenbrand (Arm) Tested-by: Venkat Rao Bagalkote Signed-off-by: Sayali Patil --- .../selftests/mm/charge_reserved_hugetlb.sh | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh b/tools/= testing/selftests/mm/charge_reserved_hugetlb.sh index e1945901fd20..a1cfd3a349db 100755 --- a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh +++ b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh @@ -94,6 +94,15 @@ function get_machine_hugepage_size() { } =20 MB=3D$(get_machine_hugepage_size) +if (( MB >=3D 1024 )); then + # For 1GB hugepages + UNIT=3D"GB" + MB_DISPLAY=3D$((MB / 1024)) +else + # For 2MB hugepages + UNIT=3D"MB" + MB_DISPLAY=3D$MB +fi =20 function setup_cgroup() { local name=3D"$1" @@ -103,11 +112,12 @@ function setup_cgroup() { mkdir $cgroup_path/$name =20 echo writing cgroup limit: "$cgroup_limit" - echo "$cgroup_limit" >$cgroup_path/$name/hugetlb.${MB}MB.$fault_limit_fi= le + echo "$cgroup_limit" > \ + $cgroup_path/$name/hugetlb.${MB_DISPLAY}${UNIT}.$fault_limit_file =20 echo writing reservation limit: "$reservation_limit" echo "$reservation_limit" > \ - $cgroup_path/$name/hugetlb.${MB}MB.$reservation_limit_file + $cgroup_path/$name/hugetlb.${MB_DISPLAY}${UNIT}.$reservation_limit_file =20 if [ -e "$cgroup_path/$name/cpuset.cpus" ]; then echo 0 >$cgroup_path/$name/cpuset.cpus @@ -142,7 +152,7 @@ function wait_for_file_value() { =20 function wait_for_hugetlb_memory_to_get_depleted() { local cgroup=3D"$1" - local path=3D"$cgroup_path/$cgroup/hugetlb.${MB}MB.$reservation_usage_fi= le" + local path=3D"$cgroup_path/$cgroup/hugetlb.${MB_DISPLAY}${UNIT}.$reserva= tion_usage_file" =20 wait_for_file_value "$path" "0" } @@ -150,7 +160,7 @@ function wait_for_hugetlb_memory_to_get_depleted() { function wait_for_hugetlb_memory_to_get_reserved() { local cgroup=3D"$1" local size=3D"$2" - local path=3D"$cgroup_path/$cgroup/hugetlb.${MB}MB.$reservation_usage_fi= le" + local path=3D"$cgroup_path/$cgroup/hugetlb.${MB_DISPLAY}${UNIT}.$reserva= tion_usage_file" =20 wait_for_file_value "$path" "$size" } @@ -158,7 +168,7 @@ function wait_for_hugetlb_memory_to_get_reserved() { function wait_for_hugetlb_memory_to_get_written() { local cgroup=3D"$1" local size=3D"$2" - local path=3D"$cgroup_path/$cgroup/hugetlb.${MB}MB.$fault_usage_file" + local path=3D"$cgroup_path/$cgroup/hugetlb.${MB_DISPLAY}${UNIT}.$fault_u= sage_file" =20 wait_for_file_value "$path" "$size" } @@ -180,8 +190,8 @@ function write_hugetlbfs_and_get_usage() { hugetlb_difference=3D0 reserved_difference=3D0 =20 - local hugetlb_usage=3D$cgroup_path/$cgroup/hugetlb.${MB}MB.$fault_usage_= file - local reserved_usage=3D$cgroup_path/$cgroup/hugetlb.${MB}MB.$reservation= _usage_file + local hugetlb_usage=3D$cgroup_path/$cgroup/hugetlb.${MB_DISPLAY}${UNIT}.= $fault_usage_file + local reserved_usage=3D$cgroup_path/$cgroup/hugetlb.${MB_DISPLAY}${UNIT}= .$reservation_usage_file =20 local hugetlb_before=3D$(cat $hugetlb_usage) local reserved_before=3D$(cat $reserved_usage) @@ -312,8 +322,10 @@ function run_test() { =20 cleanup_hugetlb_memory "hugetlb_cgroup_test" =20 - local final_hugetlb=3D$(cat $cgroup_path/hugetlb_cgroup_test/hugetlb.${M= B}MB.$fault_usage_file) - local final_reservation=3D$(cat $cgroup_path/hugetlb_cgroup_test/hugetlb= .${MB}MB.$reservation_usage_file) + local final_hugetlb=3D$(cat \ + $cgroup_path/hugetlb_cgroup_test/hugetlb.${MB_DISPLAY}${UNIT}.$fault_usa= ge_file) + local final_reservation=3D$(cat \ + $cgroup_path/hugetlb_cgroup_test/hugetlb.${MB_DISPLAY}${UNIT}.$reservat= ion_usage_file) =20 echo $hugetlb_difference echo $reserved_difference @@ -369,10 +381,14 @@ function run_multiple_cgroup_test() { reservation_failed1=3D$reservation_failed oom_killed1=3D$oom_killed =20 - local cgroup1_hugetlb_usage=3D$cgroup_path/hugetlb_cgroup_test1/hugetlb.= ${MB}MB.$fault_usage_file - local cgroup1_reservation_usage=3D$cgroup_path/hugetlb_cgroup_test1/huge= tlb.${MB}MB.$reservation_usage_file - local cgroup2_hugetlb_usage=3D$cgroup_path/hugetlb_cgroup_test2/hugetlb.= ${MB}MB.$fault_usage_file - local cgroup2_reservation_usage=3D$cgroup_path/hugetlb_cgroup_test2/huge= tlb.${MB}MB.$reservation_usage_file + local cgroup1_hugetlb_usage=3D\ + $cgroup_path/hugetlb_cgroup_test1/hugetlb.${MB_DISPLAY}${UNIT}.$fault_u= sage_file + local cgroup1_reservation_usage=3D\ + $cgroup_path/hugetlb_cgroup_test1/hugetlb.${MB_DISPLAY}${UNIT}.$reserva= tion_usage_file + local cgroup2_hugetlb_usage=3D\ + $cgroup_path/hugetlb_cgroup_test2/hugetlb.${MB_DISPLAY}${UNIT}.$fault_u= sage_file + local cgroup2_reservation_usage=3D\ + $cgroup_path/hugetlb_cgroup_test2/hugetlb.${MB_DISPLAY}${UNIT}.$reserva= tion_usage_file =20 local usage_before_second_write=3D$(cat $cgroup1_hugetlb_usage) local reservation_usage_before_second_write=3D$(cat $cgroup1_reservation= _usage) --=20 2.52.0 From nobody Sun May 24 21:36:40 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 ADFF32BE034; Thu, 21 May 2026 06:48:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779346113; cv=none; b=pFM63xpGxsjSZl3P2uNfk/ye7lDkC2HpEwF5FL6vmM9pipx7CdSJZfAi/ReXf+lSOIIb4zuti2gETDHG3fnzbe44rdoe/0+fC35X8EePael2nqQQ3Dra/IO91pYUmU6sk0B/UXOj24G3ZHnlSmhuCHdA6Jwv6cxrPD8Rtt1OhBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779346113; c=relaxed/simple; bh=XHoajm1DEYNuypwtTMliJOqP/XkxnTk/DW4Tzt1COqY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eynGvTC/twPze8nQHuZc2fh2loVzrZgsGk2qidbMhSSH7NjiwFIlQUq8uLdkelp4PpNGv4JzU+U41nbke4qz5bkfvYJ4KjtdtOvhDDj5v5bcQw1pTPEku+sLVtgZvsOsLLSz7GNA7mBEkPEGnpfLSkkdYMiCnYqVQQBqRU791R8= 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=S1uj1feU; arc=none smtp.client-ip=148.163.156.1 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="S1uj1feU" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64L4nxT93913287; Thu, 21 May 2026 06:48: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=wuvm835NB4tDr/INm Aj8E4pEfzootxPjtudzVh0pFns=; b=S1uj1feUmJDrzF8biPNYlSJlwZkvySj8A c0vtK40B9uOmElM3p/wooq7GMGYq6O2axnTQdeTfYIc5yRVBI0r/oSHBs15AlUiI W0XT9VyPCe11iuqYYMoD71j8p1oc4Wrf5h1ffu+WUBtwCccw9T3PZ8/uyUyUs2S3 Tb/HVjajSRP8Im2Aj6ick5a5gjw06U3UR67kK8DfbXJc3BSRr9ZfHUSsES/hkZHy cBuNh2GYPstp3O+keUytMtW297WUFXcv2JJFCJFaqeWub0Ow92dFUu0mpMejWmzo cvaSZfvT/SrFG+sBTOHwgQTAXKDFLLnl8NG2gzQjTlRj8H5IUzGaA== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e6h9y5k63-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:06 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64L6dBB8018365; Thu, 21 May 2026 06:48:05 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e75kyajd9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:05 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64L6m12e40829320 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 May 2026 06:48:01 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 986E120043; Thu, 21 May 2026 06:48:01 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C819E20040; Thu, 21 May 2026 06:47:58 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 21 May 2026 06:47: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 v7 03/13] selftests/mm: restore default nr_hugepages value via exit trap in hugetlb_reparenting_test.sh Date: Thu, 21 May 2026 12:17:43 +0530 Message-ID: <29db637c3c6ba6c168f6b33f59f059a0b39c35c8.1779296493.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-Spam-Details-Enc: AW1haW4tMjYwNTIxMDA2MiBTYWx0ZWRfXyUiUAcSTpt4k fKUdI3XYMIKIt4FLxvFnjj4gx0nrIHMwvIuiRoKid+KvpYf6WGbDD3kPCTnYTm3yCLmk35LXTRm iuXfha/wH0vkSdb4evkhsq8OPAjEXAHZkPSC+q2b2d6bumllxqxXpiDfdQkc7x8DCeLlWZAgBJE w7fan0s7Q7EA/SYpjatFm0lTkRPdCENRA+aaj8iCsGkIuSgvu03gcAnldNRM/hGiZqeMc0mv90Y BRgqeP80klWcc0LukWJ2iliF08qtjfpwNEVqPCy8pOBDu9+AKecPbVNUm+kxxMUrbt8LKVt0sz7 okVb5RXHIUdycvRtXSKdqISkIjLOkbKubtsoV3IbcfwzFzTaZ4OsjhYITf3h1Eprn6KstEM/ZxV pVVyxVBjkqiX8O1N+z9mtuxABQDQ/QbuTtHguCjRzkKSv1Z0ojbLyDYeFHPHqkMXywdSRr68Rh/ xhoKAMrco2mu0fIwvbw== X-Authority-Analysis: v=2.4 cv=BNuDalQG c=1 sm=1 tr=0 ts=6a0eaaa6 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=Ikd4Dj_1AAAA:8 a=VnNF1IyMAAAA:8 a=dU9eaedoi-733nYHt2kA:9 X-Proofpoint-ORIG-GUID: G9G2dDS_3HjUZVGRrb2MsSArkdyVZq6t X-Proofpoint-GUID: 6N2rSNS9x34ORBswSKiOSH2EjL8vY8sw 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-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 suspectscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210062 Content-Type: text/plain; charset="utf-8" The test modifies nr_hugepages during execution and restores it from cleanup() and again reconfigure it setup, which is invoked multiple times across test flow. This can lead to repeated allocation/freeing of hugepages. With set -e, failures in cleanup (e.g., rmdir/umount) can also cause early exit before restoring the original value at the end. Move restoration of the original nr_hugepages value to a trap handler registered for EXIT, INT, and TERM signals so it is always restored on all exit paths. This also avoids unnecessary allocation churn across repeated cleanup/setup cycles. Fixes: 585a9145886a ("selftests/mm: restore default nr_hugepages value duri= ng cleanup in hugetlb_reparenting_test.sh") Acked-by: Zi Yan Tested-by: Venkat Rao Bagalkote Signed-off-by: Sayali Patil --- tools/testing/selftests/mm/hugetlb_reparenting_test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh b/tools= /testing/selftests/mm/hugetlb_reparenting_test.sh index 0dd31892ff67..11f914831146 100755 --- a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh +++ b/tools/testing/selftests/mm/hugetlb_reparenting_test.sh @@ -12,6 +12,8 @@ if [[ $(id -u) -ne 0 ]]; then fi =20 nr_hugepgs=3D$(cat /proc/sys/vm/nr_hugepages) +trap 'echo "$nr_hugepgs" > /proc/sys/vm/nr_hugepages' EXIT INT TERM + usage_file=3Dusage_in_bytes =20 if [[ "$1" =3D=3D "-cgroup-v2" ]]; then @@ -56,7 +58,6 @@ function cleanup() { rmdir "$CGROUP_ROOT"/a/b 2>/dev/null rmdir "$CGROUP_ROOT"/a 2>/dev/null rmdir "$CGROUP_ROOT"/test1 2>/dev/null - echo $nr_hugepgs >/proc/sys/vm/nr_hugepages set -e } =20 @@ -240,4 +241,3 @@ if [[ $do_umount ]]; then rm -rf $CGROUP_ROOT fi =20 -echo "$nr_hugepgs" > /proc/sys/vm/nr_hugepages --=20 2.52.0 From nobody Sun May 24 21:36:40 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 3C48136729F; Thu, 21 May 2026 06:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779346116; cv=none; b=uNpuom9sZb89meK+aX3TUM1wZPpEAH/7YiRPXZRmC5vNBssVt4TBzi+wM9psiMHaAOlnBfIBv0nIuRmyXFvF9YuQXv94wvb50hU4VB+DOZOS+ekA81SARGVxvnB/LG0j+YN+q3Q1T8DjHF48FwVW2F1eTPiVbpmLBlOjCgNkZ+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779346116; c=relaxed/simple; bh=6k0dfBPedoZ5m3zDYQfNpVT7vuiVKssNtYmRQNfyMxo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gvg3jLq87ZdrtjIATCXYie632iwUNIbpyJmkLJJsjeI3LNmzX+ef8aX5xLPtATzjpJmPvFIKDCWcdn/MwpA9i+ibP1IixrMhmVWCCSzZWV2CFKHqn+SQsP3BVascOho97bXLqtRzv7OzoF6F92GlufOnoPo8WfhSn5COPCtg8Bs= 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=eMB8yAFv; arc=none smtp.client-ip=148.163.156.1 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="eMB8yAFv" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64L2v5It3972669; Thu, 21 May 2026 06:48:10 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=9bpngp4LuWeNJI7hh OZ15/SZJ6KlaN1MsO0YmwThcC0=; b=eMB8yAFvqWJ8icmRD3+8j++Y5KumPwpXN dE4ST32ynNHWqTQBaiA4BArpZaUBQm2yoQWDDj0Jcs6DaVByMx7W7F5VwNrb283T Da4uwu9T5/CcVtXaXtCGC3IbxLmSfqwVowlIrXO6UBPrSyl/YdCDZJ7lx73nXZN2 W5V3W8oD+GcP7IRRPaFNKLLR7vQCru14y3xdo/auLrkcBCFWTHhm4EG6EU+vW6rx wJxIeBS77kRJOEghNsE6UOsnMqTSOaCwtuie7aT5etSMgqNwYmneKhkJJCcYXCtI 6K6UKSmw/n6CEYsgmVsx0jcn44fMeZogrwnAZG57aPttaer6gdipQ== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e6h9y5k68-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:09 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64L6d40A003561; Thu, 21 May 2026 06:48:08 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e754gjksw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:08 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64L6m4Om48824598 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 May 2026 06:48:04 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B5C012004D; Thu, 21 May 2026 06:48:04 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E015620040; Thu, 21 May 2026 06:48:01 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 21 May 2026 06:48:01 +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 v7 04/13] selftests/mm: fix hugetlb pathname construction in hugetlb_reparenting_test.sh Date: Thu, 21 May 2026 12:17:44 +0530 Message-ID: <837ce751965c93f74c95d89587debf1e93281364.1779296493.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-Spam-Details-Enc: AW1haW4tMjYwNTIxMDA2MiBTYWx0ZWRfX8tCfmpVxwOYZ fNCRcgg19UxXoHi3+n4Wk4wqYjkM4vVVHlB84htGCdm2YQqRngrIfI/EZxflS9TcY17B9zUNyNZ DX8AH21HzYFsoFeZ1hyfPHiU62oTjq9wi88K88sckV3IZk9VijWyefuLX39fYbkMQZDYh+EvEJy GmkLk3LIqtWkYBnIHpMrJeoaeGh1jtcqFTJHrMgeekHnWIAImH5K7ssc4e7C/EWkyto1IQPTgOS 4ZmlDqs4AZ/otw06NW/OOwKsXhWZC8vg5K6Eh6NQAQi58wP9bhnQNj6FpN/ozqvmzb3Bz32aYKr ylLkPOSYdwVJxZtrRwZlQDTCyIFBjOKzwsREtEa0bfo8LTnOJDj1DRL8ebfi6s2xwq7Z6SJHEcG 76gq0lbspWEy13PMkBKKxQqk6Ue5HjA4mTb4jTmc7OK57gaoL/SOKn9PSb+QmxuTBxWJgYc2x8h 1YTPeg8E8lZpySM12wg== X-Authority-Analysis: v=2.4 cv=BNuDalQG c=1 sm=1 tr=0 ts=6a0eaaa9 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=Ikd4Dj_1AAAA:8 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=7yu59zDboRqKFyXxuvEA:9 X-Proofpoint-ORIG-GUID: pICns9u6T883Qo12vo5EruQsdOhLvWbs X-Proofpoint-GUID: CYXlI0-YC_WZTxCdHj1tzX9j09-hsPxm 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-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 suspectscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210062 Content-Type: text/plain; charset="utf-8" The hugetlb_reparenting_test.sh script constructs hugetlb cgroup memory interface file names based on the configured huge page size. The script formats the size only in MB units, which causes mismatches on systems using larger huge pages where the kernel exposes normalized units (e.g. "1GB" instead of "1024MB"). As a result, the test fails to locate the corresponding cgroup files when 1GB huge pages are configured. Update the script to detect the huge page size and select the appropriate unit (MB or GB) so that the constructed paths match the kernel's hugetlb controller naming. Also print an explicit "Fail" message when a test failure occurs to improve result visibility. Fixes: e487a5d513cb ("selftest/mm: make hugetlb_reparenting_test tolerant t= o async reparenting") Reviewed-by: Zi Yan Acked-by: David Hildenbrand (Arm) Tested-by: Venkat Rao Bagalkote Signed-off-by: Sayali Patil --- .../selftests/mm/hugetlb_reparenting_test.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh b/tools= /testing/selftests/mm/hugetlb_reparenting_test.sh index 11f914831146..d724b6e45432 100755 --- a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh +++ b/tools/testing/selftests/mm/hugetlb_reparenting_test.sh @@ -48,6 +48,13 @@ function get_machine_hugepage_size() { } =20 MB=3D$(get_machine_hugepage_size) +if (( MB >=3D 1024 )); then + UNIT=3D"GB" + MB_DISPLAY=3D$((MB / 1024)) +else + UNIT=3D"MB" + MB_DISPLAY=3D$MB +fi =20 function cleanup() { echo cleanup @@ -88,6 +95,7 @@ function assert_with_retry() { if [[ $elapsed -ge $timeout ]]; then echo "actual =3D $((${actual%% *} / 1024 / 1024)) MB" echo "expected =3D $((${expected%% *} / 1024 / 1024)) MB" + echo FAIL cleanup exit 1 fi @@ -108,11 +116,13 @@ function assert_state() { fi =20 assert_with_retry "$CGROUP_ROOT/a/memory.$usage_file" "$expected_a" - assert_with_retry "$CGROUP_ROOT/a/hugetlb.${MB}MB.$usage_file" "$expecte= d_a_hugetlb" + 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" - assert_with_retry "$CGROUP_ROOT/a/b/hugetlb.${MB}MB.$usage_file" "$exp= ected_b_hugetlb" + assert_with_retry \ + "$CGROUP_ROOT/a/b/hugetlb.${MB_DISPLAY}${UNIT}.$usage_file" "$expected_= b_hugetlb" fi } =20 --=20 2.52.0 From nobody Sun May 24 21:36:40 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 4281C342509; Thu, 21 May 2026 06:48:33 +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=1779346115; cv=none; b=Nr0Dww1Gz2nb6ZI7tmSGdorV5tIa/TsoV+Kshh5jTk58Q6cL0Ggb3LS7ndmxElGVVoKWtjiZaawtdnJ/wfQyXq4awFxEnJ1kkAihe7QMtt0uqLj52mAZu3iso6iqoaCv+zZDY8RhjqfUw++1CllOjzHZAJe+O1RAnVFk48L7Wx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779346115; c=relaxed/simple; bh=LwQdcjDlXg0itHoPUyZh+mH36PaAEwMzM4SLAyBwvwM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GAsuL6Q0fJQ/nj7W2zxsj2LbiJ9EhrUKlha1CGCSg5kOBGGQ68A/61ovQ60LlYAbx+MkPZAHACIKG3vwvCCJCC/9nnC3gQ6YY35auAfH2AULmNSCHYtG33NVGswhicsNLLPMaAo+cVbwBzbXYBhxArYMbCVpHxxPJBmUu5yLK08= 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=EUozKRy/; 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="EUozKRy/" 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 64L6jBKE160368; Thu, 21 May 2026 06:48:13 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=udzwYhTawzSzNQvyJ pDKM0o+od4uW9MOHNJ2PUBQYQ0=; b=EUozKRy/qynqU39nvlcEOX0Or1JacDwOr bDdcfrsKshaPSSye8vrw7oS+aYQsU1ZRYvM3M4oi1+j/S7Y2UaBH5J0mO0iPeuW4 008yNctoGFEaETdH8JPWjQnA0LWX9cpxr55YipxlWc/hko/QDE++HUKOBX2QOfpQ 82lCl6A6xT7jzlo4rHgje4Ti+aBgBl6MZBaCwxOG6LER9fpDsWDI7C9xOmHXwit9 vamMjsaqbURFUgoFSO912CvLRGAZ5DaqT7SHYGx04HbBfAvB/UEbySIiYt0NK+jn 24kTSfJjhpJmvahJI7sKdJJqpEn6CUz7rxdqz8emhas8buhbgX7sA== 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 4e6hb8mbmd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:12 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64L6d83r013530; Thu, 21 May 2026 06:48:11 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e72wqb260-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:11 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64L6m8Dl50463086 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 May 2026 06:48:08 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 011152004B; Thu, 21 May 2026 06:48:08 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 06B5120040; Thu, 21 May 2026 06:48:05 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 21 May 2026 06:48:04 +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 v7 05/13] selftests/mm: fix cgroup task placement and drop memory.current checks in hugetlb_reparenting_test.sh Date: Thu, 21 May 2026 12:17:45 +0530 Message-ID: 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-Spam-Details-Enc: AW1haW4tMjYwNTIxMDA2MiBTYWx0ZWRfX21iNKeR+KCX2 OuCNHQLbNnV0F5ss/BZbjhjmVKU73GsCdonrSvZnWqNVnLFNDwYxI+dHMBAGl7AEPaz0/UazZni TEKbe476umaMWLHVQQCQjMV0fs2jCVVdyGPq9efT4S2TcaqEjn376MD7BH2jg7fv+mQmg4ar1+s nRWNDHgdGIGun0zcsLOcTYrp5EfHfpMpkFmazM0g7zh8MCKCpILCX1kgeRNF9kwovcQYjD7gWsL 8obc8uFuc46KxIBFfuXOV3JAWRbtPYTwkt49PXGxAWzI1QlvVKRkdH4IdcIc16uorPb+FQFVJO8 pK/uIYpnOF1paWYVmP332YJw4uMO7A8hWztEBxUyi5Cvh1UVAemsNKNHjacowlGUmUBd6pnvE4t PCydBGX1i5xE8nXNPOKzKtZsHJhiM2fup8LigBBlkFhyqKx4ZAalgsmFWAQsxgcMFmawOdXFEfx upkkWyIEM3JYl9N+HEQ== X-Proofpoint-GUID: iMCUzNF_VwhkUlL8IdcE_H9LrsmkFWJ4 X-Proofpoint-ORIG-GUID: 2j9dxQs97PS-2Hu29T8HZTDJweJTj8aF X-Authority-Analysis: v=2.4 cv=aYBRWxot c=1 sm=1 tr=0 ts=6a0eaaac cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=fW5kwVfrStG9UF1TlMAA:9 a=O8hF6Hzn-FEA:10 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-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 phishscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210062 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 | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh b/tools= /testing/selftests/mm/hugetlb_reparenting_test.sh index d724b6e45432..95f517c3bd16 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,17 @@ 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 $$ > "$1"; exec ./write_to_hugetlbfs -p "$2" -s "$3" -m 0 = -o' _ \ + "$cg_file" "$path" "$size" & pid=3D$! + wait "$pid" echo } =20 @@ -203,21 +197,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 +225,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 From nobody Sun May 24 21:36:40 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 7C998395AC4; Thu, 21 May 2026 06:48:39 +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=1779346120; cv=none; b=Eof+GuqqCjUPvYBp2ApDxhnuXpBHXacmknXQw2YWR7MvXsWsRwxvyD3eXllaDAj+mZ42aEoIxZ8pEszpUj9darp0Xpr/ThcmYZ9LiTqYBa0qRBOO6Ne6Ak/6sPQ1Gznb0BM6fen84lT9etlB3Jmjil58X/87bgQf82p0R3NYlDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779346120; c=relaxed/simple; bh=Phzv6Er8wF+8uqtjbMWElkvWEYRsIQ4TqNEEPQnxkJI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ThOcYWWv2tN9Kd34LQJ1zCbqhuX44v1yLthOlzLJVUDw9vLXtgT0IyFT0nRu5Lfgtv6Fc0nUoQgla812FN0hrQzg0mFJ2is94uZm/XBhelqeLz0DeoIYQkrqwXwAm7EBtRT5En+KPUr+tqqQnUQ64Tw/WGOMlNvFtMNTQ7MRAq0= 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=D3S5yZb6; 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="D3S5yZb6" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64KJBE2b2735197; Thu, 21 May 2026 06:48:16 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=mtvzoiAxbgnkfrp6P scCj4WP0YSbVNRNiGRRDhh6oYQ=; b=D3S5yZb6D9RVZAJbTgVLjaoeF4LmeNTY2 jFy3mg3DNVsQpTX3FPSETGGUzBX51j74CAwd63gsLvcn/hNlbVE7b8pi3sKWz4jo B5/xj+xgH1D1omtIg03N1apo5l+IWZwuaC2tYgS4DoFskzTobQ65x4N6356dDFD4 nATYohC2tya4N+QN/DqhTdgniffLWl2RS8Y/5UytL91dZ0OXDY5qGnWf41cL13eN 4JBXnUDGn4CM+CYMivOhY33W4qUDJi1B4EPE1IGK6iY0yMUTr55axX5QsMauUnYu JUEuoMPT2QYlOPbKIvy6AgQ2TaxvTYm5/RpBnJLTsHKrq2fLvH5Kg== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e6h88mcd8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:15 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64L6d6hQ018345; Thu, 21 May 2026 06:48:15 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e75kyajdn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:15 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64L6mBQj49414406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 May 2026 06:48:11 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8002E2004D; Thu, 21 May 2026 06:48:11 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5FCBE20040; Thu, 21 May 2026 06:48:08 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 21 May 2026 06:48:08 +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 v7 06/13] selftests/mm: size tmpfs according to PMD page size in split_huge_page_test Date: Thu, 21 May 2026 12:17:46 +0530 Message-ID: <33e1bc10753fe82d1217613d8cd496020778cf2b.1779296493.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-ORIG-GUID: mDMVzFjnYJc1JdZPKPQtNX6Etc6MavDN X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIxMDA2MiBTYWx0ZWRfX6cMxuM7nd47K MsrK6X7vjHNPqH/gfxfH1Br1ClZCnimb+XXLJI+6DaCmTzDuhUpQPuUbtmh7yBcFm7AC/Hm4ZV6 iqVKgBOiYynV0IIjE1mJS1KeGf9pIAqB1Nimd4Z8fX+AHkkohtQJRht0OVp35avDt2I9gBVcaei z1tiYB7Jt9CrmO16I2AXvjdf6CvCUxSVV0fKOKWB3qGp2TN/P69tn6OjUPsUs/H+RxyP5O7itU6 BGszVYp53aOgnRhRhvM3fVY70qP89+vKKvuAOMHxmPzDXiELNhqlUyWay0Mnoulag4x8nc1JtAf ovpEsgiha158K1wVMM35sTycyapJXw4cmptFMxQQ1+c/vKEjS8eMPZ11jP7inVgML8PWmHwSnAE vMdY4Hfwt4e8xm5NNTYVw9JSPScbCQ0JG5qNn9OkVOkZ9quuBneKaZdcBCOJam3yA6WacKukz8d EL5WN4ns/byyFIcmBFw== X-Proofpoint-GUID: 7OsTwujtcS76igdtvXCRZzwfhYTlJYbk X-Authority-Analysis: v=2.4 cv=apyCzyZV c=1 sm=1 tr=0 ts=6a0eaab0 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=Ikd4Dj_1AAAA:8 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=2DqBuDyFdJ_AORcY0zkA:9 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-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 suspectscore=0 adultscore=0 spamscore=0 phishscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210062 Content-Type: text/plain; charset="utf-8" The split_file_backed_thp() test mounts a tmpfs with a fixed size of "4m". This works on systems with smaller PMD page sizes, but fails on configurations where the PMD huge page size is larger (e.g. 16MB). On such systems, the fixed 4MB tmpfs is insufficient to allocate even a single PMD-sized THP, causing the test to fail. Fix this by sizing the tmpfs dynamically based on the runtime pmd_pagesize, allocating space for two PMD-sized pages. Before patch: running ./split_huge_page_test /tmp/xfs_dir_YTrI5E -------------------------------------------------- TAP version 13 1..55 ok 1 Split zero filled huge pages successful ok 2 Split huge pages to order 0 successful ok 3 Split huge pages to order 2 successful ok 4 Split huge pages to order 3 successful ok 5 Split huge pages to order 4 successful ok 6 Split huge pages to order 5 successful ok 7 Split huge pages to order 6 successful ok 8 Split huge pages to order 7 successful ok 9 Split PTE-mapped huge pages successful Please enable pr_debug in split_huge_pages_in_file() for more info. Failed to write data to testing file: Success (0) Bail out! Error occurred Planned tests !=3D run tests (55 !=3D 9) Totals: pass:9 fail:0 xfail:0 xpass:0 skip:0 error:0 [FAIL] After patch: running ./split_huge_page_test /tmp/xfs_dir_bMvj6o -------------------------------------------------- TAP version 13 1..55 ok 1 Split zero filled huge pages successful ok 2 Split huge pages to order 0 successful ok 3 Split huge pages to order 2 successful ok 4 Split huge pages to order 3 successful ok 5 Split huge pages to order 4 successful ok 6 Split huge pages to order 5 successful ok 7 Split huge pages to order 6 successful ok 8 Split huge pages to order 7 successful ok 9 Split PTE-mapped huge pages successful Please enable pr_debug in split_huge_pages_in_file() for more info. Please check dmesg for more information ok 10 File-backed THP split to order 0 test done Please enable pr_debug in split_huge_pages_in_file() for more info. Please check dmesg for more information ok 11 File-backed THP split to order 1 test done Please enable pr_debug in split_huge_pages_in_file() for more info. Please check dmesg for more information ok 12 File-backed THP split to order 2 test done ... ok 55 Split PMD-mapped pagecache folio to order 7 at in-folio offset 128 passed Totals: pass:55 fail:0 xfail:0 xpass:0 skip:0 error:0 [PASS] ok 1 split_huge_page_test /tmp/xfs_dir_bMvj6o Fixes: fbe37501b252 ("mm: huge_memory: debugfs for file-backed THP split") Reviewed-by: Zi Yan Reviewed-by: David Hildenbrand (Arm) Tested-by: Venkat Rao Bagalkote Signed-off-by: Sayali Patil --- tools/testing/selftests/mm/split_huge_page_test.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/test= ing/selftests/mm/split_huge_page_test.c index 50c80ceb4988..4066de6e8ae0 100644 --- a/tools/testing/selftests/mm/split_huge_page_test.c +++ b/tools/testing/selftests/mm/split_huge_page_test.c @@ -470,6 +470,8 @@ static void split_file_backed_thp(int order) char tmpfs_template[] =3D "/tmp/thp_split_XXXXXX"; const char *tmpfs_loc =3D mkdtemp(tmpfs_template); char testfile[INPUT_MAX]; + unsigned long size =3D 2 * pmd_pagesize; + char opts[64]; ssize_t num_written, num_read; char *file_buf1, *file_buf2; uint64_t pgoff_start =3D 0, pgoff_end =3D 1024; @@ -489,7 +491,8 @@ static void split_file_backed_thp(int order) file_buf1[i] =3D (char)i; memset(file_buf2, 0, pmd_pagesize); =20 - status =3D mount("tmpfs", tmpfs_loc, "tmpfs", 0, "huge=3Dalways,size=3D4m= "); + snprintf(opts, sizeof(opts), "huge=3Dalways,size=3D%lu", size); + status =3D mount("tmpfs", tmpfs_loc, "tmpfs", 0, opts); =20 if (status) ksft_exit_fail_msg("Unable to create a tmpfs for testing\n"); --=20 2.52.0 From nobody Sun May 24 21:36:40 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 92272397357; Thu, 21 May 2026 06:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779346127; cv=none; b=KYBV+jPSWEElO0yYVSJRqPAyHwgznC2aevxJHbXM/bgY85aNzAYCiKOM3dr2k2BvOTeUsYjbIieKG9Dp9LZayovnwF/XQQBPQZBtxMUr9kqpqYMUYUmwYP8f+0wI2BdOgPcHmY7cBDRWyz1FTcvAaOl6YRYoe4V7xM0Vo43ZzEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779346127; c=relaxed/simple; bh=zxMjdzwlmkSIs9YiR1LwQ5RFctCkhAzQaBFq9p0VPDQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R+Z1zLEuhXK86sC78BaARSkrTivN3+JdmXbW/z85NMz8YTQajSXtCjuK4t4lywhbHLGcS3LwN1bKECOaZBCqwVewzRL8bvVh+hUrnf3s/GfAn65/D270qHzRyG1JLJPsPIL4PxgJsCu2sLIzy0+m8eNYzN9BvEdWsgZI677rFSw= 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=pPL0Sjfy; arc=none smtp.client-ip=148.163.156.1 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="pPL0Sjfy" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64L4nxTA3913287; Thu, 21 May 2026 06:48:20 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=EU7FDm+SK0SeHUIOa PNtoHigI+RGvZfT8tjdC0pN70s=; b=pPL0SjfylPTPLVwBJhpsk474c+FZ698HU DzS0mTv2zdOIis3+OmDX1iLHL4O26DHKY3txk/ysrhXnd4CorxYvXcfDHzcCUPSa Dl5yQTRKzbmpo42MdG8VEXz3S+QZNPM5FPcVSaTWyHR3ZvCGufkgbzAxnuPSHU1f Vtww9Khj/Ukysi00h3BbfFjSzgzPpIXf6iFBmh4/5VOdygXKuV2XYXmUV4Y8R1kd ahxiouK7ILOqCt+KEM6pylXAilb3/msaGWFU6CXS+bLnwnb3Iemf+JLTFjMGAQAI c8eKExq2P/e2KRxKTNaBHKSldEQKpOf3GwOghl3pHcFcWdWfh2jhw== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e6h9y5k72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:19 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64L6dFse003635; Thu, 21 May 2026 06:48:18 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e754gjktq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:18 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64L6mF2U51184088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 May 2026 06:48:15 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1AE3E2004D; Thu, 21 May 2026 06:48:15 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D931D20040; Thu, 21 May 2026 06:48:11 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 21 May 2026 06:48:11 +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 v7 07/13] selftests/mm: free dynamically allocated PMD-sized buffers in split_huge_page_test Date: Thu, 21 May 2026 12:17:47 +0530 Message-ID: <060c673b376bbeeed2b1fb1d48a825e846654191.1779296493.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-Spam-Details-Enc: AW1haW4tMjYwNTIxMDA2MiBTYWx0ZWRfX0lB5NLz0sG5H rlke4dn0jGafkRW+w3KSwTlA+yIFvS0fM9dxQQcNqj3ZXWCA6v+1OEEzaUv92KNbBBW23Go3/8o dEU0AzDyQhRbxhZEgqisleSZ9Ifra+eQS9CCYPXYVuYMJgKusRjjkA9nGmCdLMl5y9W/0mVKO5h ZfwJlqsvWgpc5XXtezbEu/JlsvZd/XKIM5uJNcFFaMAei2g6QEqRep8mcPepnoeMreqginMjUnu ToUlZNWLFvBS55iHsX5vo04CXooBRm20nfUMSzf7l0kwOsEaSWkWjB+Hh0BPtQdpPEoadGIG6EV gz8kvgoxGdyC35Wig3hWfwqYAYBTAjf+S6uHOxRBpSeK8GUb50cCGYyk9Rna0E16wUazvaj+HSn s9omu+nDAjMvbwPF3aybAQa8mvWfCc43BlFfjcVt4DIXRdoqdq/dOsq1xqhuOah0ijVECaFopxR vPGz5dsgtXAwItyimFw== X-Authority-Analysis: v=2.4 cv=BNuDalQG c=1 sm=1 tr=0 ts=6a0eaab4 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=Ikd4Dj_1AAAA:8 a=VnNF1IyMAAAA:8 a=9VAv6nXQuNVwvrTyzFEA:9 X-Proofpoint-ORIG-GUID: LZztiJkIpvWA-ajeXgRT9hYCTADlW0SK X-Proofpoint-GUID: pvfvNl9zkJM7djLOppnCP9NcadwCTh0- 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-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 suspectscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210062 Content-Type: text/plain; charset="utf-8" Dynamically allocated buffers of PMD size for file-backed THP operations (file_buf1 and file_buf2) were not freed on the success path and some failure paths. Since the function is called repeatedly in a loop for each split order, this can cause significant memory leaks. On architectures with large PMD sizes, repeated leaks could exhaust system memory and trigger the OOM killer during test execution. Ensure all allocated buffers are freed to maintain stable repeated test runs. Fixes: 035a112e5fd5 ("selftests/mm: make file-backed THP split work by writ= ing PMD size data") Reviewed-by: Zi Yan Tested-by: Venkat Rao Bagalkote Signed-off-by: Sayali Patil --- .../selftests/mm/split_huge_page_test.c | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/test= ing/selftests/mm/split_huge_page_test.c index 4066de6e8ae0..7a8b64cf4aad 100644 --- a/tools/testing/selftests/mm/split_huge_page_test.c +++ b/tools/testing/selftests/mm/split_huge_page_test.c @@ -473,12 +473,15 @@ static void split_file_backed_thp(int order) unsigned long size =3D 2 * pmd_pagesize; char opts[64]; ssize_t num_written, num_read; - char *file_buf1, *file_buf2; + char *file_buf1 =3D NULL, *file_buf2 =3D NULL; uint64_t pgoff_start =3D 0, pgoff_end =3D 1024; int i; =20 ksft_print_msg("Please enable pr_debug in split_huge_pages_in_file() for = more info.\n"); =20 + if (!tmpfs_loc) + ksft_exit_fail_msg("mkdtemp failed\n"); + file_buf1 =3D (char *)malloc(pmd_pagesize); file_buf2 =3D (char *)malloc(pmd_pagesize); =20 @@ -494,8 +497,10 @@ static void split_file_backed_thp(int order) snprintf(opts, sizeof(opts), "huge=3Dalways,size=3D%lu", size); status =3D mount("tmpfs", tmpfs_loc, "tmpfs", 0, opts); =20 - if (status) - ksft_exit_fail_msg("Unable to create a tmpfs for testing\n"); + if (status) { + ksft_print_msg("Unable to create a tmpfs for testing\n"); + goto out; + } =20 status =3D snprintf(testfile, INPUT_MAX, "%s/thp_file", tmpfs_loc); if (status >=3D INPUT_MAX) { @@ -547,10 +552,13 @@ static void split_file_backed_thp(int order) =20 status =3D umount(tmpfs_loc); if (status) { - rmdir(tmpfs_loc); - ksft_exit_fail_msg("Unable to umount %s\n", tmpfs_loc); + ksft_print_msg("Unable to umount %s\n", tmpfs_loc); + goto out; } =20 + free(file_buf1); + free(file_buf2); + status =3D rmdir(tmpfs_loc); if (status) ksft_exit_fail_msg("cannot remove tmp dir: %s\n", strerror(errno)); @@ -563,8 +571,10 @@ static void split_file_backed_thp(int order) close(fd); cleanup: umount(tmpfs_loc); - rmdir(tmpfs_loc); out: + free(file_buf1); + free(file_buf2); + rmdir(tmpfs_loc); ksft_exit_fail_msg("Error occurred\n"); } =20 --=20 2.52.0 From nobody Sun May 24 21:36:40 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 AC16C395AD7; Thu, 21 May 2026 06:48:43 +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=1779346125; cv=none; b=ngo/o2zt6Pd8yfjxY4C4TtyRegb8MmGWs3W7QqGlrIzXNzHP6+3ynTBzNcdkO7tZwaM1PrPUcRCikVbQ+f7dJl1PMJcloztLEaMAewpKGNQ9J67pRGHWcj7ugzhhe0NqFHR3fUtzsG4310HOAmWM1n+DmdROcTg78vCwQPWo6x8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779346125; c=relaxed/simple; bh=ZZuGP7/c9Ekxh1Fsyz4kegioTSjWRjXz1w/cpNJVhPQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mw8LKrwJPNdLtfJFXN8oSq+5EFFI0Ve1y1qtqDuzNE3M5ExGruSSVd1Tx7AMbK85FTIxrRByFC3jyfbG2vP5xvjZaXcEcaIBC097PVtjT9/DIOHLQO2haQZGtribcws4ejqk/aXaovls/bojDNbav5TABU7uegeDkRKu9R+/NGA= 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=C6D3I+33; 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="C6D3I+33" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64KG6lUI730699; Thu, 21 May 2026 06:48:23 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=eo/px+osxzXbvD5x7 9rFpcV6MacGwZaroZw3vt7lgbU=; b=C6D3I+33wKUb95AlyJb5gEuDX02tN5gCf gubv8vxLGHYm7mZVvuh924FeOjXikkXNJDPhybdIPRQR2+yeqUzBPtCEEMMsNq9Y TE9MgkddLZoGOzBauCUnMFwUOY54EchfXcBY61CM1Vzzaid9/KLSEoDT1HHNHL/V g08zBtqeLCG+2cBpHU34oLFq5wssZf68dKmL1K+GYKyUabs3V7GAljVHpCc5VMTL B8UtgQwjT7LWfQZXuSaIBB56lTe2LmnwpJNSkDL9gJqbWSnmf80+HvSyL6w7Domi k2B+V3uLsocE/PjHOSKRmNAiL8k+KphloaBvTy8yb7fs6QWeByY3A== 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 4e6hawcdbt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:22 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64L6d4A8013509; Thu, 21 May 2026 06:48:22 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e72wqb26h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:21 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64L6mIPJ33423678 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 May 2026 06:48:18 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5442A20043; Thu, 21 May 2026 06:48:18 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6345820040; Thu, 21 May 2026 06:48:15 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 21 May 2026 06:48:15 +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 v7 08/13] selftest/mm: register existing mapping with userfaultfd in hugetlb-mremap Date: Thu, 21 May 2026 12:17:48 +0530 Message-ID: <13845da872ed174316173e8996dbb5f181994017.1779296493.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-Spam-Details-Enc: AW1haW4tMjYwNTIxMDA2MiBTYWx0ZWRfX3JWUZB8iIVFj nFl4qeHz8zh4hCJW8cqDX1HIdJB1iJmbMa23xEKuR2YGKh6gU6L8DrJ1+BDBng2ZjB00oak24Gh lQxi8N29yA1/W8BipXqWjsYCfGbnPpPXSLzUW16t3fByvSqSNZUmx1NMYJgFUBRZT/TLMXBxf8y MYltzTIpfegefC09wCCxVAw3OVg/f1AFZu7Wy7gxGEzKsUC+o1ZXWU8J7im9I/UFBJtwSUB4n4N bH/GuzR2xA/PLIBh2dmymBLm06aDmAuTVlh6DuE5UK4+pEoiqDD4UDZYH6Wx/YK07U5N25/Rjun 3dzRvAHGfJ8BZ/Rg9q6qzPfOQCBft8AvSWOafWtIn5HVeYXlcIbbII9r+Yx1yY8+KezTlV29A79 1riosCYSQ9e+G/bAhOAOFevB4vE0w7b5QnDApF7j1z4mFomy6ZcJKXqx/fLtVNbTO1GMy2QCRkA 9xYy4KFYqmi8dz991fw== X-Authority-Analysis: v=2.4 cv=Np/htcdJ c=1 sm=1 tr=0 ts=6a0eaab7 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=gVE5Qc0x_BWLnb-D2gsA:9 X-Proofpoint-ORIG-GUID: fkKLQw64dHTeX5od5XGIYddJsny1HIgv X-Proofpoint-GUID: Vo6N1Uabd546SMOG7gbBTt9oz9wwn6XY 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-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210062 Content-Type: text/plain; charset="utf-8" Previously, register_region_with_uffd() created a new anonymous mapping and overwrote the address supplied by the caller before registering the range with userfaultfd. As a result, userfaultfd was applied to an unrelated anonymous mapping instead of the hugetlb region used by the test. Remove the extra mmap() and register the caller-provided address range directly using UFFDIO_REGISTER_MODE_MISSING, so that faults are generated for the hugetlb mapping used by the test. This ensures userfaultfd operates on the actual hugetlb test region and validates the expected fault handling. Before patch: running ./hugetlb-mremap ------------------------- TAP version 13 1..1 Map haddr: Returned address is 0x7eaa40000000 Map daddr: Returned address is 0x7daa40000000 Map vaddr: Returned address is 0x7faa40000000 Address returned by mmap() =3D 0x7fff9d000000 Mremap: Returned address is 0x7faa40000000 First hex is 0 First hex is 3020100 ok 1 Read same data Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0 [PASS] ok 1 hugetlb-mremap After patch: running ./hugetb-mremap ------------------------- TAP version 13 1..1 Map haddr: Returned address is 0x7eaa40000000 Map daddr: Returned address is 0x7daa40000000 Map vaddr: Returned address is 0x7faa40000000 Registered memory at address 0x7eaa40000000 with userfaultfd Mremap: Returned address is 0x7faa40000000 First hex is 0 First hex is 3020100 ok 1 Read same data Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0 [PASS] ok 1 hugetlb-mremap Fixes: 12b613206474 ("mm, hugepages: add hugetlb vma mremap() test") Acked-by: David Hildenbrand (Arm) Tested-by: Venkat Rao Bagalkote Signed-off-by: Sayali Patil --- tools/testing/selftests/mm/hugetlb-mremap.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/mm/hugetlb-mremap.c b/tools/testing/se= lftests/mm/hugetlb-mremap.c index d239905790dd..00b4c2cc95a6 100644 --- a/tools/testing/selftests/mm/hugetlb-mremap.c +++ b/tools/testing/selftests/mm/hugetlb-mremap.c @@ -86,25 +86,14 @@ static void register_region_with_uffd(char *addr, size_= t len) if (ioctl(uffd, UFFDIO_API, &uffdio_api) =3D=3D -1) ksft_exit_fail_msg("ioctl-UFFDIO_API: %s\n", strerror(errno)); =20 - /* Create a private anonymous mapping. The memory will be - * demand-zero paged--that is, not yet allocated. When we - * actually touch the memory, it will be allocated via - * the userfaultfd. - */ - - addr =3D mmap(NULL, len, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (addr =3D=3D MAP_FAILED) - ksft_exit_fail_msg("mmap: %s\n", strerror(errno)); - - ksft_print_msg("Address returned by mmap() =3D %p\n", addr); - - /* Register the memory range of the mapping we just created for - * handling by the userfaultfd object. In mode, we request to track - * missing pages (i.e., pages that have not yet been faulted in). + /* Register the passed memory range for handling by the userfaultfd objec= t. + * In mode, we request to track missing pages + * (i.e., pages that have not yet been faulted in). */ if (uffd_register(uffd, addr, len, true, false, false)) ksft_exit_fail_msg("ioctl-UFFDIO_REGISTER: %s\n", strerror(errno)); + + ksft_print_msg("Registered memory at address %p with userfaultfd\n", addr= ); } =20 int main(int argc, char *argv[]) --=20 2.52.0 From nobody Sun May 24 21:36:40 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 4633B399039; Thu, 21 May 2026 06:48:49 +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=1779346131; cv=none; b=kOzbdeLrBXFLba2EkZ4Dj6CVk4r71QzmLSZnEaP1TNkS91r+lziBz31Xs1fqobRzbkgrAkRgaxMgfiyOJBNtOCSwug8QM3FYrfd4PPm1Jl9QkRSxIgOj/In55OTiC9Bfp8oKrZ+pOsjo+y3Rr9JusrEpjmGjI2T83gGz7D0yUUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779346131; c=relaxed/simple; bh=MZqXB1sp4Gj4TiePhCzviXPjbfmNP06AWs6goDaFplM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GNv0GjTGjHYAiyas76zSIU0jcaSiYC6jmY61gUV9bMlKLFs+kEEDYtt5W3xroYcgZSIPw6tOwBcN2qV45R7uUREEbbzF9JYKmC12A80v48q4rp589jI93AKIhLnRqF8tIvBFPsMVp/57z5d0PJm78+AjbhlZPZbZE96T1QmcLRI= 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=FGrDqY6s; 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="FGrDqY6s" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64L66Bgp3628517; Thu, 21 May 2026 06:48:28 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=A94GLQ4GcTeWPTRQG n8aC6W/mrfCd8XhQQq2VXeeAxM=; b=FGrDqY6sneZ31K4fdHDfNBpdYxXQU8Y3y tEIMqvJHF/u770HjWmjnrXc3CCk/wsWHuLQx1x89GeHTYvFCjjzrwtx2FIJWfRQ9 kitaKld9jVMa0C1yVoAm6cQ2n0n70Pb5pVBboLTfPfp0PhVyurHQqhIkWGHhkycD nd3AugpPpmcVZy3kD8J+nIE/7EkMv4g+jBy/39wZ2owNSI6U4uvRzDB3OIa0jK2s OSfHS+aLWE7DMgPF9nL8qN37i+RZ95foHzA7YFGEH5cHulJZJTOYksXMdULzdZcN cuRM3L7vB9X7RPSMVr6TyOanHqkvJHyZCDAn86To8hVyumLo0pyrw== 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 4e6hawcdc5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:26 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64L6dAaG009776; Thu, 21 May 2026 06:48:26 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e74dhtrpf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:25 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64L6mMCS50463140 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 May 2026 06:48:22 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E25D320043; Thu, 21 May 2026 06:48:21 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9B9F820040; Thu, 21 May 2026 06:48:18 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 21 May 2026 06:48:18 +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 v7 09/13] selftests/mm: ensure destination is hugetlb-backed in hugetlb-mremap Date: Thu, 21 May 2026 12:17:49 +0530 Message-ID: <367644df45c65098f23e3945c6a80f4b8a8964a6.1779296493.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-Spam-Details-Enc: AW1haW4tMjYwNTIxMDA2MiBTYWx0ZWRfXxK6S+CvmQwg6 oxCp0jtK6dxsTpEEDmlPWYFjIHLlm44AvIRPuNTU7T11xe2g6518FpYFaCEgm+jicZjAlG0b60Y K1d4+ErvoZtfVpQD/8n6NOzLfOUk4D9J1eDvrlTQkBswnTkiFipSloV5tf/1Dq9taaMShioHwz+ caBltjvii1IIBRtCTJJLUVd+UUJeCkzoHoS92A1jaJYbGau390tEbM6EcIIztG02rMf52VDsONa NWSi4Zl1CH04/Os2/P4xnn4De64ve4fyVBkq5wEAsOYAbr2n1Hir+ICsCzjEOUZMVMK4iLYrIpu tKg6H/tLkXnnYFKJPnZUr45QlN4NpwgkCHzQRV3baOZCRIeUrl2YvPxtmT6tELwBg7VxHAIAsQD WVb7f7S0ffRDm9AXtyxMmxFJyrvoram0LlDCZb5JC/7wlFvHcQwmk30Ii9lnaFqU7L3yhzYLAY8 Yl+pZNk62AfcA+errHA== X-Authority-Analysis: v=2.4 cv=Np/htcdJ c=1 sm=1 tr=0 ts=6a0eaabb cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=njH7lnjfnPuJvX8OOgMA:9 X-Proofpoint-ORIG-GUID: xqIuYuIF4ps_1A54LtPWGKsrPRX4ITLR X-Proofpoint-GUID: ZdW7gwnlZ6n6TpjX7t_X8P_C2hGw29u1 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-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210062 Content-Type: text/plain; charset="utf-8" The hugetlb-mremap selftest reserves the destination address using a anonymous base-page mapping before calling mremap() with MREMAP_FIXED, while the source region is hugetlb-backed. When remapping a hugetlb mapping into a base-page VMA may fail with: mremap: Device or resource busy This is observed on powerpc hash MMU systems where slice constraints and page size incompatibilities prevent the remap. Ensure the destination region is created using MAP_HUGETLB so that both source and destination VMAs are hugetlb-backed and compatible. Update the FLAGS macro to include MAP_HUGETLB | MAP_SHARED so that both mappings are hugetlb-backed and compatible. Also use the macro for the mmap() calls to avoid repeating the flag combination. This ensures the test reliably exercises hugetlb mremap instead of failing due to VMA type mismatch. Fixes: 12b613206474 ("mm, hugepages: add hugetlb vma mremap() test") Tested-by: Venkat Rao Bagalkote Signed-off-by: Sayali Patil --- tools/testing/selftests/mm/hugetlb-mremap.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/mm/hugetlb-mremap.c b/tools/testing/se= lftests/mm/hugetlb-mremap.c index 00b4c2cc95a6..ed3d92e862d8 100644 --- a/tools/testing/selftests/mm/hugetlb-mremap.c +++ b/tools/testing/selftests/mm/hugetlb-mremap.c @@ -32,7 +32,7 @@ #define MB_TO_BYTES(x) (x * 1024 * 1024) =20 #define PROTECTION (PROT_READ | PROT_WRITE | PROT_EXEC) -#define FLAGS (MAP_SHARED | MAP_ANONYMOUS) +#define FLAGS (MAP_HUGETLB | MAP_SHARED) =20 static void check_bytes(char *addr) { @@ -132,23 +132,20 @@ int main(int argc, char *argv[]) =20 /* mmap to a PUD aligned address to hopefully trigger pmd sharing. */ unsigned long suggested_addr =3D 0x7eaa40000000; - void *haddr =3D mmap((void *)suggested_addr, length, PROTECTION, - MAP_HUGETLB | MAP_SHARED | MAP_POPULATE, fd, 0); + void *haddr =3D mmap((void *)suggested_addr, length, PROTECTION, FLAGS, f= d, 0); ksft_print_msg("Map haddr: Returned address is %p\n", haddr); if (haddr =3D=3D MAP_FAILED) ksft_exit_fail_msg("mmap1: %s\n", strerror(errno)); =20 /* mmap again to a dummy address to hopefully trigger pmd sharing. */ suggested_addr =3D 0x7daa40000000; - void *daddr =3D mmap((void *)suggested_addr, length, PROTECTION, - MAP_HUGETLB | MAP_SHARED | MAP_POPULATE, fd, 0); + void *daddr =3D mmap((void *)suggested_addr, length, PROTECTION, FLAGS, f= d, 0); ksft_print_msg("Map daddr: Returned address is %p\n", daddr); if (daddr =3D=3D MAP_FAILED) ksft_exit_fail_msg("mmap3: %s\n", strerror(errno)); =20 suggested_addr =3D 0x7faa40000000; - void *vaddr =3D - mmap((void *)suggested_addr, length, PROTECTION, FLAGS, -1, 0); + void *vaddr =3D mmap((void *)suggested_addr, length, PROTECTION, FLAGS, f= d, 0); ksft_print_msg("Map vaddr: Returned address is %p\n", vaddr); if (vaddr =3D=3D MAP_FAILED) ksft_exit_fail_msg("mmap2: %s\n", strerror(errno)); --=20 2.52.0 From nobody Sun May 24 21:36:40 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 19C02399017; Thu, 21 May 2026 06:48:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779346130; cv=none; b=r8cJq4+fukw7bWXaF/gbrTR/NrmeEm2MqWudq254oPQpxQULS7c7pGUqiLtMvPn/nACZUl/ElvREtyXOdEjzFrT6kLXpoHVGMiei++sUkdfZ+ed58dQYbU72/kbaTp+2IfgOM3CdX11B6JwNj15RalJqhwoyZg21tUTvpwByuNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779346130; c=relaxed/simple; bh=ushnOu1mTY8BYps9HGQrmKSLkhF2Ruq3mzuSepiXAm8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n6nzGsC40gnx0en3kLpF8qnVyE9Du7No7KeL6mIhaM8ZNL99aVi4uXtjfH12ntR+JDHZ8/wsNA4DPZJtNmDlQYvMZ1pyRRy0hzi/mYb6+zVMP7Yx+9hQGTaw1xJ5AWDwzISbtkLn2+GmfogeAH4lRBQ4L8PBwPToIPpfCG16QUw= 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=gBO+Kf5I; arc=none smtp.client-ip=148.163.156.1 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="gBO+Kf5I" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64L2lBOm069628; Thu, 21 May 2026 06:48:30 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=c75aam0Ymf20+UpHF k7pH2xwhCNVScu6l+3UVxdrvZE=; b=gBO+Kf5I274AG57O6OQdAaXfl1n4iN762 zICNnGqq4pu0bn+cw5BS+iB5PExV1yrY/NkvVHOJRguwuYuauVMY9ZCD87JuVeDU BrwPEvI4y5Iqj1jmYLA1g4OHG644sfUBLMbc45KQlHHJ2ji4kl0ApjyDLZ7OjKJK 8FfmKLb8o2U3U7NmPcN19DYtjCFFCLWVOg/2GUCLSt3h4de0Tlyn6f4oTR7IVZYp JUFxW1Lc1fOc5WEx1U1R3fn7j4FsYg4mHr3eNm1gKpfUZ+uIvJv2l+gw9h57cYFL FPCDanC5GvwHAbKPCvlAutbz6K7KIju3EzNbmK+14yr70pDdwRmtA== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e6h8mwfwg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:29 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64L6d6in003597; Thu, 21 May 2026 06:48:28 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e754gjkug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:28 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64L6mPxp48824634 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 May 2026 06:48:25 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 330D320043; Thu, 21 May 2026 06:48:25 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 43BBE20040; Thu, 21 May 2026 06:48:22 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 21 May 2026 06:48:22 +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 v7 10/13] selftests/mm: skip uffd-wp-mremap if UFFD write-protect is unsupported Date: Thu, 21 May 2026 12:17:50 +0530 Message-ID: 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: w3CxwwPr800L2Lw7kCvtEmxLurTbiHzo X-Authority-Analysis: v=2.4 cv=GYMnWwXL c=1 sm=1 tr=0 ts=6a0eaabe cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=njH7lnjfnPuJvX8OOgMA:9 X-Proofpoint-ORIG-GUID: im54uowdCAl_43vhwGui22KJhSluskMK X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIxMDA2MiBTYWx0ZWRfX3jD4vaifPvzr 5Mp2iMho1gyyXWLaDQz3bREV2Ilk+rlomm6P3jjo7qVO37XuU15J3OhVsHuqshqDgiKGwhkAcIz /aE+n7iP2kGCboZ5umA3w0sXANwezvTxM7cA2IhL75bwQIrrKfi1T6lTjdzTO14FB3fnvgRp64X zkiVcIGnqF6F66jLg443RfuXm61C0/BxScyE+H84s6uvYzdT9pLoLjEERqgULOCVesidOj0BVIp VXE51Q3ARI1M7FenoMOTHRZJovtCpOf0A84eSQ2pV1NDQChmL12b3nPykdxk+YIk8hJR5h2jCVy 9/M0nc8neARN834hE60ls9FVYOc74Bk2deDeulgRwpvN1S8a6y86zOKuoz75neW4vKbjXavEF/D Ckg2awmcbj14aSlU0ZVkO3cb7lJ6VffClToo+adirO3a6RPSFwLF016s3NUpC/vk6JZH7kiZXug 1e9vB2vQ78MkRUVR68g== 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-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 clxscore=1015 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210062 Content-Type: text/plain; charset="utf-8" The uffd-wp-mremap test requires the UFFD_FEATURE_PAGEFAULT_FLAG_WP capability. On systems where userfaultfd write-protect is not supported, uffd_register() fails and the test reports failures. Check for the required feature at startup and skip the test when the UFFD_FEATURE_PAGEFAULT_FLAG_WP capability is not present, preventing false failures on unsupported configurations. Before patch: running ./uffd-wp-mremap ------------------------ [INFO] detected THP size: 256 KiB [INFO] detected THP size: 512 KiB [INFO] detected THP size: 1024 KiB [INFO] detected THP size: 2048 KiB [INFO] detected hugetlb page size: 2048 KiB [INFO] detected hugetlb page size: 1048576 KiB 1..24 [RUN] test_one_folio(size=3D65536, private=3Dfalse, swapout=3Dfalse, hugetlb=3Dfalse) not ok 1 uffd_register() failed [RUN] test_one_folio(size=3D65536, private=3Dtrue, swapout=3Dfalse, hugetlb=3Dfalse) not ok 2 uffd_register() failed [RUN] test_one_folio(size=3D65536, private=3Dfalse, swapout=3Dtrue, hugetlb=3Dfalse) not ok 3 uffd_register() failed [RUN] test_one_folio(size=3D65536, private=3Dtrue, swapout=3Dtrue, hugetlb=3Dfalse) not ok 4 uffd_register() failed [RUN] test_one_folio(size=3D262144, private=3Dfalse, swapout=3Dfalse, hugetlb=3Dfalse) not ok 5 uffd_register() failed [RUN] test_one_folio(size=3D524288, private=3Dfalse, swapout=3Dfalse, hugetlb=3Dfalse) not ok 6 uffd_register() failed . . . Bail out! 24 out of 24 tests failed Totals: pass:0 fail:24 xfail:0 xpass:0 skip:0 error:0 [FAIL] not ok 1 uffd-wp-mremap # exit=3D1 After patch: running ./uffd-wp-mremap ------------------------ 1..0 # SKIP uffd-wp feature not supported [SKIP] ok 1 uffd-wp-mremap # SKIP Tested-by: Venkat Rao Bagalkote Signed-off-by: Sayali Patil --- tools/testing/selftests/mm/uffd-wp-mremap.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/testing/selftests/mm/uffd-wp-mremap.c b/tools/testing/se= lftests/mm/uffd-wp-mremap.c index 90ac410c6c6f..c973d6722720 100644 --- a/tools/testing/selftests/mm/uffd-wp-mremap.c +++ b/tools/testing/selftests/mm/uffd-wp-mremap.c @@ -19,6 +19,17 @@ static size_t thpsizes[20]; static int nr_hugetlbsizes; static unsigned long hugetlbsizes[10]; =20 +static void check_uffd_wp_feature_supported(void) +{ + uint64_t features =3D 0; + + if (uffd_get_features(&features)) + ksft_exit_skip("failed to get available features (%d)\n", errno); + + if (!(features & UFFD_FEATURE_PAGEFAULT_FLAG_WP)) + ksft_exit_skip("uffd-wp feature not supported\n"); +} + static int detect_thp_sizes(size_t sizes[], int max) { int count =3D 0; @@ -338,6 +349,8 @@ int main(int argc, char **argv) =20 hugepage_save_settings(true, true); =20 + check_uffd_wp_feature_supported(); + pagesize =3D getpagesize(); nr_thpsizes =3D detect_thp_sizes(thpsizes, ARRAY_SIZE(thpsizes)); nr_hugetlbsizes =3D hugetlb_setup(1, hugetlbsizes, ARRAY_SIZE(hugetlbsize= s)); --=20 2.52.0 From nobody Sun May 24 21:36:40 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 1F83F399017; Thu, 21 May 2026 06:48:54 +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=1779346136; cv=none; b=e2KXePDyZw3C4l5H2owsv2erc43en65f/no/UlJJrCXHiaa0kWI264DgnChSidb1qkG499x0TTszP4GOt+4Ul19Xlt+JZPfUCryQsX6fZ5v1koGSfDQxEub/4bOQ9rnS6GoMsU60Rm6rT61xFV9T0WjSksWvdAE1R8+991bmvRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779346136; c=relaxed/simple; bh=kxV8+1kwk5iTCGncuidvU0c/O6/K7qcPLyYRJgPBhSU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dneZqN3vvr+FoMgjx+fTlVHizVEYm7/B0NpdHV8ISLVerqRR8cAx3+zSx/cXw8qBCsv6WVOPbnLZTVVZ06kBLf4RMwkwttd/wVpyia1mz/0s7c8r5aud8sI4QxgoInallWmGSZpiQEG9QyyVcfiqlD95tEnuFeRLSmZVJ5YdYk8= 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=Mlxj7w+d; 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="Mlxj7w+d" 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 64KL6B651853987; Thu, 21 May 2026 06:48:34 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=FQF9FZs2eg1Enek9q TboZeMmaUyOa6cHAXzM+prlfBI=; b=Mlxj7w+dI6BPwWKLt9DobguPgTezmwtgq 6IYVol4dfvkvBY/EnYfZVcQnZoCpyJJh+WF373/4/gMEqetOPEpiHc5hp8OUhoi7 CvwqhzfF8v5d81LD2RR1ExLLR38RZ7OaCQ6RiSEaywenuJ51ydA/+2cK97oK+cVh jrNs0RiSnxshveuwYP0ZuYMu9XBIy021BB/rKUGR284frDtaxHE+aM5C8KCJ6xw7 88BmtBqHxXTR1ZEwVbxe6Y7d7QIAHuvpwQmlQVEcYhLjLQiyg8towhyWQVPBH4mh mRQJc98aorhoOtuKIhRPkTNQ/JdrhasJww06oou8PYafrcBo5Fwug== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e6hb8mbp4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:33 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64L6dIbu018383; Thu, 21 May 2026 06:48:32 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e75kyajev-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:32 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64L6mSAK24248782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 May 2026 06:48:28 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BC0E420043; Thu, 21 May 2026 06:48:28 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D64520040; Thu, 21 May 2026 06:48:25 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 21 May 2026 06:48:25 +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 v7 11/13] selftests/mm: skip uffd-stress test when nr_pages_per_cpu is zero Date: Thu, 21 May 2026 12:17:51 +0530 Message-ID: <0707e9a0f1b3dd904c4a069b91db317f9c160faa.1779296493.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-Spam-Details-Enc: AW1haW4tMjYwNTIxMDA2MiBTYWx0ZWRfX5T9MuEj6il3V UJOg1gPjYjwcVi+pLoVBKsSGrOjMDf2eR0Ci18QiQ0WDrYrrN1MYpNRfvffO502mEKxKRhj8MEB W1H7oKAVeW+X83PL+8oIcFDLRguerUwu/uSVHEsQEyURYsj+q3jv8oFRU2vgqxTDGbbOIAAMwLu Gg0MfFUeeufQ150M36iL4soXznGKJIuVLlTBzJiPmU7v/1KCoCCllgtqTRADt+Qr0blKBT7OO7F mcf47vY7cTeyYheZ6yj7Z9XDvliIrZ7hZJAt5JscB6RDeB7sCnnrcj38qFrs6LSC92re1R2lRiJ mrgYdqMnQI/qOYJa5Jnnufj85WZW3hKMS21PJw22zrayE2n44trERaKpqbJzS9HDt+WnkDwQnSY ZIvM67sU8/Tg0M+XCJtClwKckQ1AX0q78YL72RiIdhwNFnQKI5XaHT7EJMVo0R6z9DY69N8IP5M Pt3rLFxcdU5lOtAuUjQ== X-Proofpoint-GUID: Z1xE03N4YSu0Q5Q9srAd_BPqDsz20iYe X-Proofpoint-ORIG-GUID: 9jLyuVdzYQWkAs55cBOCg5EFOmwt-_YL X-Authority-Analysis: v=2.4 cv=aYBRWxot c=1 sm=1 tr=0 ts=6a0eaac1 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=Ikd4Dj_1AAAA:8 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=QLFraA1qSxkZgXf6QZAA:9 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-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 phishscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210062 Content-Type: text/plain; charset="utf-8" uffd-stress currently fails when the computed nr_pages_per_cpu evaluates to zero: nr_pages_per_cpu =3D bytes / page_size / nr_parallel This can occur on systems with large hugepage sizes (e.g. 1GB) and a high number of CPUs, where the total allocated memory is sufficient overall but not enough to provide at least one page per cpu. In such cases, the failure is due to insufficient test resources rather than incorrect kernel behaviour. Update the test to treat this condition as a test skip instead of reporting an error. Fixes: db0f1c138f18 ("selftests/mm: print some details when uffd-stress get= s bad params") Acked-by: Zi Yan Acked-by: David Hildenbrand (Arm) Tested-by: Venkat Rao Bagalkote Signed-off-by: Sayali Patil --- tools/testing/selftests/mm/uffd-stress.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/mm/uffd-stress.c b/tools/testing/selft= ests/mm/uffd-stress.c index 43cc79590136..39e13e2078a9 100644 --- a/tools/testing/selftests/mm/uffd-stress.c +++ b/tools/testing/selftests/mm/uffd-stress.c @@ -489,9 +489,9 @@ int main(int argc, char **argv) =20 gopts->nr_pages_per_cpu =3D bytes / gopts->page_size / gopts->nr_parallel; if (!gopts->nr_pages_per_cpu) { - _err("pages_per_cpu =3D 0, cannot test (%lu / %lu / %lu)", - bytes, gopts->page_size, gopts->nr_parallel); - usage(); + ksft_print_msg("pages_per_cpu =3D 0, cannot test (%zu / %lu / %lu)\n", + bytes, gopts->page_size, gopts->nr_parallel); + return KSFT_SKIP; } =20 bounces =3D atoi(argv[3]); --=20 2.52.0 From nobody Sun May 24 21:36:40 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 1F79F395ACB; Thu, 21 May 2026 06:48:55 +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=1779346137; cv=none; b=J3GxgmI87OX549Oaky8QIiJjtSCWghiPtBx2JX8mEPypAxpc7yR4mprlad4chV7dJYeUpC9quoGFdKQu8TC4e5rHBinkBsfHPG+tStSnsHHVJ8h7/xq89RRpdKH22VFfcQqt0kdzw20dC08pDGj9kXc2ASWT+WwW9MgziM15484= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779346137; c=relaxed/simple; bh=BvVGNaDo429LLSn1sgJNknkT6bLNQng0hT0ABwIM2a0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B+Hr895f3+iYu2aLjsfmTKBH4BQKi24zM6sF0S5PtEkZKbGrkOeP5mm4KQ7WMkjVkEBiqwRt8kD4w57PHH8mUM5GqWfR5NlW3xrbgBJnYVzC858EsugXA8HG0fih5xO9gskjVqoFEUJ0exkhut0P0BBp8hKX/rsIPVKZDNUlYbw= 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=SMEWPbgT; 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="SMEWPbgT" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64L3Rbem470901; Thu, 21 May 2026 06:48:37 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=mC2WsYZfhgVjdLpYp 2qK3XgGPT458/2QAjeD/0bOqxw=; b=SMEWPbgTyM5wyew5lTu8NAJx9d+ebSpXB j/6L/aBpfB5Ichn7I7IhD/zVBm9GXDEqMoFAkkskOtx/NGYvzIeubkhwCa9hffsM g5t5+NP4Sq0qOCgdgKLrimXRDN9ZDFccnGrDB6T6wErcG3V5HFU2jKGO7shWVQw5 UfrvqBXF9qpEPrgHv9MtCQigRo1RA9uQespQflZjNQCjCDM7Wsa7+T2b173eMaDb /SQ0ZkeI/7wMvE9bEHxZ9AcGZfGGffkcw6RFyqMA44ZUPUp5Y+Zn2Z1BXh21BD20 yNzj9e/87sOSmMyN4D9wTCnVRYppjzAYJHO1eZz38JRzHTRCyjhgg== 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 4e6h88mcev-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:36 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64L6dAnF009772; Thu, 21 May 2026 06:48:36 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e74dhtrqj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:36 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64L6mWiS48824700 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 May 2026 06:48:32 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5B1F720043; Thu, 21 May 2026 06:48:32 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2358520040; Thu, 21 May 2026 06:48:29 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 21 May 2026 06:48:28 +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 v7 12/13] selftests/mm: move hwpoison setup into run_test() and silence modprobe output for memory-failure category Date: Thu, 21 May 2026 12:17:52 +0530 Message-ID: <93441f34f7ef5add47d1a130d03daa79e21b5050.1779296493.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-ORIG-GUID: 9VugsKY05zg6rR89hxxUeUzNOm6O2Il9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIxMDA2MiBTYWx0ZWRfX4t8Jzc0Vb+Sa bpotnjv6nEyj/qlLGcHQccm5Pk7hpHTlMBHL2JDGIrIS2R2gxJkcabnXCqJrX5yMKchE9jSylsG 4XL7naaEzCDEjkdSs3k0KB35rfidjrR+dObof2YChC11469dkDCkPBHiVlzq1SHzH22EG/Vk7jC iOxAJjMjOufSlhYwytjq2Y6iEpP22ZKHGCKcKpofEZax9knM8fAojDsYkLB9FsFhyAwQebCZzPW cIPXZ0QKP33ST6wii0cJAKzv5VPVCWZ5cfDRuupfh3FQezcmCvFkaCafmKB1QXvgLrD1p89qwQU e705WGrVNBy5WO5DqmgTPRAtOL+NAYHFq390h7B6OCb+O6LqyxahAxHyKPEqeQfw/ExtlcWTMe/ 0DaPjMy06R3ljrEs+SeG20Z75yRA01ZeB3kQqNmFe6PVTSDJTa1Tm7ux7/g3qCd220jbXVjC4bl BKmEV8Oujq9hvxLD+Fw== X-Proofpoint-GUID: qs7GHM6fPp2f7DHNK26s1pCgdYKy4xYY X-Authority-Analysis: v=2.4 cv=apyCzyZV c=1 sm=1 tr=0 ts=6a0eaac5 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=i0EeH86SAAAA:8 a=VnNF1IyMAAAA:8 a=RKaXm5X2BghK_eAo6iIA:9 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-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 suspectscore=0 adultscore=0 spamscore=0 phishscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210062 Content-Type: text/plain; charset="utf-8" run_vmtests.sh contains special handling to ensure the hwpoison_inject module is available for the memory-failure tests. This logic was implemented outside of run_test(), making the setup category-specific but managed globally. Move the hwpoison_inject handling into run_test() and restrict it to the memory-failure category so that: 1. the module is checked and loaded only when memory-failure tests run, 2. the test is skipped if the module or the debugfs interface (/sys/kernel/debug/hwpoison/) is not available. 3. the module is unloaded after the test if it was loaded by the script. This localizes category-specific setup and makes the test flow consistent with other per-category preparations. While updating this logic, fix the module availability check. The script previously used: modprobe -R hwpoison_inject The -R option prints the resolved module name to stdout, causing every run to print: hwpoison_inject in the test output, even when no action is required, introducing unnecessary noise. Replace this with: modprobe -n hwpoison_inject which verifies that the module is loadable without producing output, keeping the selftest logs clean and consistent. Also, ensure that skipped tests do not override a previously recorded failure. A skipped test currently sets exitcode to ksft_skip even if a prior test has failed, which can mask failures in the final exit status. Update the logic to only set exitcode to ksft_skip when no failure has been recorded. Fixes: ff4ef2fbd101 ("selftests/mm: add memory failure anonymous page test") Reviewed-by: Miaohe Lin Tested-by: Venkat Rao Bagalkote Signed-off-by: Sayali Patil --- tools/testing/selftests/mm/run_vmtests.sh | 62 +++++++++++++++-------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/self= tests/mm/run_vmtests.sh index 043aa3ed2596..8c296dedf047 100755 --- a/tools/testing/selftests/mm/run_vmtests.sh +++ b/tools/testing/selftests/mm/run_vmtests.sh @@ -180,6 +180,9 @@ pretty_name() { # Usage: run_test [test binary] [arbitrary test arguments...] run_test() { if test_selected ${CATEGORY}; then + local skip=3D0 + local LOADED_HWPOISON_INJECT_MOD=3D0 + # On memory constrainted systems some tests can fail to allocate hugepag= es. # perform some cleanup before the test for a higher success rate. if [ ${CATEGORY} =3D=3D "thp" -o ${CATEGORY} =3D=3D "hugetlb" ]; then @@ -194,13 +197,45 @@ run_test() { fi fi =20 + # Ensure hwpoison_inject is available for memory-failure tests + if [ "${CATEGORY}" =3D "memory-failure" ]; then + # Try to load hwpoison_inject if not present. + HWPOISON_DIR=3D/sys/kernel/debug/hwpoison/ + if [ ! -d "$HWPOISON_DIR" ]; then + if ! modprobe -n hwpoison_inject > /dev/null 2>&1; then + echo "Module hwpoison_inject not found, skipping..." \ + | tap_prefix + skip=3D1 + else + modprobe hwpoison_inject > /dev/null 2>&1 + LOADED_HWPOISON_INJECT_MOD=3D1 + if [ ! -d "$HWPOISON_DIR" ]; then + echo "hwpoison debugfs interface not present" \ + | tap_prefix + skip=3D1 + fi + fi + fi + + fi + local test=3D$(pretty_name "$*") local title=3D"running $*" local sep=3D$(echo -n "$title" | tr "[:graph:][:space:]" -) printf "%s\n%s\n%s\n" "$sep" "$title" "$sep" | tap_prefix =20 - ("$@" 2>&1) | tap_prefix - local ret=3D${PIPESTATUS[0]} + if [ $skip -eq 1 ]; then + local ret=3D$ksft_skip + else + ("$@" 2>&1) | tap_prefix + local ret=3D${PIPESTATUS[0]} + fi + + # Unload hwpoison_inject if we loaded it + if [ "${LOADED_HWPOISON_INJECT_MOD}" =3D "1" ]; then + modprobe -r hwpoison_inject > /dev/null 2>&1 + fi + count_total=3D$(( count_total + 1 )) if [ $ret -eq 0 ]; then count_pass=3D$(( count_pass + 1 )) @@ -210,7 +245,9 @@ run_test() { count_skip=3D$(( count_skip + 1 )) echo "[SKIP]" | tap_prefix echo "ok ${count_total} ${test} # SKIP" | tap_output - exitcode=3D$ksft_skip + if [ $exitcode -eq 0 ]; then + exitcode=3D$ksft_skip + fi else count_fail=3D$(( count_fail + 1 )) echo "[FAIL]" | tap_prefix @@ -422,24 +459,7 @@ CATEGORY=3D"page_frag" run_test ./test_page_frag.sh no= naligned =20 CATEGORY=3D"rmap" run_test ./rmap =20 -# Try to load hwpoison_inject if not present. -HWPOISON_DIR=3D/sys/kernel/debug/hwpoison/ -if [ ! -d "$HWPOISON_DIR" ]; then - if ! modprobe -q -R hwpoison_inject; then - echo "Module hwpoison_inject not found, skipping..." - else - modprobe hwpoison_inject > /dev/null 2>&1 - LOADED_MOD=3D1 - fi -fi - -if [ -d "$HWPOISON_DIR" ]; then - CATEGORY=3D"memory-failure" run_test ./memory-failure -fi - -if [ -n "${LOADED_MOD}" ]; then - modprobe -r hwpoison_inject > /dev/null 2>&1 -fi +CATEGORY=3D"memory-failure" run_test ./memory-failure =20 echo "SUMMARY: PASS=3D${count_pass} SKIP=3D${count_skip} FAIL=3D${count_fa= il}" | tap_prefix echo "1..${count_total}" | tap_output --=20 2.52.0 From nobody Sun May 24 21:36:40 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 863E3395AEB; Thu, 21 May 2026 06:49:04 +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=1779346145; cv=none; b=JFpuZRyET3XiupATBlWJ9jW8xgWfOx/xFmR2WyouJQm3/nW+GTRa1mPswwkvID/X+k+A6VBbIlR7z1uAV3nqbKIz8+raNqE9ButJKniSVHMriS8LBDehuHWYrNEdESt2jITD+jdS3l1pzSm9UK3EG9A4ozjM/Shq9eaRanEeL8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779346145; c=relaxed/simple; bh=wf2kRa8wgKlreMyVss2ZcyoJpO8TYgJk+dNO2NsDlX4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U4A5HOYrRguqnYLgiCIAu0ExZIXxDj+WIWZgkfa5gTJtQE/36vt354OvnqI26yB1s9gQjpMHsn0uWUmd9bsvPF0amaPZIQpinvLdxaWuT5+i4X6zyWomSbLuKCNvzhSF87/tr33Jbd14l+WGwwu8a5uqhKfL/PRU4mO2W5pGvsQ= 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=WyHTV82z; 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="WyHTV82z" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64KIvSiV2082630; Thu, 21 May 2026 06:48:41 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=Nq5DzWgRtL4E1DjO2 dFfdwfaryhi9dLpfVcJI5A/LOU=; b=WyHTV82z1KFFn4BB8fy5BaybULEjJQZZ1 wrf4oGmjLxBsjRBXCifazLl+LnLdbVX6ZLKMyYUjgjgNuNN+PnZLAgoaqU7Z7k/n qgmAYiIov68p62Ysgd7keNQwPYPyZFWYXg2sBtWyE4D01VGgHoNCaH8xLE9m5CEZ D4RXvKyKzgSyw1xM46a5bTmml5+Nf7yrGn6fXCvJ2rvFd/O2M1WDLEaZYqlDBs3g Zn663AYQfT+/mhCSeVYta3eUBzVS2+QoHPxOGdooKrCU/BJr2g81t4annnXEBNI6 VB5WO/mC8uR3G3m9sUfjGmZoi0bi4TXYzsgX+416ZyFiEm+1dblqw== 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 4e6h88mcey-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:40 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64L6dHiD009806; Thu, 21 May 2026 06:48:39 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e74dhtrr1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 06:48:39 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64L6mZKB24248794 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 May 2026 06:48:36 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D3F392004B; Thu, 21 May 2026 06:48:35 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A23D920040; Thu, 21 May 2026 06:48:32 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 21 May 2026 06:48:32 +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 v7 13/13] selftests/mm: clarify alternate unmapping in compaction_test Date: Thu, 21 May 2026 12:17:53 +0530 Message-ID: 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-ORIG-GUID: 1pF53W5BIdKYW_lxTRZ2eoamRBw1P_PD X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIxMDA2MiBTYWx0ZWRfX06tcHDJDJrMG YTFU4A6E26qTAclF1E1qDWHIUoF9KXE8DEwb/pMYeYuOeVyLcCLybY1x5fGVUCSim145a1mlZD8 GfjwxHYaqL2E4zu6APXvFl4rvBOA4ziF4hAXjNex9HYZzny/0JqUC1PI96EWVlUyuKLm31amdnI MLDCNdnJjFQHS0LKK48qb2Dd68yCdxjC+F4RQKg0JSs8vmfAv4i8vu8tAjmIQSKfFVEKgZt/eLp dBsWKBBBd9hmQJWBqYYvbLFiIIFWI+sIwZ446xwW4jiiBje7q3NqOsvfCRDAjbjZ8Nsn3EUT+v9 WweWPONzdSF+DHLTri2ON7OuR2cTZM2OYVnLtvEAheoLqsxAGp93I3rwBgT/CwEjjEEEuEHL4eW C/NbNTJmy0naTFHV6RSZI0FYgik0rTGbFyzXyKpTWjNMbPZ3oL21U0f1bdxNmbr9FGAoZkH1xEw 35JkQVNyzF1ljtxr0CA== X-Proofpoint-GUID: ypZ8jMGmHbV48Chdn4zcz8L_7sFw0qly X-Authority-Analysis: v=2.4 cv=apyCzyZV c=1 sm=1 tr=0 ts=6a0eaac8 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=THlBPJCoSQ4NST9nLWYA:9 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-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 suspectscore=0 adultscore=0 spamscore=0 phishscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210062 Content-Type: text/plain; charset="utf-8" Add a comment explaining that every other entry in the list is unmapped to intentionally create fragmentation with locked pages before invoking check_compaction(). Fixes: bd67d5c15cc1 ("Test compaction of mlocked memory") Tested-by: Venkat Rao Bagalkote Signed-off-by: Sayali Patil --- tools/testing/selftests/mm/compaction_test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/mm/compaction_test.c b/tools/testing/s= elftests/mm/compaction_test.c index de0633f9a7e5..5b582588e015 100644 --- a/tools/testing/selftests/mm/compaction_test.c +++ b/tools/testing/selftests/mm/compaction_test.c @@ -181,6 +181,9 @@ int main(int argc, char **argv) mem_fragmentable_MB -=3D MAP_SIZE_MB; } =20 + /* Unmap every other entry in the list to create fragmentation with + * locked pages before invoking check_compaction(). + */ for (entry =3D list; entry !=3D NULL; entry =3D entry->next) { munmap(entry->map, MAP_SIZE); if (!entry->next) --=20 2.52.0