* [PATCH 0/4] selftests/mm: run all hugetlb cgroup reservation tests
@ 2026-12-04 17:31 Kurt Lin
2026-12-04 17:31 ` [PATCH 1/4] selftests/mm: don't wait for a hugetlb reservation that is expected to fail Kurt Lin
` (4 more replies)
0 siblings, 5 replies; 14+ messages in thread
From: Kurt Lin @ 2026-12-04 17:31 UTC (permalink / raw)
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, linux-kselftest,
linux-kernel, Li Wang, Kurt Lin
Song's "selftests/mm: restore hidden hugetlb reservation scenarios" was
dropped from mm-unstable because it made the hugetlb category of the
linux-mm CI time out [1]. The time goes into a 60 second wait in the
cases that expect a reservation to fail. As there has been no follow-up,
this series carries Song's patch (3/4, unchanged) behind fixes for that
(1-2/4), and fixes the multiple cgroups test it had to leave skipped
(4/4). That test failed only because of bugs in the script.
Tested in a virtme-ng guest on mm-new: charge_reserved_hugetlb.sh
-cgroup-v2 passes all 84 checks in about 62 seconds, and
run_vmtests.sh -t hugetlb passes in 87 seconds. It also passes with
KASAN and lockdep on an mm-new that includes David's "mm/hugetlb:
various fixes (2)" v1. Not tested with cgroup v1 or other huge page
sizes.
Found and fixed with the help of an AI coding assistant.
[1] https://lore.kernel.org/20260714021630.1063823-1-husong@kylinos.cn
---
Kurt Lin (3):
selftests/mm: don't wait for a hugetlb reservation that is expected to fail
selftests/mm: don't use killall --wait in charge_reserved_hugetlb.sh
selftests/mm: fix and enable the multiple cgroups hugetlb tests
Song Hu (1):
selftests/mm: restore hidden hugetlb reservation scenarios
.../selftests/mm/charge_reserved_hugetlb.sh | 62 +++++++++++-----------
1 file changed, 32 insertions(+), 30 deletions(-)
---
base-commit: 872ceec1e3caf227655a58f7407a9c8493dcf56f
change-id: 20261205-hugetlb-charge-multi-cgroup-c222845080f1
Best regards,
--
Kurt Lin <lylin1023@gmail.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/4] selftests/mm: don't wait for a hugetlb reservation that is expected to fail
2026-12-04 17:31 [PATCH 0/4] selftests/mm: run all hugetlb cgroup reservation tests Kurt Lin
@ 2026-12-04 17:31 ` Kurt Lin
2026-12-05 8:35 ` + selftests-mm-dont-wait-for-a-hugetlb-reservation-that-is-expected-to-fail.patch added to mm-new branch Andrew Morton
2026-12-05 17:33 ` [PATCH 1/4] selftests/mm: don't wait for a hugetlb reservation that is expected to fail sashiko-bot
2026-12-04 17:31 ` [PATCH 2/4] selftests/mm: don't use killall --wait in charge_reserved_hugetlb.sh Kurt Lin
` (3 subsequent siblings)
4 siblings, 2 replies; 14+ messages in thread
From: Kurt Lin @ 2026-12-04 17:31 UTC (permalink / raw)
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, linux-kselftest,
linux-kernel, Li Wang, Kurt Lin
After a synchronous write, write_hugetlbfs_and_get_usage() waits for
the reservation usage to reach the requested size, even when the
reservation is expected to fail. That wait then times out after 60
seconds.
The "more than reservation" and "more than cgroup limit" cases, hidden
by a stray 'continue' today, take this path. When they were restored,
the hugetlb category of the linux-mm CI hit its 300 second timeout
after three such waits.
Only wait when the reservation is expected to succeed.
Signed-off-by: Kurt Lin <lylin1023@gmail.com>
---
tools/testing/selftests/mm/charge_reserved_hugetlb.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
index 65065b1377b2..043cc1b1eb5f 100755
--- a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
+++ b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
@@ -252,7 +252,7 @@ function write_hugetlbfs_and_get_usage() {
"$cgroup" "$path" "$method" "$private" "$reserve"
local write_result=$?
- if [[ "$reserve" != "-n" ]]; then
+ if [[ "$reserve" != "-n" ]] && [[ "$expect_failure" != 1 ]]; then
wait_for_hugetlb_memory_to_get_reserved "$cgroup" "$size"
fi
fi
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/4] selftests/mm: don't use killall --wait in charge_reserved_hugetlb.sh
2026-12-04 17:31 [PATCH 0/4] selftests/mm: run all hugetlb cgroup reservation tests Kurt Lin
2026-12-04 17:31 ` [PATCH 1/4] selftests/mm: don't wait for a hugetlb reservation that is expected to fail Kurt Lin
@ 2026-12-04 17:31 ` Kurt Lin
2026-12-05 8:35 ` + selftests-mm-dont-use-killall-wait-in-charge_reserved_hugetlbsh.patch added to mm-new branch Andrew Morton
2026-12-05 17:33 ` [PATCH 2/4] selftests/mm: don't use killall --wait in charge_reserved_hugetlb.sh sashiko-bot
2026-12-04 17:31 ` [PATCH 3/4] selftests/mm: restore hidden hugetlb reservation scenarios Kurt Lin
` (2 subsequent siblings)
4 siblings, 2 replies; 14+ messages in thread
From: Kurt Lin @ 2026-12-04 17:31 UTC (permalink / raw)
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, linux-kselftest,
linux-kernel, Li Wang, Kurt Lin
killall --wait checks only once a second whether the processes are
gone, so each cleanup of a write_to_hugetlbfs process costs about a
second, although it exits right away on SIGINT.
Poll with pgrep every 0.1 seconds instead. With all test cases enabled,
this cuts charge_reserved_hugetlb.sh -cgroup-v2 from 144 to 62 seconds
in a virtme-ng guest.
Signed-off-by: Kurt Lin <lylin1023@gmail.com>
---
tools/testing/selftests/mm/charge_reserved_hugetlb.sh | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
index 043cc1b1eb5f..92d6a66e6a84 100755
--- a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
+++ b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
@@ -286,7 +286,10 @@ function cleanup_hugetlb_memory() {
local cgroup="$1"
if [[ "$(pgrep -f write_to_hugetlbfs)" != "" ]]; then
echo killing write_to_hugetlbfs
- killall -2 --wait 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
fi
set -e
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/4] selftests/mm: restore hidden hugetlb reservation scenarios
2026-12-04 17:31 [PATCH 0/4] selftests/mm: run all hugetlb cgroup reservation tests Kurt Lin
2026-12-04 17:31 ` [PATCH 1/4] selftests/mm: don't wait for a hugetlb reservation that is expected to fail Kurt Lin
2026-12-04 17:31 ` [PATCH 2/4] selftests/mm: don't use killall --wait in charge_reserved_hugetlb.sh Kurt Lin
@ 2026-12-04 17:31 ` Kurt Lin
2026-12-05 8:35 ` + selftests-mm-restore-hidden-hugetlb-reservation-scenarios.patch added to mm-new branch Andrew Morton
2026-12-05 17:33 ` [PATCH 3/4] selftests/mm: restore hidden hugetlb reservation scenarios sashiko-bot
2026-12-04 17:32 ` [PATCH 4/4] selftests/mm: fix and enable the multiple cgroups hugetlb tests Kurt Lin
2026-12-05 8:33 ` [PATCH 0/4] selftests/mm: run all hugetlb cgroup reservation tests Andrew Morton
4 siblings, 2 replies; 14+ messages in thread
From: Kurt Lin @ 2026-12-04 17:31 UTC (permalink / raw)
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, linux-kselftest,
linux-kernel, Li Wang, Kurt Lin
From: Song Hu <husong@kylinos.cn>
A stray 'continue' in the main loop of charge_reserved_hugetlb.sh made
the "more than reservation", "more than cgroup limit", and "multiple
cgroups" scenarios unreachable, so they never ran.
Remove it so the first two run again. The third,
run_multiple_cgroup_test(), is separately broken -- a backslash
line-continuation breaks its local declarations and its hugetlb
reservation accounting does not charge as expected -- and has never run
in CI; skip it explicitly with a comment until fixed. Also correct two
`[[ "$method" == 2"" ]]` typos (harmless empty-string concatenation)
to plain `2`.
Signed-off-by: Song Hu <husong@kylinos.cn>
Signed-off-by: Kurt Lin <lylin1023@gmail.com>
---
tools/testing/selftests/mm/charge_reserved_hugetlb.sh | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
index 92d6a66e6a84..e43b7bc1ad1b 100755
--- a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
+++ b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
@@ -450,11 +450,11 @@ for populate in "" "-o"; do
fi
# Skip populated shmem tests. Doesn't seem to be supported.
- if [[ "$method" == 2"" ]] && [[ "$populate" == "-o" ]]; then
+ if [[ "$method" == 2 ]] && [[ "$populate" == "-o" ]]; then
continue
fi
- if [[ "$method" == 2"" ]] && [[ "$reserve" == "-n" ]]; then
+ if [[ "$method" == 2 ]] && [[ "$reserve" == "-n" ]]; then
continue
fi
@@ -507,7 +507,6 @@ for populate in "" "-o"; do
echo 'PASS'
cleanup
- continue
echo
echo
echo
@@ -525,6 +524,15 @@ 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
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 4/4] selftests/mm: fix and enable the multiple cgroups hugetlb tests
2026-12-04 17:31 [PATCH 0/4] selftests/mm: run all hugetlb cgroup reservation tests Kurt Lin
` (2 preceding siblings ...)
2026-12-04 17:31 ` [PATCH 3/4] selftests/mm: restore hidden hugetlb reservation scenarios Kurt Lin
@ 2026-12-04 17:32 ` Kurt Lin
2026-12-05 8:35 ` + selftests-mm-fix-and-enable-the-multiple-cgroups-hugetlb-tests.patch added to mm-new branch Andrew Morton
2026-12-05 17:33 ` [PATCH 4/4] selftests/mm: fix and enable the multiple cgroups hugetlb tests sashiko-bot
2026-12-05 8:33 ` [PATCH 0/4] selftests/mm: run all hugetlb cgroup reservation tests Andrew Morton
4 siblings, 2 replies; 14+ messages in thread
From: Kurt Lin @ 2026-12-04 17:32 UTC (permalink / raw)
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, linux-kselftest,
linux-kernel, Li Wang, Kurt Lin
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 <lylin1023@gmail.com>
---
.../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
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 0/4] selftests/mm: run all hugetlb cgroup reservation tests
2026-12-04 17:31 [PATCH 0/4] selftests/mm: run all hugetlb cgroup reservation tests Kurt Lin
` (3 preceding siblings ...)
2026-12-04 17:32 ` [PATCH 4/4] selftests/mm: fix and enable the multiple cgroups hugetlb tests Kurt Lin
@ 2026-12-05 8:33 ` Andrew Morton
4 siblings, 0 replies; 14+ messages in thread
From: Andrew Morton @ 2026-12-05 8:33 UTC (permalink / raw)
To: Kurt Lin
Cc: David Hildenbrand, Liam R. Howlett, Vlastimil Babka,
Mike Rapoport, Michal Hocko, Shuah Khan, Mina Almasry,
Sayali Patil, Zi Yan, Song Hu, linux-mm, linux-kselftest,
linux-kernel, Li Wang
On Sat, 05 Dec 2026 01:31:56 +0800 Kurt Lin <lylin1023@gmail.com> wrote:
> Song's "selftests/mm: restore hidden hugetlb reservation scenarios" was
> dropped from mm-unstable because it made the hugetlb category of the
> linux-mm CI time out [1]. The time goes into a 60 second wait in the
> cases that expect a reservation to fail. As there has been no follow-up,
> this series carries Song's patch (3/4, unchanged) behind fixes for that
> (1-2/4), and fixes the multiple cgroups test it had to leave skipped
> (4/4). That test failed only because of bugs in the script.
>
> Tested in a virtme-ng guest on mm-new: charge_reserved_hugetlb.sh
> -cgroup-v2 passes all 84 checks in about 62 seconds, and
> run_vmtests.sh -t hugetlb passes in 87 seconds. It also passes with
> KASAN and lockdep on an mm-new that includes David's "mm/hugetlb:
> various fixes (2)" v1.
argh, this thing. 60 seconds isn't acceptable for a selftest!
selftests are to test kernel functionality and nothing else. No stress
testing, no performance testing. In, check, out, done.
I'll grab these 4 on the grounds that they take the situation from
"utterly awful" to merely "really bad", but tokenbot tells me that all
this functionality (plus the functionality which the script fails to
check) can be tested in about 1 second.
> Found and fixed with the help of an AI coding assistant.
I told it
: That script takes about a minute to run whch is not acceptable for a
; selftest. Selftests are to test kernel fuctionality and nothing else.
: No stress tests, no performance tests.
:
: I want you to figure out what kernel functionality that thing is
: testing then propose a replacement C program which tests the same
: functionality in a few seconds. Don't write anything yet - just scope
: out the work.
then
: Is there additional related functionality which this script should test
: but fails to so do?
Result: it's not a trivial project. Numerous design-level decisions
must be made which will require understanding of the APIs which are
being tested and, in some cases, of their internal implementation
details.
And the "internal implementation details" part is problematic. Those
things can change and we shouldn't implement tests which are designed
to match observed current-kernel behavior! The tests should test the
interface as we designed it and as we documented it and as we expect
userspace to use it.
> Not tested with cgroup v1 or other huge page sizes.
That would need to change ;)
^ permalink raw reply [flat|nested] 14+ messages in thread
* + selftests-mm-dont-wait-for-a-hugetlb-reservation-that-is-expected-to-fail.patch added to mm-new branch
2026-12-04 17:31 ` [PATCH 1/4] selftests/mm: don't wait for a hugetlb reservation that is expected to fail Kurt Lin
@ 2026-12-05 8:35 ` Andrew Morton
2026-12-05 17:33 ` [PATCH 1/4] selftests/mm: don't wait for a hugetlb reservation that is expected to fail sashiko-bot
1 sibling, 0 replies; 14+ messages in thread
From: Andrew Morton @ 2026-12-05 8:35 UTC (permalink / raw)
To: mm-commits, ziy, vbabka, shuah, sayalip, rppt, mhocko, li.wang,
liam, husong, david, almasrymina, lylin1023, akpm
The patch titled
Subject: selftests/mm: don't wait for a hugetlb reservation that is expected to fail
has been added to the -mm mm-new branch. Its filename is
selftests-mm-dont-wait-for-a-hugetlb-reservation-that-is-expected-to-fail.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-mm-dont-wait-for-a-hugetlb-reservation-that-is-expected-to-fail.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 <lylin1023@gmail.com>
Subject: selftests/mm: don't wait for a hugetlb reservation that is expected to fail
Date: Sat, 05 Dec 2026 01:31:57 +0800
Patch series "selftests/mm: run all hugetlb cgroup reservation tests".
Song's "selftests/mm: restore hidden hugetlb reservation scenarios" was
dropped from mm-unstable because it made the hugetlb category of the
linux-mm CI time out [1]. The time goes into a 60 second wait in the
cases that expect a reservation to fail. As there has been no follow-up,
this series carries Song's patch (3/4, unchanged) behind fixes for that
(1-2/4), and fixes the multiple cgroups test it had to leave skipped
(4/4). That test failed only because of bugs in the script.
Tested in a virtme-ng guest on mm-new: charge_reserved_hugetlb.sh
-cgroup-v2 passes all 84 checks in about 62 seconds, and run_vmtests.sh -t
hugetlb passes in 87 seconds. It also passes with KASAN and lockdep on an
mm-new that includes David's "mm/hugetlb: various fixes (2)" v1. Not
tested with cgroup v1 or other huge page sizes.
Found and fixed with the help of an AI coding assistant.
This patch (of 4):
After a synchronous write, write_hugetlbfs_and_get_usage() waits for
the reservation usage to reach the requested size, even when the
reservation is expected to fail. That wait then times out after 60
seconds.
The "more than reservation" and "more than cgroup limit" cases, hidden
by a stray 'continue' today, take this path. When they were restored,
the hugetlb category of the linux-mm CI hit its 300 second timeout
after three such waits.
Only wait when the reservation is expected to succeed.
Link: https://lore.kernel.org/20261205-hugetlb-charge-multi-cgroup-v1-0-e88105afc12a@gmail.com
Link: https://patch.msgid.link/20261205-hugetlb-charge-multi-cgroup-v1-1-e88105afc12a@gmail.com
Link: https://lore.kernel.org/20260714021630.1063823-1-husong@kylinos.cn [1]
Signed-off-by: Kurt Lin <lylin1023@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Mina Almasry <almasrymina@google.com>
Cc: Sayali Patil <sayalip@linux.ibm.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Song Hu <husong@kylinos.cn>
Cc: Li Wang <li.wang@linux.dev>
tools/testing/selftests/mm/charge_reserved_hugetlb.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh~selftests-mm-dont-wait-for-a-hugetlb-reservation-that-is-expected-to-fail
+++ a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
@@ -252,7 +252,7 @@ function write_hugetlbfs_and_get_usage()
"$cgroup" "$path" "$method" "$private" "$reserve"
local write_result=$?
- if [[ "$reserve" != "-n" ]]; then
+ if [[ "$reserve" != "-n" ]] && [[ "$expect_failure" != 1 ]]; then
wait_for_hugetlb_memory_to_get_reserved "$cgroup" "$size"
fi
fi
_
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* + selftests-mm-dont-use-killall-wait-in-charge_reserved_hugetlbsh.patch added to mm-new branch
2026-12-04 17:31 ` [PATCH 2/4] selftests/mm: don't use killall --wait in charge_reserved_hugetlb.sh Kurt Lin
@ 2026-12-05 8:35 ` Andrew Morton
2026-12-05 17:33 ` [PATCH 2/4] selftests/mm: don't use killall --wait in charge_reserved_hugetlb.sh sashiko-bot
1 sibling, 0 replies; 14+ messages in thread
From: Andrew Morton @ 2026-12-05 8:35 UTC (permalink / raw)
To: mm-commits, ziy, vbabka, shuah, sayalip, rppt, mhocko, li.wang,
liam, husong, david, almasrymina, lylin1023, akpm
The patch titled
Subject: selftests/mm: don't use killall --wait in charge_reserved_hugetlb.sh
has been added to the -mm mm-new branch. Its filename is
selftests-mm-dont-use-killall-wait-in-charge_reserved_hugetlbsh.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-mm-dont-use-killall-wait-in-charge_reserved_hugetlbsh.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 <lylin1023@gmail.com>
Subject: selftests/mm: don't use killall --wait in charge_reserved_hugetlb.sh
Date: Sat, 05 Dec 2026 01:31:58 +0800
killall --wait checks only once a second whether the processes are
gone, so each cleanup of a write_to_hugetlbfs process costs about a
second, although it exits right away on SIGINT.
Poll with pgrep every 0.1 seconds instead. With all test cases enabled,
this cuts charge_reserved_hugetlb.sh -cgroup-v2 from 144 to 62 seconds
in a virtme-ng guest.
Link: https://patch.msgid.link/20261205-hugetlb-charge-multi-cgroup-v1-2-e88105afc12a@gmail.com
Signed-off-by: Kurt Lin <lylin1023@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Mina Almasry <almasrymina@google.com>
Cc: Sayali Patil <sayalip@linux.ibm.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Song Hu <husong@kylinos.cn>
Cc: Li Wang <li.wang@linux.dev>
tools/testing/selftests/mm/charge_reserved_hugetlb.sh | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh~selftests-mm-dont-use-killall-wait-in-charge_reserved_hugetlbsh
+++ a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
@@ -286,7 +286,10 @@ function cleanup_hugetlb_memory() {
local cgroup="$1"
if [[ "$(pgrep -f write_to_hugetlbfs)" != "" ]]; then
echo killing write_to_hugetlbfs
- killall -2 --wait 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
fi
set -e
_
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* + selftests-mm-restore-hidden-hugetlb-reservation-scenarios.patch added to mm-new branch
2026-12-04 17:31 ` [PATCH 3/4] selftests/mm: restore hidden hugetlb reservation scenarios Kurt Lin
@ 2026-12-05 8:35 ` Andrew Morton
2026-12-05 17:33 ` [PATCH 3/4] selftests/mm: restore hidden hugetlb reservation scenarios sashiko-bot
1 sibling, 0 replies; 14+ messages in thread
From: Andrew Morton @ 2026-12-05 8:35 UTC (permalink / raw)
To: mm-commits, ziy, vbabka, shuah, sayalip, rppt, mhocko, lylin1023,
li.wang, liam, david, almasrymina, husong, akpm
The patch titled
Subject: selftests/mm: restore hidden hugetlb reservation scenarios
has been added to the -mm mm-new branch. Its filename is
selftests-mm-restore-hidden-hugetlb-reservation-scenarios.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-mm-restore-hidden-hugetlb-reservation-scenarios.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: Song Hu <husong@kylinos.cn>
Subject: selftests/mm: restore hidden hugetlb reservation scenarios
Date: Sat, 05 Dec 2026 01:31:59 +0800
A stray 'continue' in the main loop of charge_reserved_hugetlb.sh made the
"more than reservation", "more than cgroup limit", and "multiple cgroups"
scenarios unreachable, so they never ran.
Remove it so the first two run again. The third,
run_multiple_cgroup_test(), is separately broken -- a backslash
line-continuation breaks its local declarations and its hugetlb
reservation accounting does not charge as expected -- and has never run in
CI; skip it explicitly with a comment until fixed. Also correct two `[[
"$method" == 2"" ]]` typos (harmless empty-string concatenation) to plain
`2`.
Link: https://patch.msgid.link/20261205-hugetlb-charge-multi-cgroup-v1-3-e88105afc12a@gmail.com
Signed-off-by: Song Hu <husong@kylinos.cn>
Signed-off-by: Kurt Lin <lylin1023@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Mina Almasry <almasrymina@google.com>
Cc: Sayali Patil <sayalip@linux.ibm.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Li Wang <li.wang@linux.dev>
tools/testing/selftests/mm/charge_reserved_hugetlb.sh | 14 +++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
--- a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh~selftests-mm-restore-hidden-hugetlb-reservation-scenarios
+++ a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
@@ -450,11 +450,11 @@ for populate in "" "-o"; do
fi
# Skip populated shmem tests. Doesn't seem to be supported.
- if [[ "$method" == 2"" ]] && [[ "$populate" == "-o" ]]; then
+ if [[ "$method" == 2 ]] && [[ "$populate" == "-o" ]]; then
continue
fi
- if [[ "$method" == 2"" ]] && [[ "$reserve" == "-n" ]]; then
+ if [[ "$method" == 2 ]] && [[ "$reserve" == "-n" ]]; then
continue
fi
@@ -507,7 +507,6 @@ for populate in "" "-o"; do
echo 'PASS'
cleanup
- continue
echo
echo
echo
@@ -525,6 +524,15 @@ 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
_
Patches currently in -mm which might be from husong@kylinos.cn are
selftests-mm-restore-hidden-hugetlb-reservation-scenarios.patch
^ permalink raw reply [flat|nested] 14+ messages in thread
* + selftests-mm-fix-and-enable-the-multiple-cgroups-hugetlb-tests.patch added to mm-new branch
2026-12-04 17:32 ` [PATCH 4/4] selftests/mm: fix and enable the multiple cgroups hugetlb tests Kurt Lin
@ 2026-12-05 8:35 ` Andrew Morton
2026-12-05 17:33 ` [PATCH 4/4] selftests/mm: fix and enable the multiple cgroups hugetlb tests sashiko-bot
1 sibling, 0 replies; 14+ messages in thread
From: Andrew Morton @ 2026-12-05 8:35 UTC (permalink / raw)
To: mm-commits, ziy, vbabka, shuah, sayalip, rppt, mhocko, li.wang,
liam, husong, david, almasrymina, lylin1023, akpm
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 <lylin1023@gmail.com>
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 <lylin1023@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Mina Almasry <almasrymina@google.com>
Cc: Sayali Patil <sayalip@linux.ibm.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Song Hu <husong@kylinos.cn>
Cc: Li Wang <li.wang@linux.dev>
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/4] selftests/mm: don't wait for a hugetlb reservation that is expected to fail
2026-12-04 17:31 ` [PATCH 1/4] selftests/mm: don't wait for a hugetlb reservation that is expected to fail Kurt Lin
2026-12-05 8:35 ` + selftests-mm-dont-wait-for-a-hugetlb-reservation-that-is-expected-to-fail.patch added to mm-new branch Andrew Morton
@ 2026-12-05 17:33 ` sashiko-bot
1 sibling, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-12-05 17:33 UTC (permalink / raw)
To: Kurt Lin, 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, Li Wang
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] selftests/mm: missing Fixes trailer for commit 29750f71a9b4
--
commit 8b7420b3b5ad93181fc08ff6684f7e1e5f109900
Author: Kurt Lin <lylin1023@gmail.com>
> selftests/mm: don't wait for a hugetlb reservation that is expected to fail
>
> After a synchronous write, write_hugetlbfs_and_get_usage() waits for
> the reservation usage to reach the requested size, even when the
> reservation is expected to fail. That wait then times out after 60
> seconds.
>
> The "more than reservation" and "more than cgroup limit" cases, hidden
> by a stray 'continue' today, take this path. When they were restored,
> the hugetlb category of the linux-mm CI hit its 300 second timeout
> after three such waits.
>
> Only wait when the reservation is expected to succeed.
>
> Signed-off-by: Kurt Lin <lylin1023@gmail.com>
[Severity: Low]
This fixes a bug in write_hugetlbfs_and_get_usage() originally introduced
when the reservation tests were added. Should this include:
Fixes: 29750f71a9b4 ("hugetlb_cgroup: add hugetlb_cgroup reservation tests")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-hugetlb-charge-multi-cgroup-v1-0-e88105afc12a@gmail.com?part=1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/4] selftests/mm: don't use killall --wait in charge_reserved_hugetlb.sh
2026-12-04 17:31 ` [PATCH 2/4] selftests/mm: don't use killall --wait in charge_reserved_hugetlb.sh Kurt Lin
2026-12-05 8:35 ` + selftests-mm-dont-use-killall-wait-in-charge_reserved_hugetlbsh.patch added to mm-new branch Andrew Morton
@ 2026-12-05 17:33 ` sashiko-bot
1 sibling, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-12-05 17:33 UTC (permalink / raw)
To: Kurt Lin, 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, Li Wang
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] selftests/mm: pgrep -f in cleanup_hugetlb_memory() races with
exit teardown
- [Medium] selftests/mm: unbounded pgrep -f loop in
cleanup_hugetlb_memory() can hang
--
commit 99f77c8eb3b70025b3a8360b125d3f858177191f
Author: Kurt Lin <lylin1023@gmail.com>
selftests/mm: don't use killall --wait in charge_reserved_hugetlb.sh
This commit replaces killall -2 --wait with killall -2 followed by a
0.1-second pgrep -f polling loop in cleanup_hugetlb_memory() to reduce the
runtime of charge_reserved_hugetlb.sh.
> diff --git a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
> index 043cc1b1eb5ff..92d6a66e6a846 100755
> --- a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
> +++ b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
> @@ -286,7 +286,10 @@ function cleanup_hugetlb_memory() {
> local cgroup="$1"
> if [[ "$(pgrep -f write_to_hugetlbfs)" != "" ]]; then
> echo killing write_to_hugetlbfs
> - killall -2 --wait 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
> fi
> set -e
[Severity: Medium]
Can polling with pgrep -f return before write_to_hugetlbfs finishes
tearing down, reintroducing the umount EBUSY race fixed by c41a701d18ef
("selftests/mm: fix charge_reserved_hugetlb.sh test")?
pgrep -f reads /proc/<pid>/cmdline, which returns 0 bytes in
get_task_cmdline() as soon as exit_mm() clears current->mm. Because
write_to_hugetlbfs is longer than the 15-character TASK_COMM_LEN limit,
even falling back to /proc/<pid>/comm (write_to_hugetl) will not match:
CPU0 (write_to_hugetlbfs) CPU1 (charge_reserved_hugetlb.sh)
do_exit()
exit_mm()
current->mm = NULL;
pgrep -f write_to_hugetlbfs
get_task_cmdline() -> 0 bytes
wait_for_hugetlb_memory_to_get_depleted
umount /mnt/huge <-- EBUSY
exit_files()
exit_task_work()
cgroup_task_exit()
exit_files(), deferred fput()/mntput() in exit_task_work(), and
cgroup_task_exit() all run after exit_mm(). When rsvd.current is
already 0 (e.g. MAP_NORESERVE without populate), umount /mnt/huge or
rmdir of the test cgroup can fail with EBUSY under set -e.
Capturing the target pids before signaling and polling with kill -0
would preserve killall --wait semantics without the 1-second delay.
[Severity: Medium]
Could this unbounded pgrep -f loop hang cleanup_hugetlb_memory() if an
unrelated process matches the command-line pattern?
killall -2 matches only by process name, whereas pgrep -f matches any
command line containing write_to_hugetlbfs (such as an editor open on
write_to_hugetlbfs.c). Previously, killall --wait only waited on pids
it signaled, so unrelated matches returned immediately.
Without a retry limit like wait_for_file_value() uses, either an
unrelated match or a write_to_hugetlbfs process that does not exit on
SIGINT will spin forever.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-hugetlb-charge-multi-cgroup-v1-0-e88105afc12a@gmail.com?part=2
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/4] selftests/mm: restore hidden hugetlb reservation scenarios
2026-12-04 17:31 ` [PATCH 3/4] selftests/mm: restore hidden hugetlb reservation scenarios Kurt Lin
2026-12-05 8:35 ` + selftests-mm-restore-hidden-hugetlb-reservation-scenarios.patch added to mm-new branch Andrew Morton
@ 2026-12-05 17:33 ` sashiko-bot
1 sibling, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-12-05 17:33 UTC (permalink / raw)
To: Kurt Lin, 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, Li Wang
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] selftests/mm: missing Fixes trailer for commit 29750f71a9b4
- [Low] selftests/mm: misplaced continue still skips cgroup limit test
--
commit 19ae8c68cb5184ba9c0eb05020ea71bc09f043da
Author: Song Hu <husong@kylinos.cn>
> selftests/mm: restore hidden hugetlb reservation scenarios
>
> A stray 'continue' in the main loop of charge_reserved_hugetlb.sh made
> the "more than reservation", "more than cgroup limit", and "multiple
> cgroups" scenarios unreachable, so they never ran.
>
> Remove it so the first two run again. The third,
> run_multiple_cgroup_test(), is separately broken -- a backslash
> line-continuation breaks its local declarations and its hugetlb
> reservation accounting does not charge as expected -- and has never run
> in CI; skip it explicitly with a comment until fixed. Also correct two
> `[[ "$method" == 2"" ]]` typos (harmless empty-string concatenation)
> to plain `2`.
>
> Signed-off-by: Song Hu <husong@kylinos.cn>
> Signed-off-by: Kurt Lin <lylin1023@gmail.com>
[Severity: Low]
This fixes the stray continue and comparison typos introduced by commit
29750f71a9b4 ("hugetlb_cgroup: add hugetlb_cgroup reservation tests").
Should this include:
Fixes: 29750f71a9b4 ("hugetlb_cgroup: add hugetlb_cgroup reservation tests")
> diff --git a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
> index 92d6a66e6a846..e43b7bc1ad1b9 100755
> --- a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
> +++ b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
[ ... ]
> @@ -525,6 +524,15 @@ 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
[Severity: Low]
Does this continue still skip the "Test more than cgroup limit case."
scenario?
This block sits after "Test more than reservation case." and before
"Test more than cgroup limit case.", leaving the cgroup limit test
unreachable contrary to the comment and commit message. Moving it past
that test's cleanup (before "Test normal case, multiple cgroups.") fixes it.
A later patch in the series, commit "selftests/mm: fix and enable the
multiple cgroups hugetlb tests", removes this continue block, so the test
runs at the end of the series, though bisecting or applying this patch
standalone still leaves it skipped.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-hugetlb-charge-multi-cgroup-v1-0-e88105afc12a@gmail.com?part=3
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/4] selftests/mm: fix and enable the multiple cgroups hugetlb tests
2026-12-04 17:32 ` [PATCH 4/4] selftests/mm: fix and enable the multiple cgroups hugetlb tests Kurt Lin
2026-12-05 8:35 ` + selftests-mm-fix-and-enable-the-multiple-cgroups-hugetlb-tests.patch added to mm-new branch Andrew Morton
@ 2026-12-05 17:33 ` sashiko-bot
1 sibling, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-12-05 17:33 UTC (permalink / raw)
To: Kurt Lin, 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, Li Wang
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] selftests/mm: run_multiple_cgroup_test() leaks writers on
failure exit
- [Low] selftests/mm: cleanup_hugetlb_memory() wait loop races with
umount and rmdir
--
commit c995fb54b97ee185014857c42d52be9482317eb8
Author: Kurt Lin <lylin1023@gmail.com>
selftests/mm: fix and enable the multiple cgroups hugetlb tests
This commit converts page counts to bytes in run_multiple_cgroup_test()
and its assertions, fixes its local path variable declarations, passes
both test cgroups to cleanup_hugetlb_memory(), and removes the continue
that skipped the multiple cgroups test.
> diff --git a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh
> index e43b7bc1ad1b9..ca84c353e28fe 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
[Severity: Low]
Can the pgrep wait loop in cleanup_hugetlb_memory() exit before the
writer finishes closing files and detaching from its cgroup?
In do_exit(), exit_mm() clears tsk->mm and uncharges hugepages before
exit_files() closes /mnt/huge descriptors and before
do_cgroup_task_dead() removes the task from its cgroup:
cleanup_hugetlb_memory() write_to_hugetlbfs (do_exit)
killall -2 write_to_hugetlbfs
exit_mm()
clears tsk->mm; uncharges pages
pgrep -f write_to_hugetlbfs -> 1
wait_for_hugetlb_memory_... -> 0
umount /mnt/huge <-- EBUSY
exit_files()
exit_notify()
do_cgroup_task_dead()
Once tsk->mm is cleared, /proc/<pid>/cmdline is empty and comm is
truncated to 15 characters, so pgrep -f write_to_hugetlbfs stops
matching. umount /mnt/huge or rmdir in cleanup() can then fail with
EBUSY under set -e.
write_hugetlb_memory.sh also writes its own PID to cgroup.procs and
runs write_to_hugetlbfs without exec, so rmdir can hit EBUSY while the
wrapper shell is still exiting. Waiting for the background PIDs or for
cgroup.procs to empty before unmounting would close both races.
[ ... ]
> @@ -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"
[Severity: Low]
Does run_multiple_cgroup_test() leak background write_to_hugetlbfs
processes when expect_equal() fails?
On failure, expect_equal() calls cleanup() and exits before
cleanup_hugetlb_memory() stops the sleeping writers. cleanup() does
not kill write_to_hugetlbfs, so umount /mnt/huge and rmdir fail with
EBUSY under set -e, leaking writers, hugepages, mounts, and cgroups.
The same leak happens if the second write_hugetlbfs_and_get_usage()
detects a dead writer and calls cleanup() while the first writer is
still alive. Checking cgroup1 usage after cleanup_hugetlb_memory(), or
killing lingering writers in cleanup(), would avoid leaving them behind.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-hugetlb-charge-multi-cgroup-v1-0-e88105afc12a@gmail.com?part=4
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-12-05 17:33 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 17:31 [PATCH 0/4] selftests/mm: run all hugetlb cgroup reservation tests Kurt Lin
2026-12-04 17:31 ` [PATCH 1/4] selftests/mm: don't wait for a hugetlb reservation that is expected to fail Kurt Lin
2026-12-05 8:35 ` + selftests-mm-dont-wait-for-a-hugetlb-reservation-that-is-expected-to-fail.patch added to mm-new branch Andrew Morton
2026-12-05 17:33 ` [PATCH 1/4] selftests/mm: don't wait for a hugetlb reservation that is expected to fail sashiko-bot
2026-12-04 17:31 ` [PATCH 2/4] selftests/mm: don't use killall --wait in charge_reserved_hugetlb.sh Kurt Lin
2026-12-05 8:35 ` + selftests-mm-dont-use-killall-wait-in-charge_reserved_hugetlbsh.patch added to mm-new branch Andrew Morton
2026-12-05 17:33 ` [PATCH 2/4] selftests/mm: don't use killall --wait in charge_reserved_hugetlb.sh sashiko-bot
2026-12-04 17:31 ` [PATCH 3/4] selftests/mm: restore hidden hugetlb reservation scenarios Kurt Lin
2026-12-05 8:35 ` + selftests-mm-restore-hidden-hugetlb-reservation-scenarios.patch added to mm-new branch Andrew Morton
2026-12-05 17:33 ` [PATCH 3/4] selftests/mm: restore hidden hugetlb reservation scenarios sashiko-bot
2026-12-04 17:32 ` [PATCH 4/4] selftests/mm: fix and enable the multiple cgroups hugetlb tests Kurt Lin
2026-12-05 8:35 ` + selftests-mm-fix-and-enable-the-multiple-cgroups-hugetlb-tests.patch added to mm-new branch Andrew Morton
2026-12-05 17:33 ` [PATCH 4/4] selftests/mm: fix and enable the multiple cgroups hugetlb tests sashiko-bot
2026-12-05 8:33 ` [PATCH 0/4] selftests/mm: run all hugetlb cgroup reservation tests Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.