selftests: proc: Fix proc-empty-vm build error on non x86_64
Subsystems (3)
PATCH v2 1/2 selftests: proc: Fix proc-empty-vm build error on non x86_64
The proc-empty-vm test is implemented for x86_64 and fails to build for other architectures. Rather then emitting a compiler error it would be preferable to only build the test on supported architectures.
Mark proc-empty-vm as a test for x86_64 and customise the Makefile to build it only when building for this target architecture.
---
v1 -> v2
* Fixed missing compilation on x86_64
Previous version
* https://lore.kernel.org/all/[email protected]/
tools/testing/selftests/proc/Makefile | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
tools/testing/selftests/proc/Makefile +8 -2
@@ -1,14 +1,16 @@ # SPDX-License-Identifier: GPL-2.0-only + +# When ARCH not overridden for crosscompiling, lookup machine +ARCH ?= $(shell uname -m 2>/dev/null || echo not) + CFLAGS += -Wall -O2 -Wno-unused-function CFLAGS += -D_GNU_SOURCE LDFLAGS += -pthread -TEST_GEN_PROGS := TEST_GEN_PROGS += fd-001-lookup TEST_GEN_PROGS += fd-002-posix-eq TEST_GEN_PROGS += fd-003-kthread TEST_GEN_PROGS += proc-loadavg-001 -TEST_GEN_PROGS += proc-empty-vm TEST_GEN_PROGS += proc-pid-vm TEST_GEN_PROGS += proc-self-map-files-001 TEST_GEN_PROGS += proc-self-map-files-002
@@ -26,4 +28,8 @@ TEST_GEN_PROGS += thread-self TEST_GEN_PROGS += proc-multiple-procfs TEST_GEN_PROGS += proc-fsconfig-hidepid +TEST_GEN_PROGS_x86_64 += proc-empty-vm + +TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(ARCH)) + include ../lib.mk
Signature · 1 line
2.35.1
PATCH v2 2/2 selftests: proc: Mark proc-pid-vm as x86_64 only
The proc-pid-vm test does not have support for architectures other than x86_64. Mark it as such in the Makefile and in the process remove the special casing in the test itself.
--- tools/testing/selftests/proc/Makefile | 2 +- tools/testing/selftests/proc/proc-pid-vm.c | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-)
tools/testing/selftests/proc/Makefile +1 -1
@@ -11,7 +11,6 @@ TEST_GEN_PROGS += fd-001-lookup TEST_GEN_PROGS += fd-002-posix-eq TEST_GEN_PROGS += fd-003-kthread TEST_GEN_PROGS += proc-loadavg-001 -TEST_GEN_PROGS += proc-pid-vm TEST_GEN_PROGS += proc-self-map-files-001 TEST_GEN_PROGS += proc-self-map-files-002 TEST_GEN_PROGS += proc-self-syscall
@@ -29,6 +28,7 @@ TEST_GEN_PROGS += proc-multiple-procfs TEST_GEN_PROGS += proc-fsconfig-hidepid TEST_GEN_PROGS_x86_64 += proc-empty-vm +TEST_GEN_PROGS_x86_64 += proc-pid-vm TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(ARCH))
tools/testing/selftests/proc/proc-pid-vm.c +0 -9
@@ -105,7 +105,6 @@ struct elf64_phdr {uint64_t p_align; }; -#ifdef __x86_64__#define PAGE_SIZE 4096#define VADDR (1UL << 32)#define MAPS_OFFSET 73
@@ -209,7 +208,6 @@ static int make_exe(const uint8_t *payload, size_t len)return fd1; } -#endif /* * 0: vsyscall VMA doesn't exist vsyscall=none
@@ -225,7 +223,6 @@ static const char str_vsyscall_1[] =static const char str_vsyscall_2[] ="ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]\n" ; -#ifdef __x86_64__static void sigaction_SIGSEGV (int _,siginfo_t *__,void *___) {_exit (g_vsyscall);
@@ -493,9 +490,3 @@ int main(void)return 0 ; } -#else -int main (void ) -{ -return 4 ; -} -#endif
Signature · 1 line
2.35.1
Shuah Khan
maintainerRe: [PATCH v2 2/2] selftests: proc: Mark proc-pid-vm as x86_64 only
Quoted 23 lines · Punit Agrawal
The proc-pid-vm test does not have support for architectures other than
x86_64. Mark it as such in theMakefileand in the process remove the special casing in the test itself.Signed-off-by Punit Agrawal <[email protected]>--- tools/testing/selftests/proc/Makefile | 2 +- tools/testing/selftests/proc/proc-pid-vm.c | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-)tools/testing/selftests/proc/Makefile +0
-1@@ -11,7 +11,6 @@ TEST_GEN_PROGS += fd-001-lookup TEST_GEN_PROGS += fd-002-posix-eq TEST_GEN_PROGS += fd-003-kthread TEST_GEN_PROGS += proc-loadavg-001 -TEST_GEN_PROGS += proc-pid-vm TEST_GEN_PROGS += proc-self-map-files-001 TEST_GEN_PROGS += proc-self-map-files-002 TEST_GEN_PROGS += proc-self-syscall
tools/testing/selftests/proc/Makefile TEST_GEN_PROGS += proc-multiple-procfs · line 31
Quoted 4 lines
tools/testing/selftests/proc/Makefile +1
-0@@ -29,6 +28,7 @@ TEST_GEN_PROGS += proc-multiple-procfs TEST_GEN_PROGS += proc-fsconfig-hidepid TEST_GEN_PROGS_x86_64 += proc-empty-vm +TEST_GEN_PROGS_x86_64 += proc-pid-vm
Same comment as before. Add proc-pid-vm conditionally to TEST_GEN_PROGS
thanks,
-- Shuah
Quoted 3 lines · On Wed, 9 Nov 2022 22:11:03 +0000 Punit Agrawal <[email protected]>…
The proc-empty-vm test is implemented for
x86_64and fails to build for other architectures. Rather then emitting a compiler error it would be preferable to only build the test on supported architectures.
Why does it fail? What would be involved in making it available on other architectures?
Shuah Khan
maintainerQuoted 9 lines · Andrew Morton
Quoted 3 lines · On Wed, 9 Nov 2022 22:11:03 +0000 Punit Agrawal <[email protected]>…
The proc-empty-vm test is implemented for
x86_64and fails to build for other architectures. Rather then emitting a compiler error it would be preferable to only build the test on supported architectures.Why does it fail? What would be involved in making it available on other architectures?
I have the same question and also don't like adding TEST_GEN_PROGS_x86_64 Please see my comments on the two patches regarding this.
thanks,
-- Shuah
Hi Andrew,
Thanks for taking a look.
Quoted 8 lines · Andrew Morton
Quoted 3 lines · On Wed, 9 Nov 2022 22:11:03 +0000 Punit Agrawal <[email protected]>…
The proc-empty-vm test is implemented for
x86_64and fails to build for other architectures. Rather then emitting a compiler error it would be preferable to only build the test on supported architectures.Why does it fail? What would be involved in making it available on other architectures?
The test is written to fail building on architectures other than x86_64.
#ifdef __amd64__
munmap(NULL, ((size_t)1 << 47) - 4096);
#else
#error "implement 'unmap everything'"
#endifI hit the build failure while semi-automating the running of tests on internal infrastructure.
I am not familiar with the issue being tested but after a bit of staring, it looks like there are two architecture dependent components to the tests -
1. TASK_SIZE / application memory layout - the test unmaps the entire the user virtual address space. For this, it needs to know the length to pass to munmap().
Although it's possible to add this per-architecture, I am not sure if there is a way to discover the length passed to munmap().
2. How the vsyscall page (if implemented) is mapped - this influences the known good values used for comparison in the test.
It doesn't look like vsyscall page is used on arm64 but I am not sure about the situation with other architectures.
(Alexey, please add if I've missed anything)
Thanks,
Punit
Shuah Khan
maintainerQuoted 43 lines · Punit Agrawal
The proc-empty-vm test is implemented for
x86_64and fails to build for other architectures. Rather then emitting a compiler error it would be preferable to only build the test on supported architectures.Mark proc-empty-vm as a test for
x86_64and customise theMakefileto build it only when building for this target architecture.Fixes 5bc73bb3451b ("proc: test how it holds up with mapping'less process")Signed-off-by Punit Agrawal <[email protected]>---
v1 -> v2
* Fixed missing compilation onx86_64Previous version
* https://lore.kernel.org/all/[email protected]/
tools/testing/selftests/proc/Makefile| 10 ++++++++--1 file changed, 8 insertions(+), 2 deletions(-)tools/testing/selftests/proc/Makefile +4
-2@@ -1,14 +1,16 @@ # SPDX-License-Identifier: GPL-2.0-only + +# When ARCH not overridden for crosscompiling, lookup machine +ARCH ?= $(shell uname -m 2>/dev/null || echo not) + CFLAGS += -Wall -O2 -Wno-unused-function CFLAGS += -D_GNU_SOURCE LDFLAGS += -pthread -TEST_GEN_PROGS := TEST_GEN_PROGS += fd-001-lookup TEST_GEN_PROGS += fd-002-posix-eq TEST_GEN_PROGS += fd-003-kthread TEST_GEN_PROGS += proc-loadavg-001 -TEST_GEN_PROGS += proc-empty-vm TEST_GEN_PROGS += proc-pid-vm TEST_GEN_PROGS += proc-self-map-files-001 TEST_GEN_PROGS += proc-self-map-files-002
tools/testing/selftests/proc/Makefile TEST_GEN_PROGS += thread-self · line 31
Quoted 4 lines
tools/testing/selftests/proc/Makefile +1
-0@@ -26,4 +28,8 @@ TEST_GEN_PROGS += thread-self TEST_GEN_PROGS += proc-multiple-procfs TEST_GEN_PROGS += proc-fsconfig-hidepid +TEST_GEN_PROGS_x86_64 += proc-empty-vm
Why do you need this? You already have conditional compiles. Conditionally add proc-empty-vm to TEST_GEN_PROGS like other tests do.
tools/testing/selftests/proc/Makefile TEST_GEN_PROGS += thread-self · line 35
Quoted 4 lines
tools/testing/selftests/proc/Makefile +3
-0+ +TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(ARCH)) + include ../lib.mk
Same question Andrews asked you. What does it take to get this to work on other architectures. proc and vm tests should be arch. agnostic as a rule unless it is absolutely necessary to have them acrh. aware.
thanks,
-- Shuah
thanks,
-- Shuah
Hi Shuah,
Quoted 40 lines · Shuah Khan
Quoted 39 lines · Punit Agrawal
The proc-empty-vm test is implemented for
x86_64and fails to build for other architectures. Rather then emitting a compiler error it would be preferable to only build the test on supported architectures. Mark proc-empty-vm as a test forx86_64and customise theMakefileto
build it only when building for this target architecture.Fixes 5bc73bb3451b ("proc: test how it holds up with mapping'lessprocess")
Signed-off-by Punit Agrawal <[email protected]>---
v1 -> v2
* Fixed missing compilation onx86_64
Previous version
* https://lore.kernel.org/all/[email protected]/tools/testing/selftests/proc/Makefile| 10 ++++++++--1 file changed, 8 insertions(+), 2 deletions(-)tools/testing/selftests/proc/Makefile +4
-1@@ -1,14 +1,16 @@ # SPDX-License-Identifier: GPL-2.0-only + +# When ARCH not overridden for crosscompiling, lookup machine +ARCH ?= $(shell uname -m 2>/dev/null || echo not) + CFLAGS += -Wall -O2 -Wno-unused-function CFLAGS += -D_GNU_SOURCE LDFLAGS += -pthread -TEST_GEN_PROGS := TEST_GEN_PROGS += fd-001-lookup TEST_GEN_PROGS += fd-002-posix-eq TEST_GEN_PROGS += fd-003-kthread TEST_GEN_PROGS += proc-loadavg-001 -TEST_GEN_PROGS += proc-empty-vm TEST_GEN_PROGS += proc-pid-vm TEST_GEN_PROGS += proc-self-map-files-001 TEST_GEN_PROGS += proc-self-map-files-002
Quoted 8 lines
tools/testing/selftests/proc/Makefile TEST_GEN_PROGS += thread-self · line 30
Quoted 4 lines
tools/testing/selftests/proc/Makefile +0
-0@@ -26,4 +28,8 @@ TEST_GEN_PROGS += thread-self TEST_GEN_PROGS += proc-multiple-procfs TEST_GEN_PROGS += proc-fsconfig-hidepid +TEST_GEN_PROGS_x86_64 += proc-empty-vmWhy do you need this? You already have conditional compiles. Conditionally add proc-empty-vm to
TEST_GEN_PROGSlike other tests do.
I copied this approach from KVM tests. Looks like we've got a few different ways of disabling compilation within selftests.
I can respin to conditionally compile as suggested if that is the way forward.
Quoted 9 lines
tools/testing/selftests/proc/Makefile TEST_GEN_PROGS += thread-self · line 35
Quoted 4 lines
tools/testing/selftests/proc/Makefile +3
-0+ +TEST_GEN_PROGS += $(TEST_GEN_PROGS_$(ARCH)) + include ../lib.mkSame question Andrews asked you. What does it take to get this to work on other architectures. proc and vm tests should be arch. agnostic as a rule unless it is absolutely necessary to have them acrh. aware.
Please see my reply elsewhere in the thread for an assessment of the architecture dependencies.