From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0F617ED7B8A for ; Tue, 14 Apr 2026 08:22:46 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4fvy2D1KXNz2ySS; Tue, 14 Apr 2026 18:22:44 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1776154964; cv=none; b=PcZF+2CdxfXd7Ew7tdL5IECYAvOkZmVY81bV+n5Brh4FWWSAzas+COswaA7SdkVNKoImA4hRQoZSD54CQqlnesyDSenrNQ9eteUOVKE6JeQFe7twn3E+kqr3yaCU+8lh7h75ksskEBpe8c8G7JHV6YXC9Qs7/KumnroYPfOhHx7V+sEgpwJXZx0Ce4wsRytUd2NO0GqAHDsPctjC/bzZ5jkP7GKJGoDnkII59lOfradf522kPMaU2KVAmpbb1FA+TZhZFwBTwkBnn3w/ldfYo/BgQNy5QeM+QX2SVvVRNhgXawxnPCDg4nvZjPEwc4ZYK8UqxBcqueC33JjSt/wM6A== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1776154964; c=relaxed/relaxed; bh=9OL43+Qixq8NgL8gKJjs/kQOtTy1xSAJwjYGBdErthg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hHxI0tfoN6VEtZwqG0xf0hZl99KUICp9YFi76M2ZRzyliOD2SF8UWnnjyvi+fiEKm6nTkjsBkW51Cl3t9EkDvUTsNN58XQJOKGGSsqSLcWx088YuAE6bQyCnwCMPFZm8h/aSCsgIkIp4ATVv/1mLFg9tOoydTyY3U30j3hT5Nrvm5rFs9gwMslQRP9epEB8rP0GYR0UmL3xhevs9InUA3qUhwr66jaP4vcsJPSeE51hILxoMJ95uhQRNqVWW94m85JEYDpHatocGYsoYpvrqis+Glva+1nMXhAq5CX0tX04E7ky1Yuw7dEt1zsCRTEcu5oWx1htkzZ0Fhkwg9uzpvA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=pTv0IWnX; dkim-atps=neutral; spf=pass (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=sayalip@linux.ibm.com; receiver=lists.ozlabs.org) smtp.mailfrom=linux.ibm.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=pTv0IWnX; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=sayalip@linux.ibm.com; receiver=lists.ozlabs.org) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4fvy2B4kMfz2yQj for ; Tue, 14 Apr 2026 18:22:42 +1000 (AEST) 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 63DLIRmT1804741; Tue, 14 Apr 2026 08:22:29 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=9OL43+Qixq8NgL8gK Jjs/kQOtTy1xSAJwjYGBdErthg=; b=pTv0IWnXpJoJqvZriVYqS/+RtB/NIgEXO 00ZUSX5ZGZ7wVmXfaYJsnIJnx0ctYppJxDv8KkAOZm5kIdwpeYyQpTRGP/Hxi1OK 5aZTRfdlOPfR4Fm8e2CGICnIloSHoYi6fjO82aAF0wZImyGJk43YRH/EtIZK7BiD 1ylfOb/vJ2T2zgdTJMnAnWi0PD7aacaHk9nnS8i7Qt5/9Hl9eqaHaE1q+KOpOd8W q5cw9MnSEF9+zS/jXZkBELh8z6YaOFElQpcW8HLzE5pKVgkShFiEtUda5ZmtdGoL jXmcg+tjmZRXZegBMnN2KeOPU2N6+nAN8qqs3pJo8Ba1WnJovlwhQ== 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 4dh89k1pfp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Apr 2026 08:22:28 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 63E63xgp025837; Tue, 14 Apr 2026 08:22:27 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dg2ujgeac-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Apr 2026 08:22:27 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63E8MOmB40894782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Apr 2026 08:22:24 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 114C22004B; Tue, 14 Apr 2026 08:22:24 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 12CDD20040; Tue, 14 Apr 2026 08:22:20 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.ibm.com.com (unknown [9.39.26.223]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 14 Apr 2026 08:22: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 v5 01/14] selftests/mm: restore default nr_hugepages value via EXIT trap in charge_reserved_hugetlb.sh Date: Tue, 14 Apr 2026 13:51:55 +0530 Message-ID: <8beb895ae46c3e817e80cdd5386933cdcf8e233f.1776150071.git.sayalip@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: snjbpVxXPWmC0-popVHGrUdo3dzWp4xd X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE0MDA3NyBTYWx0ZWRfX7OCa65BG7/Li g2sMpDT5osBrLXUoiQ+qLn4mCYifZ1Zje+u66AgYbVJQruN3ZXtX6kfs5NjsNvhS6pUKienNHbK ttbDQw8o+3j8GxTp0qEq3ZDdM/wuJ7ZVIjH5mnngjTGqrv6d8j6Fh2E2I+ENvWibgzAUobbhuIY L1CDV0OyVOKaExArVKov2lvBZhv3z/xaHCl0ZKiDn3YQ6kioCAIk9pt5wAN4tt2X+u8waAv01+N SD6tcfKEAE51HpdNi+1I7Xv3NYlpeKdx8zk2oD0L31w0izDxTtmgRPY0R8ayl3p3Ye79SzgHKTL DzTpJuJ5wxaMIlUSWYIdaACwmxFkqjvY5doICefEsVcBy19ZZ+TdJI4OUZSeZLreaRAL9b01vah apdMHHtdFEhODncIeHoMjW1/v+Wbxcs9F7vkvclryCqspfN8VquonuXz8wNwgtZZagJr/ltvKo6 PC8BpvXxCFnX6M5Gmaw== X-Proofpoint-ORIG-GUID: vKpf_qrG8LF6PtRXb_qgjBhkdG5VpAk2 X-Authority-Analysis: v=2.4 cv=W60IkxWk c=1 sm=1 tr=0 ts=69ddf944 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=Ikd4Dj_1AAAA:8 a=VnNF1IyMAAAA:8 a=vtM6K80SjIFNW2yxelUA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-14_02,2026-04-13_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 priorityscore=1501 spamscore=0 bulkscore=0 adultscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604070000 definitions=main-2604140077 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. Use an EXIT trap to restore the original nr_hugepages 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 447769657634..ca33ec83ebf2 100755 --- a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh +++ b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh @@ -12,6 +12,7 @@ if [[ $(id -u) -ne 0 ]]; then fi nr_hugepgs=$(cat /proc/sys/vm/nr_hugepages) +trap 'echo "$nr_hugepgs" > /proc/sys/vm/nr_hugepages' EXIT fault_limit_file=limit_in_bytes reservation_limit_file=rsvd.limit_in_bytes @@ -65,7 +66,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 } @@ -594,4 +594,3 @@ if [[ $do_umount ]]; then rmdir $cgroup_path fi -echo "$nr_hugepgs" > /proc/sys/vm/nr_hugepages -- 2.52.0