On Tue, Jun 28, 2022 at 08:16:41PM +0530, Aneesh Kumar K V wrote: > On 6/28/22 12:22 AM, Andrew Morton wrote: > > The patch titled > > Subject: selftests/vm: Only run 128TBswitch with 5-level paging > > has been added to the -mm mm-unstable branch. Its filename is > > selftests-vm-only-run-128tbswitch-with-5-level-paging.patch > > > > This patch will shortly appear at > > https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-vm-only-run-128tbswitch-with-5-level-paging.patch > > > > This patch will later appear in the mm-unstable branch at > > git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm > > > > 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 the mm-everything > > branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm > > and is updated there every 2-3 working days > > > > ------------------------------------------------------ > > From: Adam Sindelar <adam@xxxxxxxxxxxx> > > Subject: selftests/vm: Only run 128TBswitch with 5-level paging > > Date: Mon, 27 Jun 2022 18:39:12 +0200 > > > > The test va_128TBswitch.c expects to be able to pass mmap an address hint > > and length that cross the address 1<<47. This is not possible without > > 5-level page tables, so the test fails. > > > > The test is already only run on 64-bit powerpc and x86 archs, but this > > patch adds an additional check that skips the test if PG_TABLE_LEVELS < 5. > > There is precedent for checking /proc/config.gz in selftests, e.g. in > > selftests/firmware. > > > > Running the tests produces the desired output: > > > > sudo make -C tools/testing/selftests TARGETS=vm run_tests > > --------------------------- > > running ./va_128TBswitch.sh > > --------------------------- > > ./va_128TBswitch.sh: PG_TABLE_LEVELS=4, must be >= 5 to run this test > > [SKIP] > > ------------------------------- > > > > Link: https://lkml.kernel.org/r/20220627163912.5581-1-adam@xxxxxxxxxxxx > > Signed-off-by: Adam Sindelar <adam@xxxxxxxxxxxx> > > Cc: Adam Sindelar <ats@xxxxxx> > > Cc: David Vernet <void@xxxxxxxxxxxxx> > > Cc: Aneesh Kumar K.V <aneesh.kumar@xxxxxxxxxxxxxxxxxx> > > Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > > --- > > > > tools/testing/selftests/vm/Makefile | 1 > > tools/testing/selftests/vm/run_vmtests.sh | 2 > > tools/testing/selftests/vm/va_128TBswitch.sh | 39 +++++++++++++++++ > > 3 files changed, 41 insertions(+), 1 deletion(-) > > > > --- a/tools/testing/selftests/vm/Makefile~selftests-vm-only-run-128tbswitch-with-5-level-paging > > +++ a/tools/testing/selftests/vm/Makefile > > @@ -93,6 +93,7 @@ TEST_PROGS := run_vmtests.sh > > > > TEST_FILES := test_vmalloc.sh > > TEST_FILES += test_hmm.sh > > +TEST_FILES += va_128TBswitch.sh > > > > KSFT_KHDR_INSTALL := 1 > > include ../lib.mk > > --- a/tools/testing/selftests/vm/run_vmtests.sh~selftests-vm-only-run-128tbswitch-with-5-level-paging > > +++ a/tools/testing/selftests/vm/run_vmtests.sh > > @@ -158,7 +158,7 @@ if [ $VADDR64 -ne 0 ]; then > > run_test ./virtual_address_range > > > > # virtual address 128TB switch test > > - run_test ./va_128TBswitch > > + run_test ./va_128TBswitch.sh > > fi # VADDR64 > > > > # vmalloc stability smoke test > > --- /dev/null > > +++ a/tools/testing/selftests/vm/va_128TBswitch.sh > > @@ -0,0 +1,39 @@ > > +#!/bin/bash > > +# SPDX-License-Identifier: GPL-2.0 > > +# > > +# Copyright (C) 2022 Adam Sindelar (Meta) <adam@xxxxxxxxxxxx> > > +# > > +# This is a test for mmap behavior with 5-level paging. This script wraps the > > +# real test to check that the kernel is configured to support at least 5 > > +# pagetable levels. > > + > > +# 1 means the test failed > > +exitcode=1 > > + > > +# Kselftest framework requirement - SKIP code is 4. > > +ksft_skip=4 > > + > > +die() > > +{ > > + echo "$1" > > + exit $exitcode > > +} > > + > > +check_test_requirements() > > +{ > > + local config="/proc/config.gz" > > + [[ -f "${config}" ]] || config="/boot/config-$(uname -r)" > > + [[ -f "${config}" ]] || die "Cannot find kernel config in /proc or /boot" > > + > > + # gzip -dcfq automatically handles both compressed and plaintext input. > > + # See man 1 gzip under '-f'. > > + local pg_table_levels=$(gzip -dcfq "${config}" | grep PGTABLE_LEVELS | cut -d'=' -f 2) > > + > > + if [[ "${pg_table_levels}" -lt 5 ]]; then > > + echo "$0: PG_TABLE_LEVELS=${pg_table_levels}, must be >= 5 to run this test" > > + exit $ksft_skip > > + fi > > +} > > + > > What about architectures other than x86? Will this break on other architectures which don't support > PGTABLE_LEVELS ? > > The test only runs on powerpc64 and x86_64. I didn't realize powerpc64 is using fewer pagetable levels. I am inclined to just change v4 so that it checks the PGTABLE_LEVELS config on x86_64 and accepts any powerpc64, because I don't know how to check whether a specific powerpc64 system supports addresses over 1<<47. (The test already rejects all other architectures.) Does that seem reasonable? > > +check_test_requirements > > +./va_128TBswitch > > _ > > > > Patches currently in -mm which might be from adam@xxxxxxxxxxxx are > > > > selftests-vm-only-run-128tbswitch-with-5-level-paging.patch > > >