Skip to content

Commit e157633

Browse files
committed
Merge: selftests/mm: fix va_high_addr_switch.sh failure
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7653 JIRA: https://issues.redhat.com/browse/RHEL-130531 The series is for fixing kselftest hugevm va_high_addr_switch test failure caused by two issues, one issue is no enough hugepage caused failure, the other issues is the unaligned hint addr caused test failure. Added several more commits to resolve the dependency or reduce the conflict context. As the run_vmtests.sh is the entrypoint of all sub tests and some setups are done there,and because of the far distance between the 5.14 and 6.17, there're conflicts on the file in two of the commits. And patch one is a RHEL-only fix, could help to reduce some conflict on vm_runtests.sh. We don't have guard pages feature as no 662df3e ("mm: madvise: implement lightweight guard page mechanism") in rhel9, which is added in v6.13-rc1, and in this version the the guard-pages.c/guard-regions.c test are added. So ignored the commit 6d21130 ("selftests/mm: skip guard_regions.uffd tests when uffd is not present") in the dependency series. Commit cc92882 ("mm: drop hugetlb_get_unmapped_area{_*} functions") is not in the rhel9, in which commit the hint addr round way changed and breaks the test. Commit c563252 ("selftests/mm: fix va_high_addr_switch.sh failure on x86_64") is originally for fixing the broken, using hugepage aligned hint address independent of the align (round up or down) direction being used in the kernel, making it portable, so add it together with the series. Signed-off-by: Chunyu Hu <chuhu@redhat.com> Approved-by: Rafael Aquini <raquini@redhat.com> Approved-by: Luiz Capitulino <luizcap@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Patrick Talbert <ptalbert@redhat.com>
2 parents c99ff8d + 88cd9e1 commit e157633

File tree

3 files changed

+331
-258
lines changed

3 files changed

+331
-258
lines changed

tools/testing/selftests/mm/run_vmtests.sh

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,13 @@ fi
160160

161161
# set proper nr_hugepages
162162
if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then
163-
nr_hugepgs=$(cat /proc/sys/vm/nr_hugepages)
163+
orig_nr_hugepgs=$(cat /proc/sys/vm/nr_hugepages)
164164
needpgs=$((needmem_KB / hpgsize_KB))
165165
tries=2
166166
while [ "$tries" -gt 0 ] && [ "$freepgs" -lt "$needpgs" ]; do
167167
lackpgs=$((needpgs - freepgs))
168168
echo 3 > /proc/sys/vm/drop_caches
169-
if ! echo $((lackpgs + nr_hugepgs)) > /proc/sys/vm/nr_hugepages; then
169+
if ! echo $((lackpgs + orig_nr_hugepgs)) > /proc/sys/vm/nr_hugepages; then
170170
echo "Please run this test as root"
171171
exit $ksft_skip
172172
fi
@@ -177,13 +177,15 @@ if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then
177177
done < /proc/meminfo
178178
tries=$((tries - 1))
179179
done
180+
nr_hugepgs=$(cat /proc/sys/vm/nr_hugepages)
180181
if [ "$freepgs" -lt "$needpgs" ]; then
181182
printf "Not enough huge pages available (%d < %d)\n" \
182183
"$freepgs" "$needpgs"
183184
fi
185+
HAVE_HUGEPAGES=1
184186
else
185187
echo "no hugetlbfs support in kernel?"
186-
exit 1
188+
HAVE_HUGEPAGES=0
187189
fi
188190

189191
# filter 64bit architectures
@@ -212,23 +214,33 @@ pretty_name() {
212214
# Usage: run_test [test binary] [arbitrary test arguments...]
213215
run_test() {
214216
if test_selected ${CATEGORY}; then
215-
echo "running: $1"
217+
local skip=0
218+
216219
# On memory constrainted systems some tests can fail to allocate hugepages.
217220
# perform some cleanup before the test for a higher success rate.
218-
if [ ${CATEGORY} == "thp" ] | [ ${CATEGORY} == "hugetlb" ]; then
219-
echo 3 > /proc/sys/vm/drop_caches
220-
sleep 2
221-
echo 1 > /proc/sys/vm/compact_memory
222-
sleep 2
221+
if [ ${CATEGORY} == "thp" -o ${CATEGORY} == "hugetlb" ]; then
222+
if [ "${HAVE_HUGEPAGES}" = "1" ]; then
223+
echo 3 > /proc/sys/vm/drop_caches
224+
sleep 2
225+
echo 1 > /proc/sys/vm/compact_memory
226+
sleep 2
227+
else
228+
echo "hugepages not supported" | tap_prefix
229+
skip=1
230+
fi
223231
fi
224232

225233
local test=$(pretty_name "$*")
226234
local title="running $*"
227235
local sep=$(echo -n "$title" | tr "[:graph:][:space:]" -)
228236
printf "%s\n%s\n%s\n" "$sep" "$title" "$sep" | tap_prefix
229237

230-
("$@" 2>&1) | tap_prefix
231-
local ret=${PIPESTATUS[0]}
238+
if [ "${skip}" != "1" ]; then
239+
("$@" 2>&1) | tap_prefix
240+
local ret=${PIPESTATUS[0]}
241+
else
242+
local ret=$ksft_skip
243+
fi
232244
count_total=$(( count_total + 1 ))
233245
if [ $ret -eq 0 ]; then
234246
count_pass=$(( count_pass + 1 ))
@@ -265,13 +277,15 @@ CATEGORY="hugetlb" run_test ./hugepage-mremap
265277
CATEGORY="hugetlb" run_test ./hugepage-vmemmap
266278
CATEGORY="hugetlb" run_test ./hugetlb-madvise
267279

268-
nr_hugepages_tmp=$(cat /proc/sys/vm/nr_hugepages)
269-
# For this test, we need one and just one huge page
270-
echo 1 > /proc/sys/vm/nr_hugepages
271-
CATEGORY="hugetlb" run_test ./hugetlb_fault_after_madv
272-
CATEGORY="hugetlb" run_test ./hugetlb_madv_vs_map
273-
# Restore the previous number of huge pages, since further tests rely on it
274-
echo "$nr_hugepages_tmp" > /proc/sys/vm/nr_hugepages
280+
if [ "${HAVE_HUGEPAGES}" = "1" ]; then
281+
nr_hugepages_tmp=$(cat /proc/sys/vm/nr_hugepages)
282+
# For this test, we need one and just one huge page
283+
echo 1 > /proc/sys/vm/nr_hugepages
284+
CATEGORY="hugetlb" run_test ./hugetlb_fault_after_madv
285+
CATEGORY="hugetlb" run_test ./hugetlb_madv_vs_map
286+
# Restore the previous number of huge pages, since further tests rely on it
287+
echo "$nr_hugepages_tmp" > /proc/sys/vm/nr_hugepages
288+
fi
275289

276290
if test_selected "hugetlb"; then
277291
echo "NOTE: These hugetlb tests provide minimal coverage. Use" | tap_prefix
@@ -371,7 +385,9 @@ CATEGORY="madv_populate" run_test ./madv_populate
371385
CATEGORY="memfd_secret" run_test ./memfd_secret
372386

373387
# KSM KSM_MERGE_TIME_HUGE_PAGES test with size of 100
374-
CATEGORY="ksm" run_test ./ksm_tests -H -s 100
388+
if [ "${HAVE_HUGEPAGES}" = "1" ]; then
389+
CATEGORY="ksm" run_test ./ksm_tests -H -s 100
390+
fi
375391
# KSM KSM_MERGE_TIME test with size of 100
376392
CATEGORY="ksm" run_test ./ksm_tests -P -s 100
377393
# KSM MADV_MERGEABLE test with 10 identical pages
@@ -420,6 +436,10 @@ CATEGORY="migration" run_test ./migration
420436

421437
CATEGORY="mkdirty" run_test ./mkdirty
422438

439+
if [ "${HAVE_HUGEPAGES}" = 1 ]; then
440+
echo "$orig_nr_hugepgs" > /proc/sys/vm/nr_hugepages
441+
fi
442+
423443
echo "SUMMARY: PASS=${count_pass} SKIP=${count_skip} FAIL=${count_fail}" | tap_prefix
424444
echo "1..${count_total}" | tap_output
425445

0 commit comments

Comments
 (0)