From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796459757; b=nXZHSJodLnlIoTB8aVMg01YTJmSf0uMH0YcTfN2dT6hMCRSd/FYNtRAUbZBxoH7f2Yvj 5PKAAbxfB/KJE0BcVvUWjtMIjrIjeyxtSNI6z0A9bgMgj2GPpUr439T1T7sQVw+w2wNX1 BQTpZNXX4UXEswa4jXqKhRrwaQrle8fHdAdyvRmSzvC95XXjWts0zKwBXaoFrMRWYq9zS eqWD43WzuABrHVAxwbSWikDynMuBGWWTm03CfFzNrKW5Dxpw+h6DD6ekWIRx8QbvQzjnT EZtoq0z5WmqXxodkknVGSInMOTF3DSwykyegtig5R3nwyVHj6pfbEFe3CFmEkKHNC7Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796459757; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=6PYd3GFAZbg5JdM9Zs3mSpJShVtzWhNB+Jrzxw4jm1I=; b=rDJB/HJRgwE6KgoTo/jjm2XWFTP/52dnW+jLcx/NQIrLx+KRJo3Cx73vcHjMvKpULDir yYsl1or94/BESpIZDpucl3vwPD1fl3pgBTSby1IfyniA34jAb45CO/CM4UYtbjtfEN4CG 2f2cFR7DzwFCS5e43S31in0MX1YVEp6M+CE3Hy0li8lx5i4xzTyivHKwtDX1d5gJBzVJ/ Bvmq/KapwbZ+00DYEN7uvpaiQj2nR8tJGH9Xfjn5bimtA9HnkLW89krkoNdYIl93tiksb 5LiSqUxnNogUxAAh7fEUM4ZlZSmTrKd75JJTEH/XzO6C41Zo2AC6ieEArFcSjVi+Mdw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=Oo0BQcAR; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64D56606A322 for ; Sat, 5 Dec 2026 08:35:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=Oo0BQcAR Received: by smtp.kernel.org (Postfix) with ESMTPSA id E80D31F00936; Sat, 5 Dec 2026 08:35:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796459757; bh=6PYd3GFAZbg5JdM9Zs3mSpJShVtzWhNB+Jrzxw4jm1I=; h=Date:To:From:In-Reply-To:References:Subject; b=Oo0BQcARdifaHOqZ0eiFVP/YkS+k0q3LLcI6NGbMoh93jJmDSBSD8LD9XVcxBU1jM Pv+ENJrqqBl1YJhizeXUHhiw5/gi4vI3v7v4jT/5Xmu1ztpF6tLakgzl0Ujl+blErM DWl+0UElwsid1EZMPZHNPrra0WtUJ9oVvRrwsBWk= Date: Sat, 05 Dec 2026 00:35:56 -0800 To: mm-commits@vger.kernel.org,ziy@nvidia.com,vbabka@kernel.org, shuah@kernel.org,sayalip@linux.ibm.com,rppt@kernel.org,mhocko@suse.com, li.wang@linux.dev,liam@infradead.org,husong@kylinos.cn,david@kernel.org, almasrymina@google.com,lylin1023@gmail.com,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261205-hugetlb-charge-multi-cgroup-v1-4-e88105afc12a@gmail.com> References: <20261205-hugetlb-charge-multi-cgroup-v1-4-e88105afc12a@gmail.com> Subject: + selftests-mm-fix-and-enable-the-multiple-cgroups-hugetlb-tests.patch added to mm-new branch Message-Id: <20261205083556.E80D31F00936@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: selftests/mm: fix and enable the multiple cgroups hugetlb tests has been added to the -mm mm-new branch. Its filename is selftests-mm-fix-and-enable-the-multiple-cgroups-hugetlb-tests.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-mm-fix-and-enable-the-multiple-cgroups-hugetlb-tests.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Kurt Lin Subject: selftests/mm: fix and enable the multiple cgroups hugetlb tests Date: Sat, 05 Dec 2026 01:32:00 +0800 run_multiple_cgroup_test() has never worked: - Its sizes and limits are page counts, but unlike run_test() it never converts them to bytes, so all reservations fail. - Its checks compare page counts with differences in bytes. - Its local declarations, split over two lines, became "local x= /path", which aborts the script under set -e. - It calls cleanup_hugetlb_memory() without a cgroup, so the cleanup waits for nothing. Fix all four and stop skipping the test. Each cgroup is now charged exactly 3 and 5 huge pages, and the write in the second cgroup leaves the usage of the first one unchanged. Link: https://patch.msgid.link/20261205-hugetlb-charge-multi-cgroup-v1-4-e88105afc12a@gmail.com Fixes: 29750f71a9b4 ("hugetlb_cgroup: add hugetlb_cgroup reservation tests") Fixes: 404c04e010da ("selftests/mm: fix hugetlb pathname construction in charge_reserved_hugetlb.sh") Signed-off-by: Kurt Lin Signed-off-by: Andrew Morton Cc: David Hildenbrand Cc: Liam R. Howlett Cc: Vlastimil Babka Cc: Mike Rapoport Cc: Michal Hocko Cc: Shuah Khan Cc: Mina Almasry Cc: Sayali Patil Cc: Zi Yan Cc: Song Hu Cc: Li Wang tools/testing/selftests/mm/charge_reserved_hugetlb.sh | 59 ++++------ 1 file changed, 25 insertions(+), 34 deletions(-) --- a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh~selftests-mm-fix-and-enable-the-multiple-cgroups-hugetlb-tests +++ a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh @@ -283,14 +283,16 @@ function write_hugetlbfs_and_get_usage() function cleanup_hugetlb_memory() { set +e - local cgroup="$1" + local cgroup if [[ "$(pgrep -f write_to_hugetlbfs)" != "" ]]; then echo killing write_to_hugetlbfs killall -2 write_to_hugetlbfs while pgrep -f write_to_hugetlbfs > /dev/null; do sleep 0.1 done - wait_for_hugetlb_memory_to_get_depleted $cgroup + for cgroup in "$@"; do + wait_for_hugetlb_memory_to_get_depleted $cgroup + done fi set -e @@ -345,17 +347,17 @@ function run_test() { } function run_multiple_cgroup_test() { - local size1="$1" + local size1=$(($1 * ${MB} * 1024 * 1024)) local populate1="$2" local write1="$3" - local cgroup_limit1="$4" - local reservation_limit1="$5" + local cgroup_limit1=$(($4 * ${MB} * 1024 * 1024)) + local reservation_limit1=$(($5 * ${MB} * 1024 * 1024)) - local size2="$6" + local size2=$(($6 * ${MB} * 1024 * 1024)) local populate2="$7" local write2="$8" - local cgroup_limit2="$9" - local reservation_limit2="${10}" + local cgroup_limit2=$(($9 * ${MB} * 1024 * 1024)) + local reservation_limit2=$((${10} * ${MB} * 1024 * 1024)) local nr_hugepages="${11}" local method="${12}" @@ -392,14 +394,12 @@ function run_multiple_cgroup_test() { reservation_failed1=$reservation_failed oom_killed1=$oom_killed - local cgroup1_hugetlb_usage=\ - $cgroup_path/hugetlb_cgroup_test1/hugetlb.${MB_DISPLAY}${UNIT}.$fault_usage_file - local cgroup1_reservation_usage=\ - $cgroup_path/hugetlb_cgroup_test1/hugetlb.${MB_DISPLAY}${UNIT}.$reservation_usage_file - local cgroup2_hugetlb_usage=\ - $cgroup_path/hugetlb_cgroup_test2/hugetlb.${MB_DISPLAY}${UNIT}.$fault_usage_file - local cgroup2_reservation_usage=\ - $cgroup_path/hugetlb_cgroup_test2/hugetlb.${MB_DISPLAY}${UNIT}.$reservation_usage_file + local prefix1=$cgroup_path/hugetlb_cgroup_test1/hugetlb.${MB_DISPLAY}${UNIT} + local prefix2=$cgroup_path/hugetlb_cgroup_test2/hugetlb.${MB_DISPLAY}${UNIT} + local cgroup1_hugetlb_usage=$prefix1.$fault_usage_file + local cgroup1_reservation_usage=$prefix1.$reservation_usage_file + local cgroup2_hugetlb_usage=$prefix2.$fault_usage_file + local cgroup2_reservation_usage=$prefix2.$reservation_usage_file local usage_before_second_write=$(cat $cgroup1_hugetlb_usage) local reservation_usage_before_second_write=$(cat $cgroup1_reservation_usage) @@ -418,7 +418,7 @@ function run_multiple_cgroup_test() { expect_equal "$reservation_usage_before_second_write" \ "$(cat $cgroup1_reservation_usage)" "Reservation usage changed." - cleanup_hugetlb_memory + cleanup_hugetlb_memory "hugetlb_cgroup_test1" "hugetlb_cgroup_test2" local final_hugetlb=$(cat $cgroup1_hugetlb_usage) local final_reservation=$(cat $cgroup1_reservation_usage) @@ -524,15 +524,6 @@ for populate in "" "-o"; do cleanup - # The "multiple cgroups" scenario (run_multiple_cgroup_test) is - # multiply broken and has never run in CI: a backslash - # line-continuation breaks its local declarations, it passes - # reservation sizes in bytes rather than pages (unlike - # run_test), and its assertions compare page counts to byte - # values. Skip it until properly rewritten; the two scenarios - # above are restored by this change. - continue - echo echo echo @@ -564,10 +555,10 @@ for populate in "" "-o"; do echo Memory charged to reservation2=$reserved_difference2 if [[ "$reserve" != "-n" ]] || [[ "$populate" == "-o" ]]; then - expect_equal "3" "$reserved_difference1" \ + expect_equal "$((3 * $MB * 1024 * 1024))" "$reserved_difference1" \ "Incorrect reservations charged to cgroup 1." - expect_equal "5" "$reserved_difference2" \ + expect_equal "$((5 * $MB * 1024 * 1024))" "$reserved_difference2" \ "Incorrect reservation charged to cgroup 2." else @@ -579,10 +570,10 @@ for populate in "" "-o"; do fi if [[ "$populate" == "-o" ]]; then - expect_equal "3" "$hugetlb_difference1" \ + expect_equal "$((3 * $MB * 1024 * 1024))" "$hugetlb_difference1" \ "Incorrect hugetlb charged to cgroup 1." - expect_equal "5" "$hugetlb_difference2" \ + expect_equal "$((5 * $MB * 1024 * 1024))" "$hugetlb_difference2" \ "Incorrect hugetlb charged to cgroup 2." else @@ -609,16 +600,16 @@ for populate in "" "-o"; do echo Memory charged to hugtlb2=$hugetlb_difference2 echo Memory charged to reservation2=$reserved_difference2 - expect_equal "3" "$hugetlb_difference1" \ + expect_equal "$((3 * $MB * 1024 * 1024))" "$hugetlb_difference1" \ "Incorrect hugetlb charged to cgroup 1." - expect_equal "3" "$reserved_difference1" \ + expect_equal "$((3 * $MB * 1024 * 1024))" "$reserved_difference1" \ "Incorrect reservation charged to cgroup 1." - expect_equal "5" "$hugetlb_difference2" \ + expect_equal "$((5 * $MB * 1024 * 1024))" "$hugetlb_difference2" \ "Incorrect hugetlb charged to cgroup 2." - expect_equal "5" "$reserved_difference2" \ + expect_equal "$((5 * $MB * 1024 * 1024))" "$reserved_difference2" \ "Incorrected reservation charged to cgroup 2." echo 'PASS' _ Patches currently in -mm which might be from lylin1023@gmail.com are selftests-mm-dont-wait-for-a-hugetlb-reservation-that-is-expected-to-fail.patch selftests-mm-dont-use-killall-wait-in-charge_reserved_hugetlbsh.patch selftests-mm-fix-and-enable-the-multiple-cgroups-hugetlb-tests.patch