Skip to contentSkip to conversation

selftests/vm: fix inability to build any vm tests

PATCH In review Axel Rasmussen 3 participants 5 messages Aug 19, 2022 – Aug 20, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 selftests/vm: fix inability to build any vm tests

When we stopped using KSFT_KHDR_INSTALL, a side effect is we also changed the value of top_srcdir. This can be seen by looking at the code removed by commit 49de12ba06ef
("selftests: drop KSFT_KHDR_INSTALL make target").

(Note though that this commit didn't break this, technically the one before it did since that's the one that stopped KSFT_KHDR_INSTALL from being used, even though the code was still there.)

Previously lib.mk reconfigured top_srcdir when KSFT_KHDR_INSTALL was being used. Now, that's no longer the case.

As a result, the path to gup_test.h in vm/Makefile was wrong, and since it's a dependency of all of the vm binaries none of them could be built. Instead, we'd get an "error" like:

make[1]: *** No rule to make target
'/[...]/tools/testing/selftests/vm/compaction_test', needed by 'all'. Stop.

So, modify lib.mk so it once again sets top_srcdir to the root of the kernel tree.

Fixes f2745dc0ba3d ("selftests: stop using KSFT_KHDR_INSTALL")
---
 tools/testing/selftests/lib.mk | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/lib.mk +1 -0
index 947fc72413e9..d44c72b3abe3 100644
@@ -40,6 +40,7 @@ ifeq (0,$(MAKELEVEL))
     endif
 endif
 selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST))))
+top_srcdir = $(selfdir)/../../..
 
 # The following are built by lib.mk common compile rules.
 # TEST_CUSTOM_PROGS should be used by tests that require
Signature · 1 line
2.37.1.595.g718a3a8f04-goog
#1 lore raw

PATCH v2 2/2 selftests/vm: use top_srcdir instead of recomputing relative paths

In various places both in t/t/s/v/Makefile as well as some of the test sources, we were referring to headers or directories using some fairly long relative paths.

Since we have a working top_srcdir variable though, which refers to the root of the kernel tree, we can clean up all of these "up and over" relative paths, just relying on the single variable instead.

---
 tools/testing/selftests/vm/Makefile    | 2 +-
 tools/testing/selftests/vm/gup_test.c  | 2 +-
 tools/testing/selftests/vm/hmm-tests.c | 4 ++--
 tools/testing/selftests/vm/ksm_tests.c | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
tools/testing/selftests/vm/Makefile +1 -1
index d9fa6a9ea584..d516b8c38eed 100644
@@ -25,7 +25,7 @@ MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/p
 # LDLIBS.
 MAKEFLAGS += --no-builtin-rules
 
-CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
+CFLAGS = -Wall -I $(top_srcdir) -I $(top_srcdir)/usr/include $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
 LDLIBS = -lrt -lpthread
 TEST_GEN_FILES = compaction_test
 TEST_GEN_FILES += gup_test
tools/testing/selftests/vm/gup_test.c +1 -1
index a309876d832f..e43879291dac 100644
@@ -10,7 +10,7 @@
 #include <sys/types.h>
 #include <pthread.h>
 #include <assert.h>
-#include "../../../../mm/gup_test.h"
+#include <mm/gup_test.h>
 #include "../kselftest.h"
 
 #include "util.h"
tools/testing/selftests/vm/hmm-tests.c +2 -2
index 529f53b40296..98b949c279be 100644
@@ -35,8 +35,8 @@
  * This is a private UAPI to the kernel test module so it isn't exported
  * in the usual include/uapi/... directory.
  */
-#include "../../../../lib/test_hmm_uapi.h"
-#include "../../../../mm/gup_test.h"
+#include <lib/test_hmm_uapi.h>
+#include <mm/gup_test.h>
 
 struct hmm_buffer {
 	void		*ptr;
tools/testing/selftests/vm/ksm_tests.c +1 -1
index f5e4e0bbd081..0d85be2350fa 100644
@@ -11,7 +11,7 @@
 #include <err.h>
 
 #include "../kselftest.h"
-#include "../../../../include/vdso/time64.h"
+#include <include/vdso/time64.h>
 #include "util.h"
 
 #define KSM_SYSFS_PATH "/sys/kernel/mm/ksm/"
Signature · 1 line
2.37.1.595.g718a3a8f04-goog
Reviewed-by on v2 2/2
#2 lore raw

Re: [PATCH v2 2/2] selftests/vm: use top_srcdir instead of recomputing relative paths

Quoted 8 lines · Axel Rasmussen

In various places both in t/t/s/v/Makefile as well as some of the test sources, we were referring to headers or directories using some fairly long relative paths.

Since we have a working top_srcdir variable though, which refers to the root of the kernel tree, we can clean up all of these "up and over" relative paths, just relying on the single variable instead.

Quoted 7 lines
---
  tools/testing/selftests/vm/Makefile    | 2 +-
  tools/testing/selftests/vm/gup_test.c  | 2 +-
  tools/testing/selftests/vm/hmm-tests.c | 4 ++--
  tools/testing/selftests/vm/ksm_tests.c | 2 +-
  4 files changed, 5 insertions(+), 5 deletions(-)

Very nice, thank you for the extra cleanup here.

thanks,

Signature · 2 lines
John Hubbard
NVIDIA
Quoted 55 lines
tools/testing/selftests/vm/Makefile +1 -1
index d9fa6a9ea584..d516b8c38eed 100644
@@ -25,7 +25,7 @@ MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/p
  # LDLIBS.
  MAKEFLAGS += --no-builtin-rules
 
-CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
+CFLAGS = -Wall -I $(top_srcdir) -I $(top_srcdir)/usr/include $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
  LDLIBS = -lrt -lpthread
  TEST_GEN_FILES = compaction_test
  TEST_GEN_FILES += gup_test
tools/testing/selftests/vm/gup_test.c +1 -1
index a309876d832f..e43879291dac 100644
@@ -10,7 +10,7 @@
  #include <sys/types.h>
  #include <pthread.h>
  #include <assert.h>
-#include "../../../../mm/gup_test.h"
+#include <mm/gup_test.h>
  #include "../kselftest.h"
 
  #include "util.h"
tools/testing/selftests/vm/hmm-tests.c +2 -2
index 529f53b40296..98b949c279be 100644
@@ -35,8 +35,8 @@
   * This is a private UAPI to the kernel test module so it isn't exported
   * in the usual include/uapi/... directory.
   */
-#include "../../../../lib/test_hmm_uapi.h"
-#include "../../../../mm/gup_test.h"
+#include <lib/test_hmm_uapi.h>
+#include <mm/gup_test.h>
 
  struct hmm_buffer {
  	void		*ptr;
tools/testing/selftests/vm/ksm_tests.c +1 -1
index f5e4e0bbd081..0d85be2350fa 100644
@@ -11,7 +11,7 @@
  #include <err.h>
 
  #include "../kselftest.h"
-#include "../../../../include/vdso/time64.h"
+#include <include/vdso/time64.h>
  #include "util.h"
 
  #define KSM_SYSFS_PATH "/sys/kernel/mm/ksm/"
maintainer
#3 lore raw
In reply to Axel Rasmussen
Quoted 35 lines · Axel Rasmussen

When we stopped using KSFT_KHDR_INSTALL, a side effect is we also changed the value of top_srcdir. This can be seen by looking at the code removed by commit 49de12ba06ef
("selftests: drop KSFT_KHDR_INSTALL make target").

(Note though that this commit didn't break this, technically the one before it did since that's the one that stopped KSFT_KHDR_INSTALL from being used, even though the code was still there.)

Previously lib.mk reconfigured top_srcdir when KSFT_KHDR_INSTALL was being used. Now, that's no longer the case.

As a result, the path to gup_test.h in vm/Makefile was wrong, and since it's a dependency of all of the vm binaries none of them could be built. Instead, we'd get an "error" like:

make[1]: *** No rule to make target
'/[...]/tools/testing/selftests/vm/compaction_test', needed by
'all'. Stop.

So, modify lib.mk so it once again sets top_srcdir to the root of the kernel tree.

Fixes f2745dc0ba3d ("selftests: stop using KSFT_KHDR_INSTALL")
---
  tools/testing/selftests/lib.mk | 1 +
  1 file changed, 1 insertion(+)
tools/testing/selftests/lib.mk +0 -0
index 947fc72413e9..d44c72b3abe3 100644

tools/testing/selftests/lib.mk ifeq (0,$(MAKELEVEL)) · line 46

Quoted 7 lines
tools/testing/selftests/lib.mk +1 -0
@@ -40,6 +40,7 @@ ifeq (0,$(MAKELEVEL))
      endif
  endif
  selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST))))
+top_srcdir = $(selfdir)/../../..
 
  # The following are built by lib.mk common compile rules.
  # TEST_CUSTOM_PROGS should be used by tests that require

Applied to linux-kselftest fixes for the next rc.

thanks,
-- Shuah

Reviewed-by on v2 1/2
#4 lore raw
In reply to Axel Rasmussen
Quoted 34 lines · Axel Rasmussen

When we stopped using KSFT_KHDR_INSTALL, a side effect is we also changed the value of top_srcdir. This can be seen by looking at the code removed by commit 49de12ba06ef
("selftests: drop KSFT_KHDR_INSTALL make target").

(Note though that this commit didn't break this, technically the one before it did since that's the one that stopped KSFT_KHDR_INSTALL from being used, even though the code was still there.)

Previously lib.mk reconfigured top_srcdir when KSFT_KHDR_INSTALL was being used. Now, that's no longer the case.

As a result, the path to gup_test.h in vm/Makefile was wrong, and since it's a dependency of all of the vm binaries none of them could be built. Instead, we'd get an "error" like:

make[1]: *** No rule to make target
'/[...]/tools/testing/selftests/vm/compaction_test', needed by
'all'. Stop.

So, modify lib.mk so it once again sets top_srcdir to the root of the kernel tree.

Fixes f2745dc0ba3d ("selftests: stop using KSFT_KHDR_INSTALL")
---
  tools/testing/selftests/lib.mk | 1 +
  1 file changed, 1 insertion(+)
tools/testing/selftests/lib.mk +0 -0
index 947fc72413e9..d44c72b3abe3 100644

tools/testing/selftests/lib.mk ifeq (0,$(MAKELEVEL)) · line 46

Quoted 7 lines
tools/testing/selftests/lib.mk +1 -0
@@ -40,6 +40,7 @@ ifeq (0,$(MAKELEVEL))
      endif
  endif
  selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST))))
+top_srcdir = $(selfdir)/../../..
 
  # The following are built by lib.mk common compile rules.
  # TEST_CUSTOM_PROGS should be used by tests that require

thanks,

Signature · 2 lines
John Hubbard
NVIDIA