From nobody Mon May 4 13:03:30 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 C990B1DED5C; Mon, 4 May 2026 08:25:41 +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=1777883143; cv=none; b=HRm3Q9p+EsK5voAPJgXtkAp/S39XpG0kYUkfgz/wYVIytGrto6BHxw3mtogjXRqiuiYmm/e3rE9AmFbOxCfFvSocNZxKCAAUNSSZiy+Qz19rawGEnnLg2a7y7KricScCJPCy0nLjo7CRUz9oru43C9F4DrbXalWVZ2WBtI++ScU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777883143; c=relaxed/simple; bh=IN5L6ThafTi9EFIA+WnMTzgU9QH9jsywJqx+izYz7G0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kvWwLsCykMGft3+x4146I2zmz7/5nHhrmakhyFcI8vYA0ePwRO/0Secmr2Ifl8Uv2OVEgbhHIHJ2wSDOmIHa2kh4pbjUaW6vwU9+ob7M9Dej1hj+m5Lz3dA8PJ42zmt7KfDW0NzGS+hufMLtn3n8fRwJy8SdNNNGt1yUa7WPbn0= 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=Ovj+vNNt; 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="Ovj+vNNt" 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 643AFnkE1812526; Mon, 4 May 2026 08:25:14 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=Ovj+vNNtUfZC/45O0hXPVqBkNYrv19xZt RNQixeCn4w+mVPra7kTg83rKsdZ1f/UY2Uexl7uDc7AdD8pcCe8eSP2Jnt2+3iHM ugbh5i9YunYWkY5ZXUuYyLYPamBg9kLazHbmVMT8oOa6FRgTnG354OgWJeTd3TXG Gj+ogfzrtxhWoZXS6VZW5o7SzlygBD97yeykhc1f0Cd1806BBdXALLx/AA5y5Hrk uX6jYqBh7n/Ii6BkrKsL5JWyQW2MhindRkto3OyjFaObXYgjtNJRjhdCi/t4iiWG cL2ICV0YdBGw1H+4w2II48ikWbjH0gWBj5iIP7O8CjGbWxiLCpDVg== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dw9w65y16-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:13 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 6448OOKk023532; Mon, 4 May 2026 08:25:12 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dwuyvve85-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:12 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6448P9KA48824702 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 May 2026 08:25:09 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E3AC920043; Mon, 4 May 2026 08:25:08 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3B89620040; Mon, 4 May 2026 08:25:05 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 4 May 2026 08:25:05 +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 v6 01/14] selftests/mm: restore default nr_hugepages value via exit trap in charge_reserved_hugetlb.sh Date: Mon, 4 May 2026 13:54:38 +0530 Message-ID: <94e79f92aa370c2551cd909bc9ecc0cb8910492c.1777877814.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-Authority-Analysis: v=2.4 cv=XPQAjwhE c=1 sm=1 tr=0 ts=69f857e9 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=Ikd4Dj_1AAAA:8 a=VnNF1IyMAAAA:8 a=vtM6K80SjIFNW2yxelUA:9 X-Proofpoint-ORIG-GUID: q-7WBIXm0DtVv2ifKTsa82aV2XnFn8tc X-Proofpoint-GUID: XLwWjEuZuHE0OgZG4nLZ8eFzXm6GFpDl X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDA4NyBTYWx0ZWRfX2rd8cF30XI7q rr0hD1TdGSEA1lpoqCEAtAm1XLD1JZ8CSJoYS3KmSYJ1mp/5jI89tnPBtjW86L3//dejv7iG4rt W6+nVMPVD549wKKWOQX8GkxmlF68RKxEMoNvnsZscDrS36VXRRYDIxS0eh6D3dkwsU2dIwVrapB QuQHpF4ceqJ9sUQjz7VeGNRm8D1SHN91UQUcrhcEm3AaXHlOwqJseE+fgz7kHOv0mdMhOjSGGUm TiF4JfH5MRINeAiefHYurps90lwMk2lk89+zFslJeskxrcLE1/2N8H+iUQtiwJAWKvziF/DDOd8 TGxbXvB+27rjcP2odUcIe34jl53I8Z/kMORMfRaQdMEZhpUwxhZjA8UkpPZHe0tgku+YjQiSw5R navsIcxU/4SkgVsLFjYMRyo8PIX0/Ib7k+54NUnpFNaqeB8cK+flsO4uXmGAiSupYbSlVXHdIRT GQGSNGoYhfN+4jXlBXQ== 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-04_03,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 spamscore=0 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040087 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 Mon May 4 13:03:30 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 4E3863314B9; Mon, 4 May 2026 08:25: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=1777883144; cv=none; b=KKOOaYFF8p4ikep2g1nlvMlpxOP5x2ydosvFb1eJIaA3umHWXkJJCRUxij22doSjHNU0eI1qPx/SUMrnGCV7dfvaPtDEhhLCHAGV8sEa3VkjnU8u6KNFhPAlZmMlUA9GFc6wG0oilJq/dDI01W5gEqbxkgfHZvkdl+L1PP/GgVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777883144; c=relaxed/simple; bh=yfWVdIZpiB24KGCnk7Tyh0cuvXx53E/QuQ/iqyBlXS4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NiazcFcJRNqb+Bclo1f8L0sdKnZQqonWZzWxIqn9zPmd5Mqi8kJfY0wO5OLTt18kSqOvGeCx36SkwTQB3gA4WgZKCTtWMMLbtCAQGZUiDtRnrGAzQWwwZ97mgyBqlf1F5ocUu53YaWSjjKwV9+5g2Qi8aTK869zRqpNfS9BasUY= 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=cKpPVuNH; 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="cKpPVuNH" 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 64480dcL851433; Mon, 4 May 2026 08:25:17 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=cKpPVuNHE7dn9/eZ4jjsn6o1VB19//MoU 3LZJILkihurvmIiHIgPD04ZDge83V/T1w0v4BipOQ4V+f1iwi6MiGp4DNlpP6Nu9 JBq+/xW5lPIcdFjg8cMf2Fn6gZYIidowQDSoXwrKPNZO6i+bcbfpGj6DLF6oGC0/ RNvC8flKhv2gr/WHILWU7k+eaBgpfUmMsfXZYO7mBwaV/PGs5XQo01C7ZZntYPfT zb1qknlUmPHBCslvoRktmjGa/PnjBhiONHtTuE4+Zyqn8IiwvBtXpLZ9HUkcxAS6 aIO91TkoXeCHoQykB0xS3xHNo+IybNuH5hUwvCVNtnUqndnqAPolA== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dw9y4dxjt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:17 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 6448OOUM031438; Mon, 4 May 2026 08:25:16 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dwvkjma9h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:16 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6448PCAN62062902 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 May 2026 08:25:12 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 87FBE2004B; Mon, 4 May 2026 08:25:12 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 39DE920043; Mon, 4 May 2026 08:25:09 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 4 May 2026 08:25:09 +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 v6 02/14] selftests/mm: fix hugetlb pathname construction in charge_reserved_hugetlb.sh Date: Mon, 4 May 2026 13:54:39 +0530 Message-ID: <2a78c1d4dc4772c8e828c809d1e1a74e9503b257.1777877814.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: AW1haW4tMjYwNTA0MDA4NyBTYWx0ZWRfX3J2sMhaqjENq rWuoJIvzMjCKWFm73lakuXSb+Qe5xhI1HDqgBjhIsh54VDK7Ut2nByJ/U2kZnMeTA4dulXqW99P TL+CFWcD6jPJ879/QVcV6aGnV5G+4s+CW7t9z9L4LFh3jussW7MyKN8fxXknuabASI3OyjDOpRP leqTjyKUxqV8yF/FtxXyjx+i9uIrwfE9VAFJq0k19nv4tcJWHWxNwjc4un0NLMcauq5B7l9Oo4O 796bsiINH8KIYQRqKX/w1oTzKocSyXDt2EepK8F4Nwo2xWKQI5Kyur3xNyiceYWxzD0gJSHE2RD qWcFVMOX8n8eXRp0Ys/NMjg8I4Qj81b3prZQqTlogDk/7/fWbG8dGRiNJrNjkSFWAnSvIBZgTwX aOlqdz6LazUOGWVRzX5/Epye1K5aa4m8jlEd5HtyBFq3SSY3sVtmt5AmO+OBAkIOUFTq5hCFRHL TtQKtctcy6nDlrzYq1w== X-Authority-Analysis: v=2.4 cv=J4GaKgnS c=1 sm=1 tr=0 ts=69f857ed cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==: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-GUID: PUjkF3GxY4USF1WyGh822UorCISuXIi8 X-Proofpoint-ORIG-GUID: 3RpdCWffShFdQCnh0XuyZO3JxijIhfaY 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-04_03,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 malwarescore=0 bulkscore=0 suspectscore=0 priorityscore=1501 spamscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040087 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 Mon May 4 13:03:30 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 AD6FE330652; Mon, 4 May 2026 08:25:41 +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=1777883143; cv=none; b=GVo4JHznj2Oc3VcfhjyWzJbJU2t2CVP81bbnVnH7MKuOmgaj+rY/CzDnJb/rrhQyRpH+4r4RECDEw3TwEfSl4fc02dI3LblhQhfj6uHDJ3eBdVJTWdtshyTZaKbDqMKCMQWH1H94HsxE0HxH/TNJPUrj4EU8my8PdLO4k2yJES0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777883143; c=relaxed/simple; bh=XHoajm1DEYNuypwtTMliJOqP/XkxnTk/DW4Tzt1COqY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P7s0h66VO9uPc2dDpQJ8TP1fnTlgEbWPGrKnHvx0L+1ApWTRyb9v2Ws88eBc2wgIMiU9FpOZ0Xur8Wtud4vDV8EQYgALQ0U8TAkHUmaMF9eX421CDL4gmcaohThQOi26PqNsbxU408WUHHFfyGkhywe35YBo667PYRik+irghGE= 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=nnfowVV7; 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="nnfowVV7" 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 643MtCS23253820; Mon, 4 May 2026 08:25:21 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=nnfowVV7WJ0ujKFmSjLiu1dLngaC+0h56 Km+tYpg0unsCgZDcWTqxiOUrwJSxFviuQIL3RQqUVgI6bSqmiUxVf8EdYUkhyqG5 368yL7orJcs9MTBsj2QswopQspv2dnRqR7YDX4zYIWc1KeBtarXnNd2Da2wJ+Jll ixpCROJJTp+L3mmc1vnh5Q4ryMvQ5y0nuGXNOohnMiXWp2ZtG9O9EABT4fqRiU7R N5MoS185VQHoFK7IAZgvbBXgGxw8R9vmchNkbR/50kSOXDBlebmZxMssmv2zatW+ ZXjgAej/ZhuNg4S1nvxbW9NDM3Uw8h8H03M7ZocRLk8saFMs5PsCg== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dw9w65y1k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:20 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 6448OUKN031522; Mon, 4 May 2026 08:25:20 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dwvkjma9s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:19 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6448PFWn16515564 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 May 2026 08:25:16 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D929520043; Mon, 4 May 2026 08:25:15 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD84420040; Mon, 4 May 2026 08:25:12 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 4 May 2026 08:25:12 +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 v6 03/14] selftests/mm: restore default nr_hugepages value via exit trap in hugetlb_reparenting_test.sh Date: Mon, 4 May 2026 13:54:40 +0530 Message-ID: <5694336b36daa4426d9ef83a1490f122c611ffc7.1777877814.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-Authority-Analysis: v=2.4 cv=XPQAjwhE c=1 sm=1 tr=0 ts=69f857f1 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=Ikd4Dj_1AAAA:8 a=VnNF1IyMAAAA:8 a=dU9eaedoi-733nYHt2kA:9 X-Proofpoint-ORIG-GUID: ESZ1Ww9ACOP4Pa1VMq2a4JFPKu5oYwYF X-Proofpoint-GUID: -L5JNt0udyTeDt7vPIB-9fZNtLT5KFVd X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDA4NyBTYWx0ZWRfX3M6CEdDyariB TxeB5wSllbrbWi4qnb3rm20bxKWylCxk9SwPQzxDe/+GsT2LyiZB7PaEHqPQPP/wShRhSL5FCXj tndcvPVo82ondwC5x58MgcCOFoayRK/sl7URMoK3gnZkDy8zzIHMN09enND7gSRDVoevi1GSSl8 TsdN4EVUqJrylOdQT3IPiOg2SIPj23yWPm1KVrgu3T0W8xhDM8bwjHymRIEKkt51PvFBBLp+nDY CCLXq1wfckS8LIh35oc+BHOPJPKVpfR3ZcJLgikN5W/RwoqG+K89F20FP/JUoxws5yytRioGm4p YDi+axohVazuQHQoDJ503CgdRiln2nYU5F3VBgfrOFKLgshhkczKo2Yo9k65NdO0Wr2QDtMSk1P bh4tnN7morVtSLEJlLrUPwhcM6sgFx6gu5ectj83MKp4QSbROTOueqBUNoVFC6qteGMYFUPrV6r u3CJ+3kZ5oFQDTMh38Q== 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-04_03,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 spamscore=0 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040087 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 Mon May 4 13:03:30 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 599FC330651; Mon, 4 May 2026 08:25:45 +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=1777883151; cv=none; b=Qx/1xlF0WDcVAe1fk4Yi4iDxuhRfa/exjFRWE+ykFGiLDticduMEM1F/MNm8QhmAwK9iFiwZO96MlhPh6f8ifgdkMMvkfyMl9RA14Z+AYMyZTkmxZwbrqK36XaNMP7YarFyCsHJmYimD+NaAfUZWNpPBZIYXxsVrJf0laFwsjWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777883151; c=relaxed/simple; bh=6k0dfBPedoZ5m3zDYQfNpVT7vuiVKssNtYmRQNfyMxo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q2jrySLE3y302FjdCpHZm1DV8VoD4LNf307BZuAVUfUFPUJQXTjGXUqcEWrXNeM/Q6v5i2PgmEiY3jJ1O32oH2deqdcixlvM+HhVVXn2wF7NJ/WIlD+RJ1+oJXa3tsaRrgO3INRZj7SrV3gchJ2MwwSlq9WOwNwobxDnZmfFTEU= 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=oZ4fuRzI; 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="oZ4fuRzI" 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 643MxN1j2752196; Mon, 4 May 2026 08:25:24 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=oZ4fuRzITjJH9yzaPPZC1eU8nPJ05ty6b jWtq8og1I6QHUxiqsy/aPXDwPWcfoho1TlTo8uJfAbMBAX7R55VgSbSsy5X2G2ki CgZ5KRKozEK8hzzGRjUW7sQe6nZoadqF+UOwImO6unWu0VEvPthBlBF0oxLEJY0j R4ZbnUwBlcVAfZfk2O4R7OKI0W3OduyW0cFMxWtvF9+DAdMuyC2c8i0LQ33V9INf Q6ByXi+dIMbfhuJ2bQR7ww4ZGuWhT8CdMyZcXg9tfjQTb1DH+RfrNXp+MZOLvvFw obzdIHB0J3FThvfRTFykG6IYDE7zjMIf0H4710Cw4g3QkmjwdBLfQ== 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 4dw9x4e3r7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:23 +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 6448OQh3012985; Mon, 4 May 2026 08:25:22 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dwx9y42j9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:22 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6448PJj350987460 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 May 2026 08:25:19 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C72E20043; Mon, 4 May 2026 08:25:19 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3100D2004E; Mon, 4 May 2026 08:25:16 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 4 May 2026 08:25: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 v6 04/14] selftests/mm: fix hugetlb pathname construction in hugetlb_reparenting_test.sh Date: Mon, 4 May 2026 13:54:41 +0530 Message-ID: <5479a9ce82c07899b95101e20984e10b2f3f853a.1777877814.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: AW1haW4tMjYwNTA0MDA4NyBTYWx0ZWRfXywl9X1qEtJHc Oczw2pCL4lBdIqeH1SHgl9hcBI87egrg131kbstLMqTMHX5Bo3L5JXaFMdv+EyZEpTjV5tbDjE7 P8wE2I+fTaMnNzwh7A6+dCk9upi1osg59K+EFHsVvoKXKVjTXVIvIlkwIUYNrPs1ulN+L7D13X+ frL5WzutqKjtLlEWKHK1Scu4PGeQga9f5LAFq39N+8uV3974Vo+OcRcv09kX3MR3VHZ2Xeb4/yN vtcQX/Loq0gb432/ezKA7PovazlCKzGjtkV3FAgX8VBkibFIqaHaJ0dFLUEy53HtHHW+3ghpSlc wwJneFcGPUUQadBRs0hhlXnMXlxFUVYTPX4ZRgeeAsQ8EvVZy1b7p46ATLS3vlA1S5nxP8wThtl t4mZTt9ODpcoZfg3rCCZfxTD1f1AeX1oSbpyODTbZvcZPy/7PArUlKIa8CWZT5pLz2IlNnZUtx3 FCkXZhskgrBs5L99FSw== X-Proofpoint-ORIG-GUID: _2-e7eOnbPa6i_3hbfvQf-8BMk2rYVbP X-Proofpoint-GUID: 4OiJ5OPHpstloc0H0cI0s2lbxDnPBXL7 X-Authority-Analysis: v=2.4 cv=W7UIkxWk c=1 sm=1 tr=0 ts=69f857f4 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=Ikd4Dj_1AAAA:8 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=7yu59zDboRqKFyXxuvEA: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-04_03,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 spamscore=0 clxscore=1015 phishscore=0 bulkscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040087 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 Mon May 4 13:03:30 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 2442D335067; Mon, 4 May 2026 08:30:50 +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=1777883451; cv=none; b=pAAIZdJir/37QhP5CO78/k6I7MoUV2eQku+EnT71QYCWQzk6LX6ZcmlqNLoJERLAoGZCuk7AlMNHhUMNgJdXAQJg4no4V1BLV+9WIpTJe86yiTJn0ZyuYcRrIvsUW001AG6z+fitTOs8LrpaneUlo8/XRx05bg6a008WzSltI3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777883451; c=relaxed/simple; bh=LwQdcjDlXg0itHoPUyZh+mH36PaAEwMzM4SLAyBwvwM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G0ffANYfYnsFwyQ7rDYbmwvd2GIRxH+XGWl8nNwjk5dpb/+ZMCQ+qb4BAqfJzjOsG+doEuh5OyHVik9LuepUv2U9h+lemQ/+3Gbkc17rSvL/Cf54S5ctvl+BrhmS/vjfhvX6Y73Poi9wFKvCBlSqqLw8/eBgeAMwCvLae4bXw3U= 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=Oxby+El0; 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="Oxby+El0" 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 64466bKZ347004; Mon, 4 May 2026 08:25: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=udzwYhTawzSzNQvyJ pDKM0o+od4uW9MOHNJ2PUBQYQ0=; b=Oxby+El0Pp4s0EdXUR98RyUNRIfQOrYy3 pzQAOx4IkvMRs8b+k0bGwpxPR2JHG6iQSbOZ6g1xiPQb/OnCwDXJF6Fg63O2ez7V 7++vWf6xXm3Jj/XHMDyGaooUS6169fjQ3BZ79o+dcT9lEJe1stXynOrcNSkWvjcs 70np21cYPuTtC5GS+3hguKyWtgDeGr8giK50iwJUuM5kJa3tGcRggZGWsY4/92fO 4Sl6g+6SLJqHQKsJveWdewoisUckO4VELLiUH3dmnpyvCKW0Hya3y+4THTBhkZly hGgJpmK2K0XrLzRKbNlyx6VoBPBg4ea5plsV2cJ4pXTamHORhGk8w== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dw9x4e3rj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:27 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 6448OOJx023544; Mon, 4 May 2026 08:25:26 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dwuyvve8s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:26 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6448PMw016974094 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 May 2026 08:25:22 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A98B02004B; Mon, 4 May 2026 08:25:22 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7734020040; Mon, 4 May 2026 08:25:19 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 4 May 2026 08:25:19 +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 v6 05/14] selftests/mm: fix cgroup task placement and drop memory.current checks in hugetlb_reparenting_test.sh Date: Mon, 4 May 2026 13:54:42 +0530 Message-ID: <02b37fe7c40a6be0cd6064c6eb70c83680ce04d9.1777877814.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: AW1haW4tMjYwNTA0MDA4NyBTYWx0ZWRfX6fwUAXzLn8Wg gM1UPeQpfoh9urHFpsMgwjs4Xm7BkcS453CNno8NIrXOxkJ+OOySmtO5UQX8j9KbVM8gSvDLN1G seQEfKyNoLtswGJDVmDRC86B9g4+6HSmQLVDzr46Vd8YUoFRgPIGC7l76C7qu0mjLe2Z/W85AV4 Lep6vVH+nEliWN3TxOlEOecHAfh303VO4eIuocVBw16mrPfHO7mygrVzN+nZZk1g6C/AfKA2ndm iqegq6/FvFDqTUPTn8gqPNbVIqqPoAc1ILXHTqrrlBCT/pAdzcd/m92rzVtlD4g11va43p68WLJ pBrTtXVsfJ9C0MGL53lIv4opoQcsxgctnYGSA/LMf1Uk8Zea38pMYryufVepKqz18VVRHSKHdCH j5Iv2KTX/l7eKej2j4BGMwZP9RgJ6b9tf+K0hCRxH2MtALOsSf0mTPUqyIksFpuOLQ0hxsDbnXL NDSPWi0jB+M8UEjr88g== X-Proofpoint-ORIG-GUID: nsocRD-UhZ-GCoaVCj8_XEVJj2D_UOIq X-Proofpoint-GUID: cWw37LaJLFRDrRdP35Z8bqy0X4bxkhUz X-Authority-Analysis: v=2.4 cv=W7UIkxWk c=1 sm=1 tr=0 ts=69f857f8 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY: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-04_03,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 spamscore=0 clxscore=1015 phishscore=0 bulkscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040087 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 Mon May 4 13:03:30 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 85A5F330641; Mon, 4 May 2026 08:25:50 +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=1777883152; cv=none; b=LODllT6i568NFVoRqz7TKTwdm2ejGIUOm68Ah8KwmuBJ5h7jnWzw6mer71B4X1M2yjipOdr7ltWK2eCxpVsA7fS7wL6ZsYWu4jpB5/DyAIm6VHJJXfR6OCSKc8j1+1h8xYcapm7wY2QOME6LkcirQg/bO/3R44JOQL7rcc0Wp9g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777883152; c=relaxed/simple; bh=IUoRRi6z2dOrWfb6o2Be7G4wChdzcsPzDduqHE6Gm9c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q0/nARxvcBETSrBELIDIx5CTMFFmgCJk97G7Zib7QXo0lnkmLvz7XdQ/hqENS250lLVSJr5IOsN3ouvBeLZSYfo1Cg92rNoHJ+TTpVEF2VaVdmt0DBqTZR2pTDtzgz3/FV8cCY5pfaUiSz9wGMugmWyQSy11D8aDb13DqbEQJpY= 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=HTG2SQwt; 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="HTG2SQwt" 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 643AG0hO2080466; Mon, 4 May 2026 08:25:31 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=qLoytzKAJrXb86n4y 25lLTNIOtZZSNJIuVfwc68Am2M=; b=HTG2SQwtiwSPiN5W6yzBbAKYDx6scYfKV gmLwDIhBLfYcLDL7h+zkLU5a7AaJqkkDecaH4tGxQ5YKVSjlBxEXUSzhoLEkHzZS McgiyEq63g1NubRuMbOQDnGFNz1aHBpOBsBR4HQJ77ew1KoRLvw4rsOQiJfR3oPh A9LUQt4BiVCWEhYhv2E0KMHnQ4bv/N0PGccIgJlwmX5oCYmc0edZyVl1TrR9bnq6 sSRVAQalFTjZbauPRCq7ClGMTfEKvoVtxoi55AWbBlepm+asjBugl0DN3JaRMNWP qN747XgDsSj5bUEmD4Z3MXBDeGFyrDHMQ5v4a3qvQDvwGHKVXos2Q== 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 4dw9xxdwm9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:30 +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 6448OROa000545; Mon, 4 May 2026 08:25:29 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dwukq4fra-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:29 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6448PQOS50856368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 May 2026 08:25:26 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 22CD120043; Mon, 4 May 2026 08:25:26 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0EDD520040; Mon, 4 May 2026 08:25:23 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 4 May 2026 08:25: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 v6 06/14] selftests/mm: size tmpfs according to PMD page size in split_huge_page_test Date: Mon, 4 May 2026 13:54:43 +0530 Message-ID: <4f690c32f5b0948ac50a45a067a2186fbf084ee6.1777877814.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: AW1haW4tMjYwNTA0MDA4NyBTYWx0ZWRfX8upt1mGXYHKE MshnLX1JyyFdq7QysKpZ0ZeAqJMu26Sq4W0sAqyDfSDtYhLYtTMs6bQTuQLNFJnFcKbcu+YaWmM qlRRwPQ0jan6CDJqI31B+WBGr37ElUiBBpe8GnbpjxprW2LMpjjT9N8cr6wQN9svbVx2xJRYoHT bddLCY4gd1kmYzfEvEJe2u9gdxEv3On1MhNE8+0acpjdbvQmS8bZU8XTUOw8dGlwypKWox/rt7N 9hbieWuZKKDTHv9F+TSiJCy4qYVtQPSw30HV8X76qpRyz3Ag1CCz8jP201Hb/nq7PQ84NemMqA2 D2kLT/m6o1txTgBelIYqdTqu3emPcXjFOmdxVBHspVon5YdJWBL9DFNvFaInqkMWyJk0QuG8Opk v5bnQjVqUCl8sYI/D7W3b/g4Mz+BeNcz3VBWOKC8V2LgrVTS28NTyXt7PyYByRKD4XfaoQ+64nr ysvYv/P4SuTvjUYTUGg== X-Proofpoint-ORIG-GUID: HxJxplt_wNg9Yf6gWbjzQPxjYGFJPXxt X-Proofpoint-GUID: Y8-BYe3-MdiAjFE2BGYFKeO53fCTVIgB X-Authority-Analysis: v=2.4 cv=ctWrVV4i c=1 sm=1 tr=0 ts=69f857fb cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==: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-04_03,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 clxscore=1015 suspectscore=0 impostorscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040087 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 500d07c4938b..02938f38b880 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 Mon May 4 13:03:30 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 C5C02330651; Mon, 4 May 2026 08:25:57 +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=1777883161; cv=none; b=lu47yCGJ0z2KpagzRMXee0Z0YcwMdlxg81vW3mIBPF+VQf9DZLvcRsMups828+A30hoTAwD83BRHUg0u2IijLJJUHhXT798AbX39LYk7gZj/ieK8BjCpWSp3lATs6IOmWf6uXA2giP9099LN/AFV4iRKgfr6Wa9groWA0Ewh3po= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777883161; c=relaxed/simple; bh=HAnaAtua5DhS7Bs6SPFe69msoZC+atTMue4Vm5+AeO8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XZNnXe8+Bf3SAPECQ69TWn6wKM6zSpV3efyPe44DgvOzKpDcpPIkT0MdYWhbDhq4/pmaFwMdDAwF2f/NVku4gC6xIJmaxbKk9agt7ZMksH2D6bv8YWSnzWxY/kDEdVtiaSlL8UQ9yNcQMH48YW1OTRh08q0voE5TB9m9Fk7ISKc= 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=Fnm0Md/y; 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="Fnm0Md/y" 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 643IrjgW2799040; Mon, 4 May 2026 08:25: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=uCeyz74EmYofYeqL3 Urq7QausJraeZ1cxOiTgZXAkeQ=; b=Fnm0Md/yyzl/ggFyBOD+XznTaPE8Ma5vW bjUQIap9ktpztVFjjAws05U+VfZn4DUHeM8GLi3J0fX4qcgM06whk4P1Hg8+MFkT dlh4G0RBAWe4VbSmqMrohvvn1/8OE9fIs702riLTFNI64tmOFwEmoK69hj2oXeVP lldgZos0DDXG9ZIN8WfCRuFbzZkdrV0Nq8d6Y1aD2j8bpZbqdevKRNo3HIXn8fPK Xu9zXL2h3OCuXpjnEBOLJ9Xn/FIeY/6XakRsdRj+M6+Pkmpr9+N3tr9QbEvQJOjn ozRyeox6uRGksl/x21WDsc58Ny57lgY/bJM72C9M0Mep2VJs4iD4w== 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 4dw9w65y25-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:33 +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 6448OQJY000508; Mon, 4 May 2026 08:25:33 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dwukq4fre-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:32 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6448PTqX15991210 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 May 2026 08:25:29 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 774DF2005A; Mon, 4 May 2026 08:25:29 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6878320040; Mon, 4 May 2026 08:25:26 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 4 May 2026 08:25:26 +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 v6 07/14] selftests/mm: free dynamically allocated PMD-sized buffers in split_huge_page_test Date: Mon, 4 May 2026 13:54:44 +0530 Message-ID: <284a28bcb68ffeba32a63cdfc5644975815973a3.1777877814.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-Authority-Analysis: v=2.4 cv=XPQAjwhE c=1 sm=1 tr=0 ts=69f857fe 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=Ikd4Dj_1AAAA:8 a=VnNF1IyMAAAA:8 a=9VAv6nXQuNVwvrTyzFEA:9 X-Proofpoint-ORIG-GUID: 3NARXhqaVgACSO_I13XtfUEikqObqf1c X-Proofpoint-GUID: zqv2kH9Cun2FQ6nxcdQ-98MLNnIB45J- X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDA4NyBTYWx0ZWRfX+zyGMht+WxUk ChqxGYmpjLR006zp5rDvGaCuk9pky04zC6g4zhSs0tblFmA/3rrpNBu2jqDwibBwo6XhOHVE2Il 5SQRSm+6m7FAoeGX5hH8dJ9RHkZ/7vtUcDey9P3+oTccNBNHcufVz9H3Mp9y/fLAmgTvDWYjVhp 854jDdQsQNH6/4ykJyvia2gfIBJKIKYiRu1p8QJp9d4/SAmNTtMNvaQuXOt37XslcskCwS/w05e JGoR/j9uYkUwwuQL2XRX1UI6VY2X3xs+c+rU1SM0VTyIf2yKHZsxRoSrJnHOu5iWJplnqrdxZnQ vXZzkvtGhbE6xXMTj6riWlnsGp+xjZQVfr6UR/IdeGopTY4RlBocYMfFDKxtd+nXFFBhS57uB86 BLB52hQX+uEQABEbltpyBS7W6rJJ/4yjz+2YfkN9nXu1U6CtVONhyD/ipkgUCSMy1mzexu7bRnq q1bJRJfwsnAiBk+od2Q== 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-04_03,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 spamscore=0 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040087 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 02938f38b880..ee256afecd8f 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 Mon May 4 13:03:30 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 7181E33067C; Mon, 4 May 2026 08:25:58 +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=1777883161; cv=none; b=urZCYKK7BYxBu6bw5q9d+BpVJT2RiUfZXVzp5uH7xvbWvg/4IfsYkZd/8VXm3FZ8PyCtt07/Japtn8K/bmbsMh16f6hv60MGqM1TuAsa3aZCxygCZw74TIp35Y8IFdO/mRSbZK6VdycXKyZIcWqY3zstVVJ2QmnYFL28qR/HDkw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777883161; c=relaxed/simple; bh=qe7862oHZyGNEDBvsQMIgWBZB5eyPOzbNdyR67dTBsw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KpVqQTwLwos2/Wb94xDSd2SPEax4zoCutD6PQoC7i36GoP2/Egudzcvj9m8TW+Wmszv0wSz/495yOtdnHQtdhH6d1+w6fgsfme2lEAJOTpIOfmu0ub36jjKuT6fun/0v47/D7XSf35U7lrtmGACj8Hb5u0uUBCwaQl4KoQvKnqs= 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=o4yXdfzJ; 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="o4yXdfzJ" 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 643CFGLG1531488; Mon, 4 May 2026 08:25:38 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=PIfsNgy2577DuXl0N OF1ozWvbjY8j3LLjpYwpQBtv2Q=; b=o4yXdfzJXEKdM9ctSbJ7nZ5nMBSxDEn2V UMXzSRgs69qg9PNlPGLFiR6liC7wreSTA/tf/Q10jJOJb3cTgROicAq+5YmHiHuH A3s8XhiOKYMOA+GM1RjDTRmMYLuk8BfNs/jmYrUAe5uwJQCWaKXw1dam23+zGbxv 2CNQgnWvOJfeH+HShmpHVdyTtRBFQwjdg1rwOrW2PTIriGrgSh7QSvA7dZn8nPPf /QIM+Fdi2stovz/Oc184WbGsGzInQvZZmgikS0vFWzAGgD8d6PypGpufu15zv2GR +7I27oEYDAxYAJr4RId1lf+h//pZYwF2l/7IQotL++d2rbRVrBk7Q== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dw9x4e3rv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:37 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 6448OOUR031438; Mon, 4 May 2026 08:25:36 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dwvkjmaag-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:36 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6448PWAD52035922 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 May 2026 08:25:32 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B54732004B; Mon, 4 May 2026 08:25:32 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C7AFD20043; Mon, 4 May 2026 08:25:29 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 4 May 2026 08:25:29 +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 v6 08/14] selftest/mm: align memory size to huge page size in hugepage-mremap test Date: Mon, 4 May 2026 13:54: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: AW1haW4tMjYwNTA0MDA4NyBTYWx0ZWRfXyaTO1JwJT2VU ScHvsyZW0Ghn73J7ZqVn7PaU304cb2c/cq5vGwsywHyQKdqx02GU+Uhg5HJ7nfjltsOuNVlxI1R q5FTF8v37N9kEptrYgEQ5QrtOfuMgq55H17yGp0a7RedDdiEu5s64RbrZlweb1Wnh06qU3aFuhq UoPe/Rvb4vWCOB0xbOMxkurpOt6/0+W6Hroo+isty7o9tFehuxTlZ+ngwzZSX68hkPbWbnSTnuM mrsbzENUUi4v2qE/YSHkqImPRgugYEqdRsRw4xBuqVX6LSXzo9xn7Ilyfi0JRFPnP+eViA9na4X E9UNFpaab4VBjhfJITXXzk8mBPsWtSiAr1DsLKjYDxHWYezN56e0du5YxCpeuS7ZwlL7l9GHWC5 lzUAhHa4xuLqQS6ou+f4xzgfgSxY9rScsBwAy/KPa1SD87anpPPKNd7xa1Go55794fBjbpwoqa+ fgjZYNHNZ/ioFi4heQA== X-Proofpoint-ORIG-GUID: 2Uwy9H7FEZSR6yeaU5GNKtQj-CrwYhqT X-Proofpoint-GUID: sXQvH3R5Y01GydUO8YLje9bEh_SBBbl7 X-Authority-Analysis: v=2.4 cv=W7UIkxWk c=1 sm=1 tr=0 ts=69f85802 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=Ikd4Dj_1AAAA:8 a=VnNF1IyMAAAA:8 a=7t5IiW4R7ddU3FUDOzEA: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-04_03,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 spamscore=0 clxscore=1015 phishscore=0 bulkscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040087 Content-Type: text/plain; charset="utf-8" The hugepage-mremap selftest uses a default mapping size of 10MB when no argument is provided. This size is not guaranteed to be aligned to the system hugepage size, which can cause munmap() to fail and mremap() to succeed where a failure is expected. Align the mapping length to the runtime hugepage size using default_huge_page_size() to ensure the mapping is properly aligned. Also handle the case where default_huge_page_size() returns 0 by skipping the test. Before patch: running ./hugepage-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 0x7fffaa600000 Mremap: Returned address is 0x7faa40000000 First hex is 0 First hex is 3020100 Bail out! mremap: Expected failure, but call succeeded Planned tests !=3D run tests (1 !=3D 0) Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0 [FAIL] not ok 1 hugepage-mremap # exit=3D1 After patch: running ./hugepage-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 0x7fff13000000 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 hugepage-mremap Fixes: f77a286de48c ("mm, hugepages: make memory size variable in hugepage-= mremap selftest") Reviewed-by: Zi Yan Tested-by: Venkat Rao Bagalkote Signed-off-by: Sayali Patil --- tools/testing/selftests/mm/hugepage-mremap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/testing/selftests/mm/hugepage-mremap.c b/tools/testing/s= elftests/mm/hugepage-mremap.c index b8f7d92e5a35..f66e4d806477 100644 --- a/tools/testing/selftests/mm/hugepage-mremap.c +++ b/tools/testing/selftests/mm/hugepage-mremap.c @@ -32,6 +32,7 @@ =20 #define PROTECTION (PROT_READ | PROT_WRITE | PROT_EXEC) #define FLAGS (MAP_SHARED | MAP_ANONYMOUS) +#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) =20 static void check_bytes(char *addr) { @@ -110,6 +111,7 @@ int main(int argc, char *argv[]) { size_t length =3D 0; int ret =3D 0, fd; + size_t hpage_size; =20 ksft_print_header(); ksft_set_plan(1); @@ -126,6 +128,14 @@ int main(int argc, char *argv[]) length =3D DEFAULT_LENGTH_MB; =20 length =3D MB_TO_BYTES(length); + + hpage_size =3D default_huge_page_size(); + if (!hpage_size) + ksft_exit_skip("Unable to determine huge page size\n"); + + /* Ensure length is hugepage aligned */ + length =3D ALIGN(length, hpage_size); + fd =3D memfd_create(argv[0], MFD_HUGETLB); if (fd < 0) ksft_exit_fail_msg("Open failed: %s\n", strerror(errno)); --=20 2.52.0 From nobody Mon May 4 13:03:30 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 DAD3932ED5C; Mon, 4 May 2026 08:26:00 +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=1777883162; cv=none; b=Ngot07cSKdX6ETiK4Kco4FLrxpLJK57VDuZrxJKcoP4vxEaEuhmd7qgzM0wwuaSsJK7UuNoXXyoN64M6FRGcdBO3BIgwB9dteHPaRhj07ep3C9sDbi2WViL7QcN+7boMcVe+OwrbXWXGIwHvZY17heLa04iJ5gkcdGuKPCG+YfQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777883162; c=relaxed/simple; bh=8tJlJROGPQcOhNP00R3gZKGqa4/bL0KjAmCxiZ6x+Ho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E5w81oye/ee75v3L9+fT490hefqSl7ZzTVD2fK4rZAO8xUU1hLrAZSgwAaTYYAyVgUvL4E0Z2zwEiIINFRvERjKSLNyg4wD2VWCFn9bfu7F8gYEBuwQVUwiDxxEG2vp98AQ5/p9EvNSgInKN2yomAD6j/xV/zY+VzyJehqawTUo= 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=PdTov3oS; 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="PdTov3oS" 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 643InOlO2280958; Mon, 4 May 2026 08:25: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=moIJIypDjtmZnGtHA K76laQuaSh8Y71cRRNVJavHh8k=; b=PdTov3oSiXlEpY/JsU5ShLROWVd8FlVNT JXzIb8pHtJ1jTIuivkx8AED+4DEfEXdxf+rkIxL9HpGOATFy8f8eACteugmZSELS Z67i4ZxdQch7M/cpM2Qep2PUv7C+tbeEMR6SEuZrNrN48rN5udlg9B4QLgCJoQVJ IzIGI+3pBjAi9+Mtk/7y6WjlfmRW0aj/TXzJ22z43yes8xj6wUkc1j7oZQ8QElLp V9wnnhl3xddZX8KfFP3WGW7BTP6sB3YVXTC4NbMmV4S4KGFZgq/6CLdHUZHPtM89 gSPBhPBjnzk2kFWCnhxfAQ2knAucNW/OG2iwIR0GbD1yRntFgdabQ== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dw9x4e3s1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:40 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 6448OOd7023531; Mon, 4 May 2026 08:25:39 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dwuyvve9j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:39 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6448PatS26018426 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 May 2026 08:25:36 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 00DE22004B; Mon, 4 May 2026 08:25:36 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 06D7120043; Mon, 4 May 2026 08:25:33 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 4 May 2026 08:25: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 v6 09/14] selftest/mm: register existing mapping with userfaultfd in hugepage-mremap Date: Mon, 4 May 2026 13:54:46 +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: AW1haW4tMjYwNTA0MDA4NyBTYWx0ZWRfX3QI6zhoFeIPq Jhy3gEWfDVdNkdSQUQzVq7BcVcFRIJQ7lh8FTHqmQHoUcnRZw1dyO/46epImoRqwPemPFcdaVg2 dL4lFQsGp8cL2gA7ZZfD7s9mLhe9l7dTRVVC4SBuK12TMK0Lra8faFC0N1Ln3X+3e5d/RW6G7JV 87RYalSH1dAL0eYjOa5K7mFya4sACGZNkK2eXCvWtaKJ57f4gUfv1Txrh9dCkDIqm+V61nljp1y /+hrTQvZGx7e4BiiI5JGDAzATVwQlFeR7vzID3xZmFWMf/w0I9LaFSv0Wg5XUIYErBRflyqWJ8T YhDxaKCE5RTTr1QxdnXKKhJOol9eNIK2x0+En4oyT80B0SC+9bICMGTa/WKALzfspDVJ7xevssi mLIS/u6axU/yDY2pgZYkycnTbwhUSlWWFVwq/Zuc8jBO4NsvH5vJXkz3RkST6yyCNvVy6ZlPCjh vfD7RDTEEjCXTYfe/0g== X-Proofpoint-ORIG-GUID: uPn6RHkmEbhPoeqYvp2cKeh83IV8X9Y5 X-Proofpoint-GUID: wfQhWfwlxQb2Uk9D0i_52QNHqRi6jSjT X-Authority-Analysis: v=2.4 cv=W7UIkxWk c=1 sm=1 tr=0 ts=69f85805 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=gVE5Qc0x_BWLnb-D2gsA: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-04_03,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 spamscore=0 clxscore=1015 phishscore=0 bulkscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040087 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 ./hugepage-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 hugepage-mremap After patch: running ./hugepage-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 hugepage-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/hugepage-mremap.c | 21 +++++--------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/mm/hugepage-mremap.c b/tools/testing/s= elftests/mm/hugepage-mremap.c index f66e4d806477..68c35d1d8a5f 100644 --- a/tools/testing/selftests/mm/hugepage-mremap.c +++ b/tools/testing/selftests/mm/hugepage-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 Mon May 4 13:03:30 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 25FF1333440; Mon, 4 May 2026 08:26:03 +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=1777883165; cv=none; b=jG06K5MZUX/tTBL5rJc4lrk/fsH44YufPdNaFAGCztoy+qYBR/GvmnMPSW6bfOfgyJJ8eR+PsSjTgTGd09nPPUpt3T64XNuhqfNMLJ8uAdAcrJEJGv3X6ACgKeLC39IgP94JVM88Z3lewe4qlqvo/uikUZC8chbgFZuBodHdWc8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777883165; c=relaxed/simple; bh=m32PvRnFHgUORFH0uNA83vNfak8IHaHUJZ6enKfg9ro=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WhE5TOu37fB1kL1jevcSiR18+SFIo/NVzxxan4RqUr4r+CS1gZ5AGSWjI1Fon42hzulPHQ/8J3Tg/24iQ9ijMRGQRhuwpyAuUy9WLsQSEQ/ez8kFmRAZjCse8uT2oxwWC5olWU1qOTCUl2dxyX2tUfBncTTb9VHazFj1XPYBj+E= 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=fdpEIssm; 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="fdpEIssm" 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 643AG0hQ2080466; Mon, 4 May 2026 08:25:45 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=G5jNpn3lA4nxxcFeR R2Yggf97NPpXqcmij/yD8SCbb8=; b=fdpEIssmMNtdlwy3Wip1UaEfEj8kV8NuV bsWp7l2i9dLwf3CUSa/pNxrJ81fkJEXiYDKZqTfHAE2L7adrq8ZmmXum+ZuPkLmO tA4+ITI+CdRPkz6pWOJCPes8EZpvVefHI7DU/1hxbFnnh22xCEzTAz7uTO4OGJmT pG9jSOABMtadKPhj3bW5bTdgy5nzd9AJ05wp1Zo0bQ9mwv9GINh6lOZ4/GMcGg7/ mYbtWg3hE4j2zPw9Jkd4Tabll9krdVRJuzMkhpNT/JDN/ow+e6R1neHhAa/2vhXM wlG/Z14PvZolEcs+o6G2Tvk0735plbqPHXjNm1S2bcmG69wbxqxRQ== 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 4dw9xxdwmv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:44 +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 6448OOIt024707; Mon, 4 May 2026 08:25:43 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dww3gv84a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:43 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6448PeTs59179492 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 May 2026 08:25:40 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B5DE20040; Mon, 4 May 2026 08:25:40 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4D95720043; Mon, 4 May 2026 08:25:36 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 4 May 2026 08:25:36 +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 v6 10/14] selftests/mm: ensure destination is hugetlb-backed in hugepage-mremap Date: Mon, 4 May 2026 13:54:47 +0530 Message-ID: <021c74ee2bf9d6dcc5416458d387cc7a1e58b003.1777877814.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: AW1haW4tMjYwNTA0MDA4NyBTYWx0ZWRfX7NUPgzU6H5aG dTG8ZrM9LvVfEr09/1tuWZc+ZJlOEs2duSjOQrieGtZJ4mCi1O2j2P0l9BvUewURhWIjwoTkE37 z8M6zlRGLVz9MYzFPN9XmfmgTh4movrEUL556YRqC0wjpp/LJ/Y8IhloxcSG3JV290P5/yYf7ev vbdFXeaz1PqhEneSAmU+GgLojyAZxm/HdPg44wtDWaPQ+I+Nzonw86O6doRMcFTaJYJsApg00Ci NpiBPCFnBrusMC+zQEMXM5a7TaNkWN0HJszFb2qsmdYt7qwA5A+K+pdiZygonRH84+akNZtB+j2 ifBXBRhcFmodgHNaqLacM2DRu+7WycuqnsOdhQGAWC/9GM4OSnGfH7t3VruU2gmmrBXkKn6MbqD YU7ATuzOmYJ2G7EqjNIGeyaxOl2czMq3g045wRaIWIwk6uj88XtXFVUKgUREG7vpC7h/6z6xMZh w6DxVtOGMJPgYrBZGhA== X-Proofpoint-ORIG-GUID: 2K6-qwYb5JWf8NZfbzS7aBOIcQC1HM3Z X-Proofpoint-GUID: JwLyZOHRS8xhKuQzWUSCdZ6pX2UG6At2 X-Authority-Analysis: v=2.4 cv=ctWrVV4i c=1 sm=1 tr=0 ts=69f85808 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=gVE5Qc0x_BWLnb-D2gsA: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-04_03,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 clxscore=1015 suspectscore=0 impostorscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040087 Content-Type: text/plain; charset="utf-8" The hugepage-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/hugepage-mremap.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/mm/hugepage-mremap.c b/tools/testing/s= elftests/mm/hugepage-mremap.c index 68c35d1d8a5f..a442d01908cc 100644 --- a/tools/testing/selftests/mm/hugepage-mremap.c +++ b/tools/testing/selftests/mm/hugepage-mremap.c @@ -31,7 +31,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) #define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) =20 static void check_bytes(char *addr) @@ -131,23 +131,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 Mon May 4 13:03:30 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 38EE233122A; Mon, 4 May 2026 08:26:10 +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=1777883171; cv=none; b=IwCzc4twXavKqTlicK0AlrTa9A+qZQM4u/iAOS3Et6tF4oBR3Y3kkVbBq91e7zOBxDI85WzBo0G4r0QuazNYEPt2JgYXFATK7HAIbyAOgsTIbezNgc6zXUoM/fplsmc2XKOJTXc4MRDqp9pljCbgVp63N1nuGg87ptpVHfvkVJQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777883171; c=relaxed/simple; bh=chx7JyiKX0FFALgg7InPOGypfEqHHeLf3lz6aPI1AkA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q5dPCqaQGmEEhyWM6cEQAwPcB4ov/ow5Ue8YwVRI1d/W2/HTERwfA1gOofXIBOZ0COOK/VCu/TW+SkZkSMOJkBpxdTAWamNrrSWDW4IpJ0/GVyJ09gpLfuZUbNmBNiDlMuXf8AlNI+Hj5kzZhudQxZEVQvWmQH8V83+nTtfeADU= 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=ACS/8LjP; 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="ACS/8LjP" 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 6447sMbN852737; Mon, 4 May 2026 08:25:48 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=eEOC4G2ZWST9olhih UFWeAxxSaTnVqTcR+V7Cs8ArgY=; b=ACS/8LjPnmKRpBgCC9clEf0/n9SAnNQlh vaZvmG3b405kEFBFbEdI8XZTePwKeK+q3sxB79UqdpXw09jIx+EV3hpLcc33+oif Cjn45BgbY0dwW9vLko02n51xLV6HDWEwexHLNPtZWAh3S0VtbR6wWYtbOh5eQXu0 kaFv+EpfH6m1Llkfgsn6FLExLQ/2Qz7aS5UX4PlPt6jMkfAE2eJPlaANk65IZCCA WwR0UD3OJUq2fumgTANklNhZ4zM5qyJLEFdpnn+aA9vY+LqjopYdTyCqtvlQDAlp xPx1FrysyKnp/cuq5qiMecf8mnO/fbcB/yI/MCqj2yDyaN1Odq5AQ== 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 4dw9y4dxm7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:47 +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 6448OO24032710; Mon, 4 May 2026 08:25:47 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dwukq4fsf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:46 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6448PhGV16777684 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 May 2026 08:25:43 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 86ACD20043; Mon, 4 May 2026 08:25:43 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5286720040; Mon, 4 May 2026 08:25:40 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 4 May 2026 08:25:40 +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 v6 11/14] selftests/mm: skip uffd-wp-mremap if UFFD write-protect is unsupported Date: Mon, 4 May 2026 13:54:48 +0530 Message-ID: <902b5c8139a681df83d78551d5bd4bcfa54ed3d4.1777877814.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: AW1haW4tMjYwNTA0MDA4NyBTYWx0ZWRfX3Yh6pK2He7kU Di7hUwVi+46Wh6Yw7qJtS9XhcwJMF45xROzk8LwWbFXMiqxbTjyUYi2nvRj4Th8mrbGiyuSTIoK QJfFCUlzOPZoT2l9leH23zIf+pGFaF64Ev3X46oprqOs1Wx5dfZZma8GikZa7kksIct8IBpngoN CIFo3d3WwAHRW/EyaTAbkzFPI2v88fQ8uYFMHVgv9TOdMe+nETF7wXGHSqbYykK1wrVX5tGdzNa c/5/+b9qOhUvKW8pcZtUyOHmW9fqwb7ZjxC3vc+p1iRnAeVpLztfPczq5UFAcKlHSO975eo2W+X 1MAznx2TlYlsBF3067s5S6aHY/nR4mbVaG8h5BGgghuFcBBc5+KSaPfpEMINlNgJCBrwZbNWWdK Auj0SR4twfVDHCz4Ls2AGx5E1s3V6edM3f2zJhdcUk3ycFaZSUaVDt2e70lcc4CdZvhdlgJuePb TSV+EgYllre12BHNYug== X-Authority-Analysis: v=2.4 cv=J4GaKgnS c=1 sm=1 tr=0 ts=69f8580c 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=VnNF1IyMAAAA:8 a=njH7lnjfnPuJvX8OOgMA:9 X-Proofpoint-GUID: iO3DPjSToF56TX06C1VMlVCNxALVfiX3 X-Proofpoint-ORIG-GUID: -dBqZdtVfJELVuVJqNqzGacCYupTfoQu 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-04_03,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 malwarescore=0 bulkscore=0 suspectscore=0 priorityscore=1501 spamscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040087 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 17186d4a4147..8f288484d5f5 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 size_t 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; @@ -336,6 +347,8 @@ int main(int argc, char **argv) struct thp_settings settings; int i, j, plan =3D 0; =20 + check_uffd_wp_feature_supported(); + pagesize =3D getpagesize(); nr_thpsizes =3D detect_thp_sizes(thpsizes, ARRAY_SIZE(thpsizes)); nr_hugetlbsizes =3D detect_hugetlb_page_sizes(hugetlbsizes, --=20 2.52.0 From nobody Mon May 4 13:03:30 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 0CA44332918; Mon, 4 May 2026 08:26:08 +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=1777883170; cv=none; b=BPvezI13g1eKP75cg1TzHY/VbtuU/kY6vFuumdmucj1nPMrl4LaCIGRqOijtfL3EEhzfnBO0HXSlOpp5+xsb6HpFAy1pTGR/DX3mNyP5zxBcI5oC/ZUn1ZjW4oabSNMVirDQuK6o4yeiPbpiqkZ1/WTW3R5trvSzmE+JEUI6rL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777883170; c=relaxed/simple; bh=qqjmsFDQuYpSM1sLDDM4OWNfiss66zgJdlKbEKQ83B4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z37zh55eyOD8yomUklV44VF3kpRNHA6nHJuHPdJBhYMzpZ36B/587ANMOJ4hnhRI2k5nOcV3JALW805fGkb+kUNJBpaXN1nPOFaBeCga4t9du3N5KQH+4xnCIqL6cYPhDb7GDxmLivwTAefAFBMW6Eim6gaqrKoFV+OBnUcy/gY= 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=NaNigRdb; 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="NaNigRdb" 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 643Kqx2n2830434; Mon, 4 May 2026 08:25:52 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=91SGkots8hY8yhefJ jvScb8bSKAk7Ka9vIM3IAFA2DQ=; b=NaNigRdbzPyxnig9vAaGITXTPasczpm5i K6E4cAWcX9Lze3l2OOe6dSQNAWBTDqDbzI2pIUiOcHIgY7rwXLC5BtolpEVRxQX8 L5EPOLmkw0Gn11wTpC5k5Em00EYpGnXHdn42uGNA4w/cwvNbN9f0XqxDY54CFf07 TY0NwJPepDhGFQSG9RCHfB6AJUcCrzHysVTg42Y48on/Iql05mbsMt/jft495Fq9 oErbdqf8fQRoEpmsizl1gamarlpJ8BdnPDQACqMigeT+r+bP3QyC9Z5DpRFppvYZ SmeCeX+Aqj4BRu3VV0w67TVkVVHZF6mr6hl0Kwozoa3dU4syp6/PQ== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dw9v7658a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:52 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 6448OOe1023522; Mon, 4 May 2026 08:25:50 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dwuyvveam-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:50 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6448PlJ650856396 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 May 2026 08:25:47 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EA03E20040; Mon, 4 May 2026 08:25:46 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E06CD20043; Mon, 4 May 2026 08:25:43 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 4 May 2026 08:25:43 +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 v6 12/14] selftests/mm: skip uffd-stress test when nr_pages_per_cpu is zero Date: Mon, 4 May 2026 13:54:49 +0530 Message-ID: <2b94f0a5ed129ee1249ec522d94237d04c4f19ea.1777877814.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: AW1haW4tMjYwNTA0MDA4NyBTYWx0ZWRfX2dTsRxbftKKn pcF81gkaMhizAh/gzixV3wY/h0JEdQN3gGOSyIL7JjFnDsVHmMOmicl4FqBaOxE4Zs3JGveL7Dx c8ay9TvFj4362UNfXlIQFWYwNXefFs/tm5DAlcXXEnc6Gnh885XcUFvB8UmYRgNF7Zf6AoFveh7 HinYUHVpgv4TvoyBqmKB0Cuhaw5OGGd5HXV0UAQeTLl4SthUZs5GgL+QHajn6uoDH+lwStp9HUz iLJ208A1JvOEQzruVG0OivUKWALbDX/+IPMSUNHGxgsKvkkkFd7FM1mGM1fBbBt4vpligpuCeqX YOUq0wcip3DJ74K+cAR/pJeXpwDlQgrIGkyZK6dBEllKTx9SAL4v/klaSzTgeAIaFliLcRyXr86 H4O0IQbp+I2luidBNVpfED0yiD7uuisRKpGb4ADW8h1FPnGYoH+Y27T/sXq84v0wuv6SVaTmqwM FMkb7w2dFyeP9XlJd7A== X-Proofpoint-GUID: j2aMVpGllcJhKq0dtmb-oSYhNVspY2WH X-Proofpoint-ORIG-GUID: 1qdmlwcj_bL-UkijK7ccG3ksuNYRgUuT X-Authority-Analysis: v=2.4 cv=eu/vCIpX c=1 sm=1 tr=0 ts=69f85810 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==: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=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-04_03,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 suspectscore=0 malwarescore=0 bulkscore=0 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040087 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 700fbaa18d44..b8f22ea859a6 100644 --- a/tools/testing/selftests/mm/uffd-stress.c +++ b/tools/testing/selftests/mm/uffd-stress.c @@ -491,9 +491,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 (%lu / %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 Mon May 4 13:03:30 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 E8C23332906; Mon, 4 May 2026 08:26:19 +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=1777883181; cv=none; b=h8M0j53bdj0ekPWw4pHC9fs2jSr82Md+g/zt/HX5D+eLNs9kgpD3bbrkMOSF3bx/KGPBcharZfq8eH78GNKAzMtyAhWETxCWPjewRd3UHu3C0AuHE/LxK86fKtSfKHjKX26rIifHYLfVPhdfqu8LsOXzxaD7ievtxpYoaJVE9S4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777883181; c=relaxed/simple; bh=X+XeD8wv8lVEB9pfRm5RIAKNvChulS1SzbTA7AucSK0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IADX+7an8KY7mKFfVbgxoKBZFILpBuXQIZNaKWP0VCM23A+GQrsvVPRUZpI5fsLhbkPyvBMyshvP15d9d3dSVf4HTvaWYgIivI5M0HcpDl3pD0qROzJxlQs2hjrd2A3c+QonAAUUMoULtKQXqsWtQbc1NQW2qNXj+XFmxZSP4LM= 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=PKaUTGgX; 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="PKaUTGgX" 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 643IFOgd2217751; Mon, 4 May 2026 08:25:56 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=7sMOd/dG1NiaDLjS+ cqKrM96sk8qxd8owleS1MDG/Qs=; b=PKaUTGgX6CWCQyo8Rxaz4Ld8GDSoq3ajK Wc3D9GCh+wwRAoUqc7VDHVGwZuTzmLnoaKXpHCj+hsvRF1m696I1mT0KXWks/K9z kwN2ne+LkUggyxJDwDVEW9eBgomgpNwqSEn2kLx7t3gO30QXfKckCKE31WWq5LhE vFUQbmh+Lw6ODGism2L3lJ3dzWUWN/c/SSYlgVzAsWi1vbjHdgDJKDNIYGey7ggH HyN8TBqiMZKOKemVbHx5MGy89I81Ld7JJVzLzokxR7ma+CNGa+F8o/68MRH2Jnkw 4Z8I3ErmWmnafdrlMRZG3AB50lZAhqJFB37hOmC6k2Y76guNK0WAA== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4dw9x4e3ss-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:55 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 6448OOK6023544; Mon, 4 May 2026 08:25:54 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4dwuyvveav-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:54 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6448PoQq26018430 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 May 2026 08:25:50 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6306220040; Mon, 4 May 2026 08:25:50 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 429922004F; Mon, 4 May 2026 08:25:47 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 4 May 2026 08:25:47 +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 v6 13/14] selftests/mm: move hwpoison setup into run_test() and silence modprobe output for memory-failure category Date: Mon, 4 May 2026 13:54:50 +0530 Message-ID: <9e9311d38fea425c2dcd2e470b2fd3fd8cfa9ab8.1777877814.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: AW1haW4tMjYwNTA0MDA4NyBTYWx0ZWRfX3AHtey9TXtYI QS+mn2VE8RMbVTjsVqKaHXOtdG5apUIG2eIkQRYj6AAj7u29ec+ClUNe1LaJZuPEvXdQToYBc/s dx9NhYmizj1oVmfV6dkOCTLKC5u9EStpJdIAxepD9VZ71jJiVpGeMhzojH3XWhjFJ3BfnDQnCm8 jx7hjwvkZAccEy4oanpsKFrPiqCyCwZ7UytFkH8+HktIFwMi1GFeT+Cu8yXmOocIDYdwOvUoGH6 FcO5SJ8zbJrA2HMsspd8/db7wYxnB7m+UYb1GY161wCl+cHf6whEDvRo2N0bfj27M/AkcJZKq/W Wd9kdm75vvzqKqxdapbFMiNbCFDwSoGf2gpiA8BAQUVipyIxEHZUxMYF50Dqtiaw+6b3IBMoz5x AXA17pHGt9EFMwQwWnwXfKsXqrHwxNambAfvUZwE9AwHYveIeLCTVC5oVjqrB1u+qRLnZ5p53zm T4u6AmnWqgAC2mpa4Fw== X-Proofpoint-ORIG-GUID: W8O1pE6c-MoXV22amZJYrTuOmP-JEFb_ X-Proofpoint-GUID: Sx1on6rqWfyN_wjo241OLRPuxikZhmjD X-Authority-Analysis: v=2.4 cv=W7UIkxWk c=1 sm=1 tr=0 ts=69f85813 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=i0EeH86SAAAA:8 a=VnNF1IyMAAAA:8 a=w_JUWIshtjp1QPcyv1YA: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-04_03,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 spamscore=0 clxscore=1015 phishscore=0 bulkscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040087 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 | 52 ++++++++++++++--------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/self= tests/mm/run_vmtests.sh index d8468451b3a3..eb6f0ae48cc7 100755 --- a/tools/testing/selftests/mm/run_vmtests.sh +++ b/tools/testing/selftests/mm/run_vmtests.sh @@ -235,6 +235,7 @@ pretty_name() { run_test() { if test_selected ${CATEGORY}; then local skip=3D0 + local LOADED_HWPOISON_INJECT_MOD=3D0 =20 # On memory constrainted systems some tests can fail to allocate hugepag= es. # perform some cleanup before the test for a higher success rate. @@ -250,6 +251,28 @@ 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:]" -) @@ -261,6 +284,12 @@ run_test() { else local ret=3D$ksft_skip 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 )) @@ -270,7 +299,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 @@ -531,24 +562,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 if [ "${HAVE_HUGEPAGES}" =3D 1 ]; then echo "$orig_nr_hugepgs" > /proc/sys/vm/nr_hugepages --=20 2.52.0 From nobody Mon May 4 13:03:30 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 88653332615; Mon, 4 May 2026 08:26:19 +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=1777883180; cv=none; b=QULxAoqG21e5bWCimPmfjnquWaW0927gkQy2U9A/oc9dc5oJHGW4u30p1IHJv3ThX9bP+pB3v9ASPPSkfur8/wHgcHdSp+iUqFOwXq1cl2mHDGigH/oLLUtnNbEjNYdZOVtRiLqm15Azb26TMyeTncTNX+dfAXx0aysUHVBG6QE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777883180; c=relaxed/simple; bh=hFW5u/GVDAmyeKRCDYDTF3OMxGCu5CjcIbXGIWFMql0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NtrN0/sndzeQ2sBrvSJ6Z7Z7cWrvTAZ+LqPx7EFaFpvSZzHE4Qagg7CTT1/UGgfqgbkCYOm2efJyPdyG/RIBK+32pg9AvKUg1wlHNuIhsTZkAGG+ECe1m1vP3h/a9rEag1yAwxIh33VIp6Zocl/QycLdJBbNQvwkkzQgg/DTBWM= 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=kT4sH3qD; 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="kT4sH3qD" 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 643MHdXM3183452; Mon, 4 May 2026 08:25:59 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=NcC4IMd/M46lcIebN KowLxjbupegKYGulhXVqQiEBho=; b=kT4sH3qDNqr9ym8uSr+D7AuOZV4svbNRC gDuNeglrVNlohx6N6XJ/nGY0/2ng62/4QowVGiuP0jfm2wIZIrsHIVjJ0sjgai1M PtcdYbtbtaGzo8cLcIOJ89LinMnV6lmXtrb947F+J0pr3cTkgqVZ7L7LvxxSM55N tQoWFpTi8Lq3cpY0L3rGb25x4/+oQB6Ery/UwhIa5X0pBNWfed8wF/6UiMOUlm7T NqgyhEwTvQPr4YxMY2Ok2RfLaL9X0uoypRGMt/7Fq6lM2CxiJ2GRsqgqYlI8xBg3 77nRjNa4lm3xejiqpQoWPxvDAfpITQxcBj6HZzbR+vljj8/vMaPmg== 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 4dw9w65y38-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:58 +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 6448ONKW023986; Mon, 4 May 2026 08:25:57 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dwwtg45sj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2026 08:25:57 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6448Pswm56164802 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 May 2026 08:25:54 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2F0502004B; Mon, 4 May 2026 08:25:54 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AD10B20040; Mon, 4 May 2026 08:25:50 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.bl1-in.ibm.com (unknown [9.123.3.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 4 May 2026 08:25:50 +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 v6 14/14] selftests/mm: clarify alternate unmapping in compaction_test Date: Mon, 4 May 2026 13:54:51 +0530 Message-ID: <91e4eb8e0d0b5a27e166eca59fd7750fe6e34036.1777877814.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-Authority-Analysis: v=2.4 cv=XPQAjwhE c=1 sm=1 tr=0 ts=69f85817 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=THlBPJCoSQ4NST9nLWYA:9 X-Proofpoint-ORIG-GUID: NLzTdpf4GZ06u0zeN4xQXz4pmJc3Vhf8 X-Proofpoint-GUID: XI43Xpx6JbIWOebeDXPu_gP1yG8Jtt__ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDA4NyBTYWx0ZWRfXzeR7DZj7ckY4 MVMDpR5ydZDuHjf1v2HKAR8lDUstiZJHgEQlpV0s0S008AbqZ1dzzXfN6+3CuclWl2lP3nEiYgn KuXJarWcVIckkLiufJZzW0pWLJko/pGkdIvfWwCiX3Ft4cvGrMMfKW7c1Yu4a8tOxAsNbJqk6f9 2upAvtcmhJslkHXt6ElfhA/OtCtMxl6t2ma1CT/rHyZHp9b5bGjrIy42eQLrKwIClpo4u018gmg 9azKG1A0qHNde/uL/yHUltBYVNWdVmJjp98Laxpgg//BE6ARTBo0rMKu1lURZBjB0Razeip/9Gq HhYv2H62eJtdGPlty125BeqO3N3Uw9j4ot3MhveEW72QFdijhe6qOT/tGpmymCoQa/jHXby9470 8qyyE43eNOXXWozoznJw9r0o6iju+9vFW7jfrxVwQNKcRMSzmmIF/QgsTObN+OxVXGCjmHwZf1Q oZW8KLCqUjaKjJn65Cg== 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-04_03,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 spamscore=0 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040087 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 30209c40b697..e1610e2fbdf6 100644 --- a/tools/testing/selftests/mm/compaction_test.c +++ b/tools/testing/selftests/mm/compaction_test.c @@ -261,6 +261,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