linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Vernet <void@manifault.com>
To: Adam Sindelar <adam@wowsignal.io>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, Adam Sindelar <ats@fb.com>,
	kernel-team@fb.com
Subject: Re: [PATCH] selftests/vm: Only run 128TBswitch with 5-level paging
Date: Mon, 27 Jun 2022 07:38:37 -0700	[thread overview]
Message-ID: <20220627143837.mjln2g34xkbvkj2b@dev0025.ash9.facebook.com> (raw)
In-Reply-To: <20220627123106.3798-1-adam@wowsignal.io>

On Mon, Jun 27, 2022 at 02:31:06PM +0200, Adam Sindelar wrote:
> 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.
> 
> Signed-off-by: Adam Sindelar <adam@wowsignal.io>

Hi Adam,

Thanks for the patch. This is a great start -- left a few comments and
questions.

> ---
>  tools/testing/selftests/vm/Makefile          |  1 +
>  tools/testing/selftests/vm/run_vmtests.sh    |  2 +-
>  tools/testing/selftests/vm/va_128TBswitch.sh | 37 ++++++++++++++++++++
>  3 files changed, 39 insertions(+), 1 deletion(-)
>  create mode 100755 tools/testing/selftests/vm/va_128TBswitch.sh
> 
> diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
> index c45e535ff4b8..74390f498859 100644
> --- a/tools/testing/selftests/vm/Makefile
> +++ b/tools/testing/selftests/vm/Makefile
> @@ -91,6 +91,7 @@ endif
>  TEST_PROGS := run_vmtests.sh
>  
>  TEST_FILES := test_vmalloc.sh
> +TEST_FILEs += va_128TBswitch.sh

s/TEST_FILEs/TEST_FILES

I recommend verifying that the installation worked as expected by running:

$ make -C tools/testing/selftests TARGETS=vm install

and ensuring that the shell script is output into
tools/testing/selftests/kselftest_install/vm

>  KSFT_KHDR_INSTALL := 1
>  include ../lib.mk
> diff --git a/tools/testing/selftests/vm/run_vmtests.sh b/tools/testing/selftests/vm/run_vmtests.sh
> index a2302b5faaf2..edda7350ccca 100755
> --- a/tools/testing/selftests/vm/run_vmtests.sh
> +++ b/tools/testing/selftests/vm/run_vmtests.sh
> @@ -149,7 +149,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
> diff --git a/tools/testing/selftests/vm/va_128TBswitch.sh b/tools/testing/selftests/vm/va_128TBswitch.sh
> new file mode 100755
> index 000000000000..269cc674fe9e
> --- /dev/null
> +++ b/tools/testing/selftests/vm/va_128TBswitch.sh
> @@ -0,0 +1,37 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Copyright (C) 2022 Adam Sindelar (Meta) <adam@wowsignal.io>
> +#
> +# 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

Should we change this to ksft_fail to match ksft_skip?

> +
> +# Kselftest framework requirement - SKIP code is 4.
> +ksft_skip=4
> +
> +die()
> +{
> +    echo "$1"
> +    exit $exitcode
> +}
> +
> +check_test_requirements()
> +{
> +    config="/proc/config.gz"

Can you make this variable local?

> +    [[ -f "${config}" ]] || config="/boot/config-$(uname -r)"
> +    [[ -f "${config}" ]] || die "Cannot find kernel config in /proc or /boot"
> +
> +    pg_table_levels=$(gzip -dcfq "${config}" | grep PGTABLE_LEVELS | cut -d'=' -f 2)

Same here r.e. making it local.

Also, does this work if we end up having to pull config from /boot where
it's not gzipped? Perhaps we should create a variable called something like
'configs' which stores the output as either:

$ local configs="$(zcat /proc/config.gz)"

or

$ local configs="$(cat /boot/config-$(uname -r))"

Also, to the point above, just using zcat might be a bit simpler than
invoking gzip -dcfq.

> +    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
> +}
> +
> +check_test_requirements
> +./va_128TBswitch
> -- 
> 2.35.1
> 

Thanks,
David


  reply	other threads:[~2022-06-27 14:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-27 12:31 Adam Sindelar
2022-06-27 14:38 ` David Vernet [this message]
2022-06-27 15:51   ` Adam Sindelar
2022-06-27 15:55     ` Adam Sindelar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220627143837.mjln2g34xkbvkj2b@dev0025.ash9.facebook.com \
    --to=void@manifault.com \
    --cc=adam@wowsignal.io \
    --cc=akpm@linux-foundation.org \
    --cc=ats@fb.com \
    --cc=kernel-team@fb.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox