From: Michael Ellerman <mpe@ellerman.id.au>
To: Bamvor Zhang Jian <bamvor.zhangjian@linaro.org>
Cc: linux-kernel@vger.kernel.org, Mark Brown <broonie@kernel.org>,
khilman@linaro.org, tyler.baker@linaro.org,
shuahkh@osg.samsung.com, Andrea Arcangeli <aarcange@redhat.com>
Subject: Re: [PATCH 6/7] selftests: only compile userfaultfd for x86 and powperpc
Date: Tue, 08 Sep 2015 19:54:13 +1000 [thread overview]
Message-ID: <1441706053.7601.9.camel@ellerman.id.au> (raw)
In-Reply-To: <55EEA731.5090708@linaro.org>
On Tue, 2015-09-08 at 17:15 +0800, Bamvor Zhang Jian wrote:
> Hi, Michael
>
> I thought I reply to you, but ...
>
> On 08/31/2015 11:26 AM, Michael Ellerman wrote:
> > On Fri, 2015-08-14 at 21:43 +0800, Bamvor Jian Zhang wrote:
> >> Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
> >> ---
> >> tools/testing/selftests/vm/Makefile | 12 ++++++++++++
> >> 1 file changed, 12 insertions(+)
> >>
> >> diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
> >> index bb888c6..4dd6e4f 100644
> >> --- a/tools/testing/selftests/vm/Makefile
> >> +++ b/tools/testing/selftests/vm/Makefile
> >> @@ -1,5 +1,15 @@
> >> # Makefile for vm selftests
> >>
> >> +uname_M := $(shell uname -m 2>/dev/null || echo not)
> >> +ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/ppc.*/powerpc/)
> >> +
> >> +ifeq ($(ARCH),powerpc)
> >> +support_userfaultfd = yes
> >> +endif
> >> +ifeq ($(ARCH),x86)
> >> +support_userfaultfd = yes
> >> +endif
> >> +
> >> CFLAGS = -Wall
> >> BINARIES = compaction_test
> >> BINARIES += hugepage-mmap
> >> @@ -9,7 +19,9 @@ BINARIES += mlock2-tests
> >> BINARIES += on-fault-limit
> >> BINARIES += thuge-gen
> >> BINARIES += transhuge-stress
> >> +ifdef support_userfaultfd
> >> BINARIES += userfaultfd
> >> +endif
> >>
> >> all: $(BINARIES)
> >> %: %.c
> >
> >
> > This is nasty. It means when userfaultfd gets implemented for other arches
> > someone has to remember to update the logic here, which they won't.
> >
> > Instead the C program should just do nothing when __NR_userfaultfd is not defined, eg:
> >
> > #ifdef __NR_userfaultfd
> >
> > int main(int argc, char **argv)
> > {
> > ...
> > }
> >
> > #else
> >
> > int main(void)
> > {
> > printf("skip: Skipping userfaultfd test\n");
> > return 0;
> > }
> > #endif
> >
> >
> > This way when the syscall is implemented for other arches the test will just
> > start working.
> >
> > cheers
> >
> >
> When read the following code, It seems that sometimes __NR_userfaultfd is not
> defined but the syscall is exist. I am not sure why these piece is needed.
> cc'd c
>
> #ifndef __NR_userfaultfd
> #ifdef __x86_64__
> #define __NR_userfaultfd 323
> #elif defined(__i386__)
> #define __NR_userfaultfd 374
> #elif defined(__powewrpc__)
> #define __NR_userfaultfd 364
> #else
> #error "missing __NR_userfaultfd definition"
> #endif
> #endif
>
> Do you mean that we should remove the above code?
Well yes, it would need to be removed to make the logic I suggested work.
I'm not sure those #defines actually help in practice, because if the syscall
number is not defined then linux/userfaultfd.h will not exist and the whole
test will not compile anyway.
I was suggesting something like this, which has the properties of:
- not breaking the build on arches that don't have the syscall
- still printing a notice on arches that don't have the syscall, both at build
time and runtime.
- building correctly on an arch as soon as that arch implements the syscall,
with no extra changes required.
cheers
diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c
index 2bf1fc3f562b..652c9d805006 100644
--- a/tools/testing/selftests/vm/userfaultfd.c
+++ b/tools/testing/selftests/vm/userfaultfd.c
@@ -64,19 +64,10 @@
#include <sys/syscall.h>
#include <sys/ioctl.h>
#include <pthread.h>
-#include <linux/userfaultfd.h>
-#ifndef __NR_userfaultfd
-#ifdef __x86_64__
-#define __NR_userfaultfd 323
-#elif defined(__i386__)
-#define __NR_userfaultfd 374
-#elif defined(__powewrpc__)
-#define __NR_userfaultfd 364
-#else
-#error "missing __NR_userfaultfd definition"
-#endif
-#endif
+#ifdef __NR_userfaultfd
+
+#include <linux/userfaultfd.h>
static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size;
@@ -636,3 +627,15 @@ int main(int argc, char **argv)
nr_pages, nr_pages_per_cpu);
return userfaultfd_stress();
}
+
+#else /* ! __NR_userfaultfd */
+
+#warning "missing __NR_userfaultfd definition"
+
+int main(void)
+{
+ printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n");
+ return 0;
+}
+
+#endif
next prev parent reply other threads:[~2015-09-08 9:54 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-14 13:43 [PATCH 0/7] Improvement kselftest support for arm and arm64 Bamvor Jian Zhang
2015-08-14 13:43 ` [PATCH 1/7] selftests: rename jump label to static_keys Bamvor Jian Zhang
2015-08-27 22:17 ` Shuah Khan
2015-09-07 10:33 ` Michael Ellerman
2015-09-08 13:03 ` Shuah Khan
2015-08-14 13:43 ` [PATCH 2/7] selftests: add CFLAGS_EXTRA Bamvor Jian Zhang
2015-08-24 3:48 ` Michael Ellerman
2015-08-25 12:49 ` Bamvor Zhang Jian
2015-08-27 10:23 ` Michael Ellerman
2015-08-14 13:43 ` [PATCH 3/7] selftests: exec: fix for running and installing Bamvor Jian Zhang
2015-08-27 10:55 ` Michael Ellerman
2015-08-14 13:43 ` [PATCH 4/7] selftests: check before install Bamvor Jian Zhang
2015-08-27 20:10 ` Shuah Khan
2015-08-27 22:13 ` Shuah Khan
2015-08-14 13:43 ` [PATCH 5/7] selftests: disable seccomp for arm64 Bamvor Jian Zhang
2015-08-24 3:48 ` Michael Ellerman
2015-08-25 12:51 ` Bamvor Zhang Jian
2015-08-14 13:43 ` [PATCH 6/7] selftests: only compile userfaultfd for x86 and powperpc Bamvor Jian Zhang
2015-08-27 22:20 ` Shuah Khan
2015-08-31 3:26 ` Michael Ellerman
2015-09-08 9:15 ` Bamvor Zhang Jian
2015-09-08 9:54 ` Michael Ellerman [this message]
2015-09-08 12:25 ` Bamvor Zhang Jian
2015-09-08 14:34 ` Andrea Arcangeli
2015-09-09 8:43 ` Michael Ellerman
2015-09-09 17:20 ` Andrea Arcangeli
2015-08-14 13:43 ` [PATCH 7/7] selftests: breakpoints: fix installing error on the architecture except x86 Bamvor Jian Zhang
2015-08-27 14:16 ` Shuah Khan
2015-08-27 22:14 ` Shuah Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1441706053.7601.9.camel@ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=aarcange@redhat.com \
--cc=bamvor.zhangjian@linaro.org \
--cc=broonie@kernel.org \
--cc=khilman@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shuahkh@osg.samsung.com \
--cc=tyler.baker@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome