Lines Matching +full:1 +full:- +full:1024
2 # SPDX-License-Identifier: GPL-2.0
4 # Kselftest framework requirement - SKIP code is 4.
7 set -e
9 if [[ $(id -u) -ne 0 ]]; then
21 if [[ "$1" == "-cgroup-v2" ]]; then
22 cgroup2=1
30 cgroup_path=$(mount -t cgroup2 | head -1 | awk '{print $3}')
31 if [[ -z "$cgroup_path" ]]; then
32 cgroup_path=$(mktemp -d)
33 mount -t cgroup2 none $cgroup_path
34 do_umount=1
38 cgroup_path=$(mount -t cgroup | grep ",hugetlb" | awk '{print $3}')
39 if [[ -z "$cgroup_path" ]]; then
40 cgroup_path=$(mktemp -d)
41 mount -t cgroup memory,hugetlb $cgroup_path
42 do_umount=1
54 if [[ -e /mnt/huge ]]; then
55 rm -rf /mnt/huge/*
59 if [[ -e $cgroup_path/hugetlb_cgroup_test ]]; then
62 if [[ -e $cgroup_path/hugetlb_cgroup_test1 ]]; then
65 if [[ -e $cgroup_path/hugetlb_cgroup_test2 ]]; then
73 local expected="$1"
80 exit 1
85 hpz=$(grep -i hugepagesize /proc/meminfo)
86 kb=${hpz:14:-3}
87 mb=$(($kb / 1024))
94 local name="$1"
107 if [ -e "$cgroup_path/$name/cpuset.cpus" ]; then
110 if [ -e "$cgroup_path/$name/cpuset.mems" ]; then
116 local cgroup="$1"
127 local cgroup="$1"
140 local cgroup="$1"
153 local cgroup="$1"
183 if [[ "$method" == "1" ]] || [[ "$method" == 2 ]] ||
184 [[ "$private" == "-r" ]] && [[ "$expect_failure" != 1 ]]; then
187 "$cgroup" "$path" "$method" "$private" "-l" "$reserve" 2>&1 | tee $output &
192 until grep -q -i "DONE" $output; do
198 exit 1
207 if [[ "$populate" == "-o" ]] || [[ "$write" == "-w" ]]; then
209 elif [[ "$reserve" != "-n" ]]; then
223 if [[ "$reserve" != "-n" ]]; then
227 set -e
229 if [[ "$write_result" == 1 ]]; then
230 reservation_failed=1
238 oom_killed=1
248 hugetlb_difference=$(($hugetlb_after - $hugetlb_before))
249 reserved_difference=$(($reserved_after - $reserved_before))
254 local cgroup="$1"
255 if [[ "$(pgrep -f write_to_hugetlbfs)" != "" ]]; then
257 killall -2 --wait write_to_hugetlbfs
260 set -e
262 if [[ -e /mnt/huge ]]; then
263 rm -rf /mnt/huge/*
270 local size=$(($1 * ${MB} * 1024 * 1024))
273 local cgroup_limit=$(($4 * ${MB} * 1024 * 1024))
274 local reservation_limit=$(($5 * ${MB} * 1024 * 1024))
292 mkdir -p /mnt/huge
293 mount -t hugetlbfs -o pagesize=${MB}M,size=256M none /mnt/huge
311 local size1="$1"
346 mkdir -p /mnt/huge
347 mount -t hugetlbfs -o pagesize=${MB}M,size=256M none /mnt/huge
401 for populate in "" "-o"; do
402 for method in 0 1 2; do
403 for private in "" "-r"; do
404 for reserve in "" "-n"; do
407 if [[ "$method" == 1 ]] && [[ "$private" == "" ]]; then
412 if [[ "$method" == 2"" ]] && [[ "$populate" == "-o" ]]; then
416 if [[ "$method" == 2"" ]] && [[ "$reserve" == "-n" ]]; then
431 if [[ "$populate" == "-o" ]]; then
432 expect_equal "$((5 * $MB * 1024 * 1024))" "$hugetlb_difference" \
439 if [[ "$reserve" != "-n" ]] || [[ "$populate" == "-o" ]]; then
440 expect_equal "$((5 * $MB * 1024 * 1024))" "$reserved_difference" \
455 run_test 5 "$populate" '-w' 5 5 10 "$method" "$private" "0" "$reserve"
460 expect_equal "$((5 * $MB * 1024 * 1024))" "$hugetlb_difference" \
463 expect_equal "$((5 * $MB * 1024 * 1024))" "$reserved_difference" \
476 if [ "$reserve" != "-n" ]; then
477 run_test "5" "$populate" '' "10" "2" "10" "$method" "$private" "1" \
480 expect_equal "1" "$reservation_failed" "Reservation succeeded."
495 run_test 5 "$populate" "-w" 2 10 10 "$method" "$private" "1" "$reserve"
497 expect_equal "1" "$oom_killed" "Not oom killed."
517 if [[ "$reserve" != "-n" ]] || [[ "$populate" == "-o" ]]; then
519 "Incorrect reservations charged to cgroup 1."
526 "Incorrect reservations charged to cgroup 1."
532 if [[ "$populate" == "-o" ]]; then
534 "Incorrect hugetlb charged to cgroup 1."
541 "Incorrect hugetlb charged to cgroup 1."
554 run_multiple_cgroup_test "3" "$populate" "-w" "10" "10" "5" \
555 "$populate" "-w" "10" "10" "10" \
564 "Incorrect hugetlb charged to cgroup 1."
567 "Incorrect reservation charged to cgroup 1."