linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests: proc: Fix proc-empty-vm build error on non x86_64
@ 2022-11-09 11:06 Punit Agrawal
  2022-11-09 16:59 ` Alexey Dobriyan
  2022-11-09 22:07 ` Punit Agrawal
  0 siblings, 2 replies; 4+ messages in thread
From: Punit Agrawal @ 2022-11-09 11:06 UTC (permalink / raw)
  To: akpm, shuah
  Cc: adobriyan, linux-kernel, linux-fsdevel, linux-kselftest, Punit Agrawal

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 to the Makefile
to 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 <punit.agrawal@bytedance.com>
---
 tools/testing/selftests/proc/Makefile | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/proc/Makefile b/tools/testing/selftests/proc/Makefile
index cd95369254c0..6b31439902af 100644
--- a/tools/testing/selftests/proc/Makefile
+++ b/tools/testing/selftests/proc/Makefile
@@ -1,14 +1,18 @@
 # 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_x86_64 += proc-empty-vm
+
 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
-- 
2.30.2


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

* Re: [PATCH] selftests: proc: Fix proc-empty-vm build error on non x86_64
  2022-11-09 11:06 [PATCH] selftests: proc: Fix proc-empty-vm build error on non x86_64 Punit Agrawal
@ 2022-11-09 16:59 ` Alexey Dobriyan
  2022-11-09 17:25   ` Punit Agrawal
  2022-11-09 22:07 ` Punit Agrawal
  1 sibling, 1 reply; 4+ messages in thread
From: Alexey Dobriyan @ 2022-11-09 16:59 UTC (permalink / raw)
  To: Punit Agrawal; +Cc: akpm, shuah, linux-kernel, linux-fsdevel, linux-kselftest

On Wed, Nov 09, 2022 at 11:06:21AM +0000, Punit Agrawal wrote:
> 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.

Ehh, can you just port it to whatever arch you're using?
What's the address space on arm/arm64?

	#ifdef __amd64__
                munmap(NULL, ((size_t)1 << 47) - 4096);
	#else
	#error "implement 'unmap everything'"
	#endif

This program is almost arch-independent.

> +TEST_GEN_PROGS_x86_64 += proc-empty-vm

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

* Re: Re: [PATCH] selftests: proc: Fix proc-empty-vm build error on non x86_64
  2022-11-09 16:59 ` Alexey Dobriyan
@ 2022-11-09 17:25   ` Punit Agrawal
  0 siblings, 0 replies; 4+ messages in thread
From: Punit Agrawal @ 2022-11-09 17:25 UTC (permalink / raw)
  To: Alexey Dobriyan
  Cc: Punit Agrawal, akpm, shuah, linux-kernel, linux-fsdevel, linux-kselftest

Alexey Dobriyan <adobriyan@gmail.com> writes:

> On Wed, Nov 09, 2022 at 11:06:21AM +0000, Punit Agrawal wrote:
>> 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.
>
> Ehh, can you just port it to whatever arch you're using?
> What's the address space on arm/arm64?

On arm64, it is 0x0000ffffffffffff ((1 << 48) - 1) when using 48bit VA,
but goes up when using 52-bit VA[0].

> 	#ifdef __amd64__
>                 munmap(NULL, ((size_t)1 << 47) - 4096);
> 	#else
> 	#error "implement 'unmap everything'"
> 	#endif
>
> This program is almost arch-independent.

I did try updating the #ifdef but then hit the asm block in
vsyscall(). Also, the test would be still fail to build on other
architectures.

While support for architectures is added, it would be good to not have
the compiler throw an error on unsuspecting kselftest users.

>> +TEST_GEN_PROGS_x86_64 += proc-empty-vm

[0] https://docs.kernel.org/arm64/memory.html

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

* Re: [PATCH] selftests: proc: Fix proc-empty-vm build error on non x86_64
  2022-11-09 11:06 [PATCH] selftests: proc: Fix proc-empty-vm build error on non x86_64 Punit Agrawal
  2022-11-09 16:59 ` Alexey Dobriyan
@ 2022-11-09 22:07 ` Punit Agrawal
  1 sibling, 0 replies; 4+ messages in thread
From: Punit Agrawal @ 2022-11-09 22:07 UTC (permalink / raw)
  To: Punit Agrawal
  Cc: akpm, shuah, adobriyan, linux-kernel, linux-fsdevel, linux-kselftest

Punit Agrawal <punit.agrawal@bytedance.com> writes:

> 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 to the Makefile
> to 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 <punit.agrawal@bytedance.com>
> ---
>  tools/testing/selftests/proc/Makefile | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/proc/Makefile b/tools/testing/selftests/proc/Makefile
> index cd95369254c0..6b31439902af 100644
> --- a/tools/testing/selftests/proc/Makefile
> +++ b/tools/testing/selftests/proc/Makefile
> @@ -1,14 +1,18 @@
>  # 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_x86_64 += proc-empty-vm
> +
>  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

I noticed that a hunk has gone missing from the patch. Please ignore
this version - I'll post an updated one shortly.

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

end of thread, other threads:[~2022-11-09 22:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09 11:06 [PATCH] selftests: proc: Fix proc-empty-vm build error on non x86_64 Punit Agrawal
2022-11-09 16:59 ` Alexey Dobriyan
2022-11-09 17:25   ` Punit Agrawal
2022-11-09 22:07 ` Punit Agrawal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).