Message ID | ff7c288e2a88ccfb3b79be30967646fe5b869683.1576645161.git.sandipan@linux.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | selftests, powerpc, x86: Memory Protection Keys | expand |
Sandipan Das <sandipan@linux.ibm.com> writes: > Both 4K and 64K pages are supported on powerpc. Parts of > the selftest code perform alignment computations based on > the PAGE_SIZE macro which is currently hardcoded to 64K > for powerpc. This causes some test failures on kernels > configured with 4K page size. > > This problem is solved by determining the correct page > size during the build process rather than hardcoding it > in the header file. Doing it at build time is wrong, the test could be built on a 4K system and then run on a 64K system, or vice versa. You should just use getpagesize() at runtime. cheers > diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile > index 4e9c741be6af..ada3a67eaac6 100644 > --- a/tools/testing/selftests/vm/Makefile > +++ b/tools/testing/selftests/vm/Makefile > @@ -4,6 +4,10 @@ uname_M := $(shell uname -m 2>/dev/null || echo not) > ARCH ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/') > > CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) > +ifneq (,$(filter $(ARCH), ppc64 ppc64le)) > +protection_keys: EXTRA_CFLAGS += -DPAGE_SIZE=$(shell getconf PAGESIZE) > +endif > + > LDLIBS = -lrt > TEST_GEN_FILES = compaction_test > TEST_GEN_FILES += gup_benchmark > diff --git a/tools/testing/selftests/vm/pkey-powerpc.h b/tools/testing/selftests/vm/pkey-powerpc.h > index 3cd8e03fd640..07fa9f529014 100644 > --- a/tools/testing/selftests/vm/pkey-powerpc.h > +++ b/tools/testing/selftests/vm/pkey-powerpc.h > @@ -36,7 +36,6 @@ > pkey-31 and exec-only key */ > #define PKEY_BITS_PER_PKEY 2 > #define HPAGE_SIZE (1UL << 24) > -#define PAGE_SIZE (1UL << 16) > #define pkey_reg_t u64 > #define PKEY_REG_FMT "%016lx" > > -- > 2.17.1
Hi Michael, On 15/01/20 12:37 pm, Michael Ellerman wrote: > Sandipan Das <sandipan@linux.ibm.com> writes: >> Both 4K and 64K pages are supported on powerpc. Parts of >> the selftest code perform alignment computations based on >> the PAGE_SIZE macro which is currently hardcoded to 64K >> for powerpc. This causes some test failures on kernels >> configured with 4K page size. >> >> This problem is solved by determining the correct page >> size during the build process rather than hardcoding it >> in the header file. > > Doing it at build time is wrong, the test could be built on a 4K system > and then run on a 64K system, or vice versa. > > You should just use getpagesize() at runtime. > > cheers > The reason I chose to do it this way was because PAGE_SIZE also determines the alignment for the function "lots_o_noops_around_write" (which is used by some of the test cases). Since __attribute__((__aligned__(X))) requires X to be a constant, I am not sure if there a way around this. - Sandipan
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index 4e9c741be6af..ada3a67eaac6 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile @@ -4,6 +4,10 @@ uname_M := $(shell uname -m 2>/dev/null || echo not) ARCH ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/') CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) +ifneq (,$(filter $(ARCH), ppc64 ppc64le)) +protection_keys: EXTRA_CFLAGS += -DPAGE_SIZE=$(shell getconf PAGESIZE) +endif + LDLIBS = -lrt TEST_GEN_FILES = compaction_test TEST_GEN_FILES += gup_benchmark diff --git a/tools/testing/selftests/vm/pkey-powerpc.h b/tools/testing/selftests/vm/pkey-powerpc.h index 3cd8e03fd640..07fa9f529014 100644 --- a/tools/testing/selftests/vm/pkey-powerpc.h +++ b/tools/testing/selftests/vm/pkey-powerpc.h @@ -36,7 +36,6 @@ pkey-31 and exec-only key */ #define PKEY_BITS_PER_PKEY 2 #define HPAGE_SIZE (1UL << 24) -#define PAGE_SIZE (1UL << 16) #define pkey_reg_t u64 #define PKEY_REG_FMT "%016lx"
Both 4K and 64K pages are supported on powerpc. Parts of the selftest code perform alignment computations based on the PAGE_SIZE macro which is currently hardcoded to 64K for powerpc. This causes some test failures on kernels configured with 4K page size. This problem is solved by determining the correct page size during the build process rather than hardcoding it in the header file. cc: Dave Hansen <dave.hansen@intel.com> cc: Florian Weimer <fweimer@redhat.com> cc: Ram Pai <linuxram@us.ibm.com> Signed-off-by: Sandipan Das <sandipan@linux.ibm.com> --- tools/testing/selftests/vm/Makefile | 4 ++++ tools/testing/selftests/vm/pkey-powerpc.h | 1 - 2 files changed, 4 insertions(+), 1 deletion(-)