From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796405564; b=Q9Kp1PjSmWPSYJls0mCBTTnbVpbg/hxTi3a/Pbf+1A4LdKBKjdIdME/2yfO+xE1nwLuy dPmwJPL1tNPi9llqtIuy/Jl0KR3AACBzsuRqa2jb3dVaeJ29Rq4fDl8JxPgcv/Cj6LxOS bUuKpQ52/VaFXnR2WULPaeUEuH9AiFJx3rYEUuRloSTzjfV6Wom1iGCWi50Z0gsy5r2+4 Nue7EnDCU8aTLGMrMVsyT8NEeDKqb8kg7PgFvxFZvWVcDMwjy6dTmOgeFVHThhtwyulfc 3f0ke0TqhKYpl4QmeNXdM2vCoOB2Te9OP28nZFC5kMsLduBIFH4x5j8Xb5QuTBEI9DA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796405564; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=mxlWbZHIQO13peBZ+o7BLt/u3ldoW6AA7bIYAzMC95w=; b=fsmWoUubx2c2btlwHvEHbZsyQIO4iGQzoDdvE+Dv/Vst2CKzInx7++Ex0/09yU05xYSL rbUbnTjHTdkgYmFEwxvgSH5Am8WKu/KR9uMScYB9osy+wqB15Bdq8njRRmbD5rAI7y2ga sYrXR0t5G0ZXJkZz8stAA9kJs5jD48WqOZl/wCTGSOwLoOHZyX7rYcDfIp/Z5SUKfh4Nj aSPX0lTxCbu8PJLQ+Map97Bmg92wveW2t4MbwyjX4mw+IgalEYrKkZp7Bp/qAZRruclsE 7hJo8cNBJVXyhAzCfUnspcMxVF9MaZU91lFrYMozqfb0JV4PgoUqyb5uzlv/YYss8RA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=lAwotwwb; arc=none smtp.remote-ip=209.85.216.53 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2DBC606A322 for ; Fri, 4 Dec 2026 17:32:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C2DBC606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=lAwotwwb Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-3b53db3d0a5so623623a91.0 for ; Fri, 04 Dec 2026 09:32:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796405563; x=1797010363; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=mxlWbZHIQO13peBZ+o7BLt/u3ldoW6AA7bIYAzMC95w=; b=lAwotwwbj6jo/s4oz7EtS4Sime0KJUhv/Q2+Ei7W+TK159WYzkXKrduiyIZHPtHkN/ 6R2c0Ww5nbHvTGspRRrAiwdCres19PKNYbo6ScMkfA8ICrRvy0akFDzbDRChz2we6R+D /03Vd8T45ainXNgoxDauPVPO2Hi0M00o4jGC5fMRsqgEoI/FjyAlvreI5DjQcAJTRbjD kNqMMXNz0BirWQoVz+AolssYawzkLSMBEPWgeu44dVWaEsubaP4YkVP3mEVEJ4/LJRbV zNB9TekN9JV8AFhzNCz2Bho7Axd9mLMkKjK2WjczN7XML2RAzCG1kyNyHqaJYLtUHz/I rrQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796405563; x=1797010363; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mxlWbZHIQO13peBZ+o7BLt/u3ldoW6AA7bIYAzMC95w=; b=evARkLqmHqIVssovkgxxAKqOZMXyW+G7jqVc8t2nHwAlJ6KWRPvrNkh05Ox9KWHWg8 ScC/tK3S3fykjae3Kxrk+FLWRr/GP7WBadPu5Pji/n1xCNGxqrFAj8HYbEjdxXEMhNtd FRSgTLPrlEno5oUtzuBTPQaFHTMRxxr/NuXd/8nNbbZObkdveeRgc0WtydqIG/juBfLZ xO5DHF7VLzgiOkkcx03Ho23iZB+RoSVoOMV6ZlhXrDxCmGgAzdSSB0MOgq16sV8y+DFS jLNZ3FFOwv5891ZfVSxFkO8aFjodcDm4cupOorNihGy8/zDllYkaMJYwVEGqeRt1ZjIL AQUA== X-Forwarded-Encrypted: i=1; AL+hErG32KgNMHlWN764B/11533ChzIz6TnkeS+Fz2NvI6HoN6XgfHfVGC5nq14Xkwe+4q01AOPyNWa3nj0PSW0=@vger.kernel.org X-Gm-Message-State: AB4q+uGgu27YnTGrr3qe9izPSv/leUuP3zv03i0OtWVj353sIR/BkpWc HXp3ZtENkc4p/PYKNpzqzwnshQBiUNEawzhc37PgmjLC5kYK6y8rgsgi X-Gm-Gg: AZFdTZdGj/U1czx4Bz5sQ8IOTegMemQRs9/h4pQx3pTGjmQgOJdAjOklVXDwLPfmYLs Tz1oSGj0b3DAJzEgHTKQv9PUe009v5lksz9+XrAXxN4GGgbF71SsqASfS3ipplizVPln8s9y4eZ 1KlSVe5MDMpwpiZ0nIFqAbdxnvNL9lQuDqEg8OnLEb4q5A3dOdxlQaZBC+SCyZQlnlauZeyA5fO LaTigd1pqhUaxITr4K992UELMX58W6AM6ErM2+YAtsssONSNQ5+LNJynyYtojf5YDfY16mGBJF9 Q+TYMnXT5TIrGXapzHNSWEQ6tYgF1OBZgpmazdiDZ0M/JS6Qz8jWTU7SL+oFfGQufAJgH9WXR1i 3KwbcmyFWNMb4VCqnCTkN/3Jos0coVlFplIuFIyOEtBfaaQGzt9yktD/wTz8Xv8G1IG1NnMELZz /rHIRRRbwMx4E41NkU3r01WV3WumD4+zvUBFYp5WKVH5r7UXRXHRiqXDB/sW/qMTvz7GEVV4D5j 90z/V4u47NENofQliEAc4QR3MnF4PD1mqVDwap/gPdx1GIWEcVgmqwV9s2T86bt1vf/SR0oZjaq KF00ybUxiSx1iWmhd+RgHqikNVACIbULZGh4mA== X-Received: by 2002:a17:90b:58c5:b0:3b1:7329:a127 with SMTP id 98e67ed59e1d1-3b5e05d66ffmr2194864a91.20.1796405562801; Fri, 04 Dec 2026 09:32:42 -0800 (PST) Received: from [192.168.18.15] ([118.150.29.205]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b5ddc732b1sm4993686a91.16.2026.12.04.09.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 09:32:42 -0800 (PST) From: Kurt Lin Date: Sat, 05 Dec 2026 01:32:00 +0800 Subject: [PATCH 4/4] selftests/mm: fix and enable the multiple cgroups hugetlb tests X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261205-hugetlb-charge-multi-cgroup-v1-4-e88105afc12a@gmail.com> References: <20261205-hugetlb-charge-multi-cgroup-v1-0-e88105afc12a@gmail.com> In-Reply-To: <20261205-hugetlb-charge-multi-cgroup-v1-0-e88105afc12a@gmail.com> To: Andrew Morton Cc: David Hildenbrand , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Michal Hocko , Shuah Khan , Mina Almasry , Sayali Patil , Zi Yan , Song Hu , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Li Wang , Kurt Lin X-Mailer: b4 0.14.3 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. 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 --- .../selftests/mm/charge_reserved_hugetlb.sh | 59 +++++++++------------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh index e43b7bc1ad1b..ca84c353e28f 100755 --- a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh +++ b/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' -- 2.56.1