All of lore.kernel.org
 help / color / mirror / Atom feed
* + selftests-vm-only-run-128tbswitch-with-5-level-paging.patch added to mm-unstable branch
@ 2022-06-27 18:52 Andrew Morton
  2022-06-28 14:46 ` Aneesh Kumar K V
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2022-06-27 18:52 UTC (permalink / raw)
  To: mm-commits, void, ats, aneesh.kumar, adam, akpm


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@wowsignal.io>
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@wowsignal.io
Signed-off-by: Adam Sindelar <adam@wowsignal.io>
Cc: Adam Sindelar <ats@fb.com>
Cc: David Vernet <void@manifault.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 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@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
+
+# 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
+}
+
+check_test_requirements
+./va_128TBswitch
_

Patches currently in -mm which might be from adam@wowsignal.io are

selftests-vm-only-run-128tbswitch-with-5-level-paging.patch


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: + selftests-vm-only-run-128tbswitch-with-5-level-paging.patch added to mm-unstable branch
  2022-06-27 18:52 + selftests-vm-only-run-128tbswitch-with-5-level-paging.patch added to mm-unstable branch Andrew Morton
@ 2022-06-28 14:46 ` Aneesh Kumar K V
  2022-06-28 15:46   ` Adam Sindelar
  0 siblings, 1 reply; 4+ messages in thread
From: Aneesh Kumar K V @ 2022-06-28 14:46 UTC (permalink / raw)
  To: Andrew Morton, mm-commits, void, ats, aneesh.kumar, adam

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@wowsignal.io>
> 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@wowsignal.io
> Signed-off-by: Adam Sindelar <adam@wowsignal.io>
> Cc: Adam Sindelar <ats@fb.com>
> Cc: David Vernet <void@manifault.com>
> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  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@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
> +
> +# 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 ?


> +check_test_requirements
> +./va_128TBswitch
> _
> 
> Patches currently in -mm which might be from adam@wowsignal.io are
> 
> selftests-vm-only-run-128tbswitch-with-5-level-paging.patch
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: + selftests-vm-only-run-128tbswitch-with-5-level-paging.patch added to mm-unstable branch
  2022-06-28 14:46 ` Aneesh Kumar K V
@ 2022-06-28 15:46   ` Adam Sindelar
  2022-06-28 15:53     ` Aneesh Kumar K V
  0 siblings, 1 reply; 4+ messages in thread
From: Adam Sindelar @ 2022-06-28 15:46 UTC (permalink / raw)
  To: Aneesh Kumar K V; +Cc: Andrew Morton, mm-commits, void, ats, aneesh.kumar

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@wowsignal.io>
> > 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@wowsignal.io
> > Signed-off-by: Adam Sindelar <adam@wowsignal.io>
> > Cc: Adam Sindelar <ats@fb.com>
> > Cc: David Vernet <void@manifault.com>
> > Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> > Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> > ---
> > 
> >  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@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
> > +
> > +# 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@wowsignal.io are
> > 
> > selftests-vm-only-run-128tbswitch-with-5-level-paging.patch
> > 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: + selftests-vm-only-run-128tbswitch-with-5-level-paging.patch added to mm-unstable branch
  2022-06-28 15:46   ` Adam Sindelar
@ 2022-06-28 15:53     ` Aneesh Kumar K V
  0 siblings, 0 replies; 4+ messages in thread
From: Aneesh Kumar K V @ 2022-06-28 15:53 UTC (permalink / raw)
  To: Adam Sindelar; +Cc: Andrew Morton, mm-commits, void, ats, aneesh.kumar

On 6/28/22 9:16 PM, Adam Sindelar wrote:
> 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@wowsignal.io>
>>> 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@wowsignal.io
>>> Signed-off-by: Adam Sindelar <adam@wowsignal.io>
>>> Cc: Adam Sindelar <ats@fb.com>
>>> Cc: David Vernet <void@manifault.com>
>>> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>>> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
>>> ---
>>>
>>>  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@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
>>> +
>>> +# 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?

I would suggest restricting the new check to only x86

-aneesh

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-28 15:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-27 18:52 + selftests-vm-only-run-128tbswitch-with-5-level-paging.patch added to mm-unstable branch Andrew Morton
2022-06-28 14:46 ` Aneesh Kumar K V
2022-06-28 15:46   ` Adam Sindelar
2022-06-28 15:53     ` Aneesh Kumar K V

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.