Re: [PATCH 2/2] selftests/userfaultfd: improve syscall number definition

2015-09-23 Thread Michael Ellerman
On Wed, 2015-09-23 at 14:11 +0100, Andre Przywara wrote:
> Hi Michael,
> 
> On 23/09/15 10:55, Michael Ellerman wrote:
> > On Tue, 2015-09-22 at 18:15 +0100, Andre Przywara wrote:
> >> On 22/09/15 15:06, Andrea Arcangeli wrote:
> >>> Andre, could you see if linux-next (which includes -mm) works for you
> >>> by just running "cd tools/testing/selftests/vm/ && make"? If there's
> >>> any further change required could you diff it against linux-next?
> >>
> >> This doesn't compile now for me, because it looks into
> >> /usr/include/asm/unistd.h, which I keep to the distribution copy of it.
> >> Also linux/userfaultfd.h is missing, because it's brand new.
> > ...
> >> I guess the right solution would be to hack the Makefile to set the
> >> include path to the kernel's copy of include/uapi, though I am not sure
> >> this works cleanly for different architectures and separate build
> >> directories. I will give this a try ...
> > 
> > Not that's not the right solution.
> > 
> > The right solution is to export the kernel headers, the Makefile will pick 
> > them
> > up (at least in linux-next):
> 
> Actually that was I was hoping for, I just missed the possibility of
> headers_install to put the files back into the kernel tree (I usually
> use it with INSTALL_HDR_PATH for packaging).

OK great.

It does seem that folks are struggling to work out how to do this, so maybe we
can come up with a way to have it automated.

> >   $ cd linux
> >   $ make headers_install
> >   $ ls usr/include/
> >   asm/  asm-generic/  drm/  linux/  misc/  mtd/  rdma/  scsi/  sound/  
> > uapi/  video/  xen/
> >   $ make -C tools/testing/selftests TARGETS=vm
> >   ...
> >   $ ls tools/testing/selftests/vm/userfaultfd
> >   tools/testing/selftests/vm/userfaultfd*
> 
> Yes, that works. Now I have just to figure out how to arrange this with
> out-of-tree build directories.

Right, I think it doesn't work at the moment.

The makefiles that look for the kernel headers use ../../../../usr/include,
which probably isn't what you want for an out of tree build.

Maybe we should do something like the below.

It allows you to do:

  $ make O=~/work/build/ headers_install
  $ ls ~/work/build/usr/include/
  asm/  asm-generic/  drm/  linux/  misc/  mtd/  rdma/  scsi/  sound/  uapi/  
video/  xen/
  $ ls usr/include
  ls: cannot access usr/include: No such file or directory
  $ make -C tools/testing/selftests KERNEL_HEADERS=~/work/build/usr/include/ 
TARGEST=vm
  $ ls tools/testing/selftests/vm/userfaultfd
  tools/testing/selftests/vm/userfaultfd*

cheers


diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 8922c2155a47..617a76be3889 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -41,6 +41,9 @@ override LDFLAGS =
 override MAKEFLAGS =
 endif
 
+KERNEL_HEADERS ?= $(abspath ../../../usr/include)
+export KERNEL_HEADERS
+
 all:
for TARGET in $(TARGETS); do \
make -C $$TARGET; \
diff --git a/tools/testing/selftests/vm/Makefile 
b/tools/testing/selftests/vm/Makefile
index e4bb1de1d526..4f45b9c8dd75 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -1,6 +1,6 @@
 # Makefile for vm selftests
 
-CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
+CFLAGS = -Wall -I $(KERNEL_HEADERS) $(EXTRA_CFLAGS)
 BINARIES = compaction_test
 BINARIES += hugepage-mmap
 BINARIES += hugepage-shm
@@ -14,12 +14,9 @@ BINARIES += userfaultfd
 all: $(BINARIES)
 %: %.c
$(CC) $(CFLAGS) -o $@ $^ -lrt
-userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h
+userfaultfd: userfaultfd.c $(KERNEL_HEADERS)/linux/kernel.h
$(CC) $(CFLAGS) -O2 -o $@ $< -lpthread
 
-../../../../usr/include/linux/kernel.h:
-   make -C ../../../.. headers_install
-
 TEST_PROGS := run_vmtests
 TEST_FILES := $(BINARIES)
 




--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] selftests/userfaultfd: improve syscall number definition

2015-09-23 Thread Andre Przywara
Hi Michael,

On 23/09/15 10:55, Michael Ellerman wrote:
> On Tue, 2015-09-22 at 18:15 +0100, Andre Przywara wrote:
>> On 22/09/15 15:06, Andrea Arcangeli wrote:
>>> Andre, could you see if linux-next (which includes -mm) works for you
>>> by just running "cd tools/testing/selftests/vm/ && make"? If there's
>>> any further change required could you diff it against linux-next?
>>
>> This doesn't compile now for me, because it looks into
>> /usr/include/asm/unistd.h, which I keep to the distribution copy of it.
>> Also linux/userfaultfd.h is missing, because it's brand new.
> ...
>> I guess the right solution would be to hack the Makefile to set the
>> include path to the kernel's copy of include/uapi, though I am not sure
>> this works cleanly for different architectures and separate build
>> directories. I will give this a try ...
> 
> Not that's not the right solution.
> 
> The right solution is to export the kernel headers, the Makefile will pick 
> them
> up (at least in linux-next):

Actually that was I was hoping for, I just missed the possibility of
headers_install to put the files back into the kernel tree (I usually
use it with INSTALL_HDR_PATH for packaging).

> 
>   $ cd linux
>   $ make headers_install
>   $ ls usr/include/
>   asm/  asm-generic/  drm/  linux/  misc/  mtd/  rdma/  scsi/  sound/  uapi/  
> video/  xen/
>   $ make -C tools/testing/selftests TARGETS=vm
>   ...
>   $ ls tools/testing/selftests/vm/userfaultfd
>   tools/testing/selftests/vm/userfaultfd*

Yes, that works. Now I have just to figure out how to arrange this with
out-of-tree build directories.

Cheers,
Andre.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] selftests/userfaultfd: improve syscall number definition

2015-09-23 Thread Michael Ellerman
On Tue, 2015-09-22 at 18:15 +0100, Andre Przywara wrote:
> On 22/09/15 15:06, Andrea Arcangeli wrote:
> > Andre, could you see if linux-next (which includes -mm) works for you
> > by just running "cd tools/testing/selftests/vm/ && make"? If there's
> > any further change required could you diff it against linux-next?
> 
> This doesn't compile now for me, because it looks into
> /usr/include/asm/unistd.h, which I keep to the distribution copy of it.
> Also linux/userfaultfd.h is missing, because it's brand new.
...
> I guess the right solution would be to hack the Makefile to set the
> include path to the kernel's copy of include/uapi, though I am not sure
> this works cleanly for different architectures and separate build
> directories. I will give this a try ...

Not that's not the right solution.

The right solution is to export the kernel headers, the Makefile will pick them
up (at least in linux-next):

  $ cd linux
  $ make headers_install
  $ ls usr/include/
  asm/  asm-generic/  drm/  linux/  misc/  mtd/  rdma/  scsi/  sound/  uapi/  
video/  xen/
  $ make -C tools/testing/selftests TARGETS=vm
  ...
  $ ls tools/testing/selftests/vm/userfaultfd
  tools/testing/selftests/vm/userfaultfd*

cheers


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] selftests/userfaultfd: improve syscall number definition

2015-09-23 Thread Andre Przywara
Hi Michael,

On 23/09/15 10:55, Michael Ellerman wrote:
> On Tue, 2015-09-22 at 18:15 +0100, Andre Przywara wrote:
>> On 22/09/15 15:06, Andrea Arcangeli wrote:
>>> Andre, could you see if linux-next (which includes -mm) works for you
>>> by just running "cd tools/testing/selftests/vm/ && make"? If there's
>>> any further change required could you diff it against linux-next?
>>
>> This doesn't compile now for me, because it looks into
>> /usr/include/asm/unistd.h, which I keep to the distribution copy of it.
>> Also linux/userfaultfd.h is missing, because it's brand new.
> ...
>> I guess the right solution would be to hack the Makefile to set the
>> include path to the kernel's copy of include/uapi, though I am not sure
>> this works cleanly for different architectures and separate build
>> directories. I will give this a try ...
> 
> Not that's not the right solution.
> 
> The right solution is to export the kernel headers, the Makefile will pick 
> them
> up (at least in linux-next):

Actually that was I was hoping for, I just missed the possibility of
headers_install to put the files back into the kernel tree (I usually
use it with INSTALL_HDR_PATH for packaging).

> 
>   $ cd linux
>   $ make headers_install
>   $ ls usr/include/
>   asm/  asm-generic/  drm/  linux/  misc/  mtd/  rdma/  scsi/  sound/  uapi/  
> video/  xen/
>   $ make -C tools/testing/selftests TARGETS=vm
>   ...
>   $ ls tools/testing/selftests/vm/userfaultfd
>   tools/testing/selftests/vm/userfaultfd*

Yes, that works. Now I have just to figure out how to arrange this with
out-of-tree build directories.

Cheers,
Andre.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] selftests/userfaultfd: improve syscall number definition

2015-09-23 Thread Michael Ellerman
On Tue, 2015-09-22 at 18:15 +0100, Andre Przywara wrote:
> On 22/09/15 15:06, Andrea Arcangeli wrote:
> > Andre, could you see if linux-next (which includes -mm) works for you
> > by just running "cd tools/testing/selftests/vm/ && make"? If there's
> > any further change required could you diff it against linux-next?
> 
> This doesn't compile now for me, because it looks into
> /usr/include/asm/unistd.h, which I keep to the distribution copy of it.
> Also linux/userfaultfd.h is missing, because it's brand new.
...
> I guess the right solution would be to hack the Makefile to set the
> include path to the kernel's copy of include/uapi, though I am not sure
> this works cleanly for different architectures and separate build
> directories. I will give this a try ...

Not that's not the right solution.

The right solution is to export the kernel headers, the Makefile will pick them
up (at least in linux-next):

  $ cd linux
  $ make headers_install
  $ ls usr/include/
  asm/  asm-generic/  drm/  linux/  misc/  mtd/  rdma/  scsi/  sound/  uapi/  
video/  xen/
  $ make -C tools/testing/selftests TARGETS=vm
  ...
  $ ls tools/testing/selftests/vm/userfaultfd
  tools/testing/selftests/vm/userfaultfd*

cheers


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] selftests/userfaultfd: improve syscall number definition

2015-09-23 Thread Michael Ellerman
On Wed, 2015-09-23 at 14:11 +0100, Andre Przywara wrote:
> Hi Michael,
> 
> On 23/09/15 10:55, Michael Ellerman wrote:
> > On Tue, 2015-09-22 at 18:15 +0100, Andre Przywara wrote:
> >> On 22/09/15 15:06, Andrea Arcangeli wrote:
> >>> Andre, could you see if linux-next (which includes -mm) works for you
> >>> by just running "cd tools/testing/selftests/vm/ && make"? If there's
> >>> any further change required could you diff it against linux-next?
> >>
> >> This doesn't compile now for me, because it looks into
> >> /usr/include/asm/unistd.h, which I keep to the distribution copy of it.
> >> Also linux/userfaultfd.h is missing, because it's brand new.
> > ...
> >> I guess the right solution would be to hack the Makefile to set the
> >> include path to the kernel's copy of include/uapi, though I am not sure
> >> this works cleanly for different architectures and separate build
> >> directories. I will give this a try ...
> > 
> > Not that's not the right solution.
> > 
> > The right solution is to export the kernel headers, the Makefile will pick 
> > them
> > up (at least in linux-next):
> 
> Actually that was I was hoping for, I just missed the possibility of
> headers_install to put the files back into the kernel tree (I usually
> use it with INSTALL_HDR_PATH for packaging).

OK great.

It does seem that folks are struggling to work out how to do this, so maybe we
can come up with a way to have it automated.

> >   $ cd linux
> >   $ make headers_install
> >   $ ls usr/include/
> >   asm/  asm-generic/  drm/  linux/  misc/  mtd/  rdma/  scsi/  sound/  
> > uapi/  video/  xen/
> >   $ make -C tools/testing/selftests TARGETS=vm
> >   ...
> >   $ ls tools/testing/selftests/vm/userfaultfd
> >   tools/testing/selftests/vm/userfaultfd*
> 
> Yes, that works. Now I have just to figure out how to arrange this with
> out-of-tree build directories.

Right, I think it doesn't work at the moment.

The makefiles that look for the kernel headers use ../../../../usr/include,
which probably isn't what you want for an out of tree build.

Maybe we should do something like the below.

It allows you to do:

  $ make O=~/work/build/ headers_install
  $ ls ~/work/build/usr/include/
  asm/  asm-generic/  drm/  linux/  misc/  mtd/  rdma/  scsi/  sound/  uapi/  
video/  xen/
  $ ls usr/include
  ls: cannot access usr/include: No such file or directory
  $ make -C tools/testing/selftests KERNEL_HEADERS=~/work/build/usr/include/ 
TARGEST=vm
  $ ls tools/testing/selftests/vm/userfaultfd
  tools/testing/selftests/vm/userfaultfd*

cheers


diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 8922c2155a47..617a76be3889 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -41,6 +41,9 @@ override LDFLAGS =
 override MAKEFLAGS =
 endif
 
+KERNEL_HEADERS ?= $(abspath ../../../usr/include)
+export KERNEL_HEADERS
+
 all:
for TARGET in $(TARGETS); do \
make -C $$TARGET; \
diff --git a/tools/testing/selftests/vm/Makefile 
b/tools/testing/selftests/vm/Makefile
index e4bb1de1d526..4f45b9c8dd75 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -1,6 +1,6 @@
 # Makefile for vm selftests
 
-CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
+CFLAGS = -Wall -I $(KERNEL_HEADERS) $(EXTRA_CFLAGS)
 BINARIES = compaction_test
 BINARIES += hugepage-mmap
 BINARIES += hugepage-shm
@@ -14,12 +14,9 @@ BINARIES += userfaultfd
 all: $(BINARIES)
 %: %.c
$(CC) $(CFLAGS) -o $@ $^ -lrt
-userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h
+userfaultfd: userfaultfd.c $(KERNEL_HEADERS)/linux/kernel.h
$(CC) $(CFLAGS) -O2 -o $@ $< -lpthread
 
-../../../../usr/include/linux/kernel.h:
-   make -C ../../../.. headers_install
-
 TEST_PROGS := run_vmtests
 TEST_FILES := $(BINARIES)
 




--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] selftests/userfaultfd: improve syscall number definition

2015-09-22 Thread Andre Przywara
Hi Shuah, Andrea,

On 22/09/15 15:06, Andrea Arcangeli wrote:
> On Tue, Sep 22, 2015 at 07:49:13AM -0600, Shuah Khan wrote:
>> On 09/22/2015 04:45 AM, Andre Przywara wrote:
>>> At the moment the userfaultfd test program only supports x86 and an
>>> architecture called "powewrpc" ;-)
>>> Fix that typo and add the syscall numbers for other architectures as
>>> well.
>>> Also as in an ideal world a syscall number should come from the system
>>> header file , include that header and guard the explicit
>>> syscall number section below to avoid redefinitions.
>>>
>>> Signed-off-by: Andre Przywara 
>>> ---
>>>  tools/testing/selftests/vm/userfaultfd.c | 13 -
>>>  1 file changed, 12 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/tools/testing/selftests/vm/userfaultfd.c 
>>> b/tools/testing/selftests/vm/userfaultfd.c
>>> index 2c7cca6..63be27f 100644
>>> --- a/tools/testing/selftests/vm/userfaultfd.c
>>> +++ b/tools/testing/selftests/vm/userfaultfd.c
>>> @@ -65,16 +65,27 @@
>>>  #include 
>>>  #include 
>>>  #include "../../../../include/uapi/linux/userfaultfd.h"
>>> +#include 
>>>  
>>> +/* ideally the above user header provides that number, but ... */
>>> +#ifndef __NR_userfaultfd
>>>  #ifdef __x86_64__
>>>  #define __NR_userfaultfd 323
>>>  #elif defined(__i386__)
>>>  #define __NR_userfaultfd 374
>>> -#elif defined(__powewrpc__)
>>> +#elif defined(__powerpc__)
>>>  #define __NR_userfaultfd 364
>>> +#elif defined(__ia64__)
>>> +#define __NR_userfaultfd 1343
>>> +#elif defined(__arm__)
>>> +#define __NR_userfaultfd 388
>>> +#elif defined(__aarch64__)
>>> +/* this is from the generic syscall table, used also on other 
>>> architectures */
>>> +#define __NR_userfaultfd 283
>>>  #else
>>>  #error "missing __NR_userfaultfd definition"
>>>  #endif
>>> +#endif /* !__NR_userfaultfd */
>>>  
>>>  static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size;
>>>  
>>>
>>
>> This is not okay. User-space shouldn't be (re)defining/duplicating
>> syscall numbers. I can't take this patch.

While I agree that this isn't the right approach from a userland point
of view, I wonder how this is supposed to work for the next few months?
Is everybody required to overwrite their distribution-provided kernel
headers just for compiling this test program?

> -mm has already been updated to do exactly that. Syscall numbers end
> up hardcoded into userland binaries/libs somewhere, so it's not a
> bugfix but certainly it's a nice cleanup to remove the whole #ifdef block.
> 
> Andre, could you see if linux-next (which includes -mm) works for you
> by just running "cd tools/testing/selftests/vm/ && make"? If there's
> any further change required could you diff it against linux-next?

This doesn't compile now for me, because it looks into
/usr/include/asm/unistd.h, which I keep to the distribution copy of it.
Also linux/userfaultfd.h is missing, because it's brand new.

If that tool lives in the kernel repo, it should be able to either use
the uapi headers directly or hardcode the syscall numbers - strictly
it's not a sane userland program anymore, but for that kind of tools I
deem it's totally acceptable. I think this is one rationale for keeping
it inside the linux.git repo.

Obviously you were facing the same problem in the beginning (looking at
the original code), so I was just extending the original solution to
cover more architectures and prepare for the time when those symbols
start to appear in distributions.

I guess the right solution would be to hack the Makefile to set the
include path to the kernel's copy of include/uapi, though I am not sure
this works cleanly for different architectures and separate build
directories. I will give this a try ...

Cheers,
Andre.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] selftests/userfaultfd: improve syscall number definition

2015-09-22 Thread Andrea Arcangeli
On Tue, Sep 22, 2015 at 07:49:13AM -0600, Shuah Khan wrote:
> On 09/22/2015 04:45 AM, Andre Przywara wrote:
> > At the moment the userfaultfd test program only supports x86 and an
> > architecture called "powewrpc" ;-)
> > Fix that typo and add the syscall numbers for other architectures as
> > well.
> > Also as in an ideal world a syscall number should come from the system
> > header file , include that header and guard the explicit
> > syscall number section below to avoid redefinitions.
> > 
> > Signed-off-by: Andre Przywara 
> > ---
> >  tools/testing/selftests/vm/userfaultfd.c | 13 -
> >  1 file changed, 12 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/testing/selftests/vm/userfaultfd.c 
> > b/tools/testing/selftests/vm/userfaultfd.c
> > index 2c7cca6..63be27f 100644
> > --- a/tools/testing/selftests/vm/userfaultfd.c
> > +++ b/tools/testing/selftests/vm/userfaultfd.c
> > @@ -65,16 +65,27 @@
> >  #include 
> >  #include 
> >  #include "../../../../include/uapi/linux/userfaultfd.h"
> > +#include 
> >  
> > +/* ideally the above user header provides that number, but ... */
> > +#ifndef __NR_userfaultfd
> >  #ifdef __x86_64__
> >  #define __NR_userfaultfd 323
> >  #elif defined(__i386__)
> >  #define __NR_userfaultfd 374
> > -#elif defined(__powewrpc__)
> > +#elif defined(__powerpc__)
> >  #define __NR_userfaultfd 364
> > +#elif defined(__ia64__)
> > +#define __NR_userfaultfd 1343
> > +#elif defined(__arm__)
> > +#define __NR_userfaultfd 388
> > +#elif defined(__aarch64__)
> > +/* this is from the generic syscall table, used also on other 
> > architectures */
> > +#define __NR_userfaultfd 283
> >  #else
> >  #error "missing __NR_userfaultfd definition"
> >  #endif
> > +#endif /* !__NR_userfaultfd */
> >  
> >  static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size;
> >  
> > 
> 
> This is not okay. User-space shouldn't be (re)defining/duplicating
> syscall numbers. I can't take this patch.

-mm has already been updated to do exactly that. Syscall numbers end
up hardcoded into userland binaries/libs somewhere, so it's not a
bugfix but certainly it's a nice cleanup to remove the whole #ifdef block.

Andre, could you see if linux-next (which includes -mm) works for you
by just running "cd tools/testing/selftests/vm/ && make"? If there's
any further change required could you diff it against linux-next?

Thanks!
Andrea
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] selftests/userfaultfd: improve syscall number definition

2015-09-22 Thread Shuah Khan
On 09/22/2015 04:45 AM, Andre Przywara wrote:
> At the moment the userfaultfd test program only supports x86 and an
> architecture called "powewrpc" ;-)
> Fix that typo and add the syscall numbers for other architectures as
> well.
> Also as in an ideal world a syscall number should come from the system
> header file , include that header and guard the explicit
> syscall number section below to avoid redefinitions.
> 
> Signed-off-by: Andre Przywara 
> ---
>  tools/testing/selftests/vm/userfaultfd.c | 13 -
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/vm/userfaultfd.c 
> b/tools/testing/selftests/vm/userfaultfd.c
> index 2c7cca6..63be27f 100644
> --- a/tools/testing/selftests/vm/userfaultfd.c
> +++ b/tools/testing/selftests/vm/userfaultfd.c
> @@ -65,16 +65,27 @@
>  #include 
>  #include 
>  #include "../../../../include/uapi/linux/userfaultfd.h"
> +#include 
>  
> +/* ideally the above user header provides that number, but ... */
> +#ifndef __NR_userfaultfd
>  #ifdef __x86_64__
>  #define __NR_userfaultfd 323
>  #elif defined(__i386__)
>  #define __NR_userfaultfd 374
> -#elif defined(__powewrpc__)
> +#elif defined(__powerpc__)
>  #define __NR_userfaultfd 364
> +#elif defined(__ia64__)
> +#define __NR_userfaultfd 1343
> +#elif defined(__arm__)
> +#define __NR_userfaultfd 388
> +#elif defined(__aarch64__)
> +/* this is from the generic syscall table, used also on other architectures 
> */
> +#define __NR_userfaultfd 283
>  #else
>  #error "missing __NR_userfaultfd definition"
>  #endif
> +#endif /* !__NR_userfaultfd */
>  
>  static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size;
>  
> 

This is not okay. User-space shouldn't be (re)defining/duplicating
syscall numbers. I can't take this patch.

thanks,
-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shua...@osg.samsung.com | (970) 217-8978
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] selftests/userfaultfd: improve syscall number definition

2015-09-22 Thread Andre Przywara
At the moment the userfaultfd test program only supports x86 and an
architecture called "powewrpc" ;-)
Fix that typo and add the syscall numbers for other architectures as
well.
Also as in an ideal world a syscall number should come from the system
header file , include that header and guard the explicit
syscall number section below to avoid redefinitions.

Signed-off-by: Andre Przywara 
---
 tools/testing/selftests/vm/userfaultfd.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/vm/userfaultfd.c 
b/tools/testing/selftests/vm/userfaultfd.c
index 2c7cca6..63be27f 100644
--- a/tools/testing/selftests/vm/userfaultfd.c
+++ b/tools/testing/selftests/vm/userfaultfd.c
@@ -65,16 +65,27 @@
 #include 
 #include 
 #include "../../../../include/uapi/linux/userfaultfd.h"
+#include 
 
+/* ideally the above user header provides that number, but ... */
+#ifndef __NR_userfaultfd
 #ifdef __x86_64__
 #define __NR_userfaultfd 323
 #elif defined(__i386__)
 #define __NR_userfaultfd 374
-#elif defined(__powewrpc__)
+#elif defined(__powerpc__)
 #define __NR_userfaultfd 364
+#elif defined(__ia64__)
+#define __NR_userfaultfd 1343
+#elif defined(__arm__)
+#define __NR_userfaultfd 388
+#elif defined(__aarch64__)
+/* this is from the generic syscall table, used also on other architectures */
+#define __NR_userfaultfd 283
 #else
 #error "missing __NR_userfaultfd definition"
 #endif
+#endif /* !__NR_userfaultfd */
 
 static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size;
 
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] selftests/userfaultfd: improve syscall number definition

2015-09-22 Thread Andre Przywara
Hi Shuah, Andrea,

On 22/09/15 15:06, Andrea Arcangeli wrote:
> On Tue, Sep 22, 2015 at 07:49:13AM -0600, Shuah Khan wrote:
>> On 09/22/2015 04:45 AM, Andre Przywara wrote:
>>> At the moment the userfaultfd test program only supports x86 and an
>>> architecture called "powewrpc" ;-)
>>> Fix that typo and add the syscall numbers for other architectures as
>>> well.
>>> Also as in an ideal world a syscall number should come from the system
>>> header file , include that header and guard the explicit
>>> syscall number section below to avoid redefinitions.
>>>
>>> Signed-off-by: Andre Przywara 
>>> ---
>>>  tools/testing/selftests/vm/userfaultfd.c | 13 -
>>>  1 file changed, 12 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/tools/testing/selftests/vm/userfaultfd.c 
>>> b/tools/testing/selftests/vm/userfaultfd.c
>>> index 2c7cca6..63be27f 100644
>>> --- a/tools/testing/selftests/vm/userfaultfd.c
>>> +++ b/tools/testing/selftests/vm/userfaultfd.c
>>> @@ -65,16 +65,27 @@
>>>  #include 
>>>  #include 
>>>  #include "../../../../include/uapi/linux/userfaultfd.h"
>>> +#include 
>>>  
>>> +/* ideally the above user header provides that number, but ... */
>>> +#ifndef __NR_userfaultfd
>>>  #ifdef __x86_64__
>>>  #define __NR_userfaultfd 323
>>>  #elif defined(__i386__)
>>>  #define __NR_userfaultfd 374
>>> -#elif defined(__powewrpc__)
>>> +#elif defined(__powerpc__)
>>>  #define __NR_userfaultfd 364
>>> +#elif defined(__ia64__)
>>> +#define __NR_userfaultfd 1343
>>> +#elif defined(__arm__)
>>> +#define __NR_userfaultfd 388
>>> +#elif defined(__aarch64__)
>>> +/* this is from the generic syscall table, used also on other 
>>> architectures */
>>> +#define __NR_userfaultfd 283
>>>  #else
>>>  #error "missing __NR_userfaultfd definition"
>>>  #endif
>>> +#endif /* !__NR_userfaultfd */
>>>  
>>>  static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size;
>>>  
>>>
>>
>> This is not okay. User-space shouldn't be (re)defining/duplicating
>> syscall numbers. I can't take this patch.

While I agree that this isn't the right approach from a userland point
of view, I wonder how this is supposed to work for the next few months?
Is everybody required to overwrite their distribution-provided kernel
headers just for compiling this test program?

> -mm has already been updated to do exactly that. Syscall numbers end
> up hardcoded into userland binaries/libs somewhere, so it's not a
> bugfix but certainly it's a nice cleanup to remove the whole #ifdef block.
> 
> Andre, could you see if linux-next (which includes -mm) works for you
> by just running "cd tools/testing/selftests/vm/ && make"? If there's
> any further change required could you diff it against linux-next?

This doesn't compile now for me, because it looks into
/usr/include/asm/unistd.h, which I keep to the distribution copy of it.
Also linux/userfaultfd.h is missing, because it's brand new.

If that tool lives in the kernel repo, it should be able to either use
the uapi headers directly or hardcode the syscall numbers - strictly
it's not a sane userland program anymore, but for that kind of tools I
deem it's totally acceptable. I think this is one rationale for keeping
it inside the linux.git repo.

Obviously you were facing the same problem in the beginning (looking at
the original code), so I was just extending the original solution to
cover more architectures and prepare for the time when those symbols
start to appear in distributions.

I guess the right solution would be to hack the Makefile to set the
include path to the kernel's copy of include/uapi, though I am not sure
this works cleanly for different architectures and separate build
directories. I will give this a try ...

Cheers,
Andre.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] selftests/userfaultfd: improve syscall number definition

2015-09-22 Thread Shuah Khan
On 09/22/2015 04:45 AM, Andre Przywara wrote:
> At the moment the userfaultfd test program only supports x86 and an
> architecture called "powewrpc" ;-)
> Fix that typo and add the syscall numbers for other architectures as
> well.
> Also as in an ideal world a syscall number should come from the system
> header file , include that header and guard the explicit
> syscall number section below to avoid redefinitions.
> 
> Signed-off-by: Andre Przywara 
> ---
>  tools/testing/selftests/vm/userfaultfd.c | 13 -
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/vm/userfaultfd.c 
> b/tools/testing/selftests/vm/userfaultfd.c
> index 2c7cca6..63be27f 100644
> --- a/tools/testing/selftests/vm/userfaultfd.c
> +++ b/tools/testing/selftests/vm/userfaultfd.c
> @@ -65,16 +65,27 @@
>  #include 
>  #include 
>  #include "../../../../include/uapi/linux/userfaultfd.h"
> +#include 
>  
> +/* ideally the above user header provides that number, but ... */
> +#ifndef __NR_userfaultfd
>  #ifdef __x86_64__
>  #define __NR_userfaultfd 323
>  #elif defined(__i386__)
>  #define __NR_userfaultfd 374
> -#elif defined(__powewrpc__)
> +#elif defined(__powerpc__)
>  #define __NR_userfaultfd 364
> +#elif defined(__ia64__)
> +#define __NR_userfaultfd 1343
> +#elif defined(__arm__)
> +#define __NR_userfaultfd 388
> +#elif defined(__aarch64__)
> +/* this is from the generic syscall table, used also on other architectures 
> */
> +#define __NR_userfaultfd 283
>  #else
>  #error "missing __NR_userfaultfd definition"
>  #endif
> +#endif /* !__NR_userfaultfd */
>  
>  static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size;
>  
> 

This is not okay. User-space shouldn't be (re)defining/duplicating
syscall numbers. I can't take this patch.

thanks,
-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shua...@osg.samsung.com | (970) 217-8978
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] selftests/userfaultfd: improve syscall number definition

2015-09-22 Thread Andre Przywara
At the moment the userfaultfd test program only supports x86 and an
architecture called "powewrpc" ;-)
Fix that typo and add the syscall numbers for other architectures as
well.
Also as in an ideal world a syscall number should come from the system
header file , include that header and guard the explicit
syscall number section below to avoid redefinitions.

Signed-off-by: Andre Przywara 
---
 tools/testing/selftests/vm/userfaultfd.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/vm/userfaultfd.c 
b/tools/testing/selftests/vm/userfaultfd.c
index 2c7cca6..63be27f 100644
--- a/tools/testing/selftests/vm/userfaultfd.c
+++ b/tools/testing/selftests/vm/userfaultfd.c
@@ -65,16 +65,27 @@
 #include 
 #include 
 #include "../../../../include/uapi/linux/userfaultfd.h"
+#include 
 
+/* ideally the above user header provides that number, but ... */
+#ifndef __NR_userfaultfd
 #ifdef __x86_64__
 #define __NR_userfaultfd 323
 #elif defined(__i386__)
 #define __NR_userfaultfd 374
-#elif defined(__powewrpc__)
+#elif defined(__powerpc__)
 #define __NR_userfaultfd 364
+#elif defined(__ia64__)
+#define __NR_userfaultfd 1343
+#elif defined(__arm__)
+#define __NR_userfaultfd 388
+#elif defined(__aarch64__)
+/* this is from the generic syscall table, used also on other architectures */
+#define __NR_userfaultfd 283
 #else
 #error "missing __NR_userfaultfd definition"
 #endif
+#endif /* !__NR_userfaultfd */
 
 static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size;
 
-- 
2.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] selftests/userfaultfd: improve syscall number definition

2015-09-22 Thread Andrea Arcangeli
On Tue, Sep 22, 2015 at 07:49:13AM -0600, Shuah Khan wrote:
> On 09/22/2015 04:45 AM, Andre Przywara wrote:
> > At the moment the userfaultfd test program only supports x86 and an
> > architecture called "powewrpc" ;-)
> > Fix that typo and add the syscall numbers for other architectures as
> > well.
> > Also as in an ideal world a syscall number should come from the system
> > header file , include that header and guard the explicit
> > syscall number section below to avoid redefinitions.
> > 
> > Signed-off-by: Andre Przywara 
> > ---
> >  tools/testing/selftests/vm/userfaultfd.c | 13 -
> >  1 file changed, 12 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/testing/selftests/vm/userfaultfd.c 
> > b/tools/testing/selftests/vm/userfaultfd.c
> > index 2c7cca6..63be27f 100644
> > --- a/tools/testing/selftests/vm/userfaultfd.c
> > +++ b/tools/testing/selftests/vm/userfaultfd.c
> > @@ -65,16 +65,27 @@
> >  #include 
> >  #include 
> >  #include "../../../../include/uapi/linux/userfaultfd.h"
> > +#include 
> >  
> > +/* ideally the above user header provides that number, but ... */
> > +#ifndef __NR_userfaultfd
> >  #ifdef __x86_64__
> >  #define __NR_userfaultfd 323
> >  #elif defined(__i386__)
> >  #define __NR_userfaultfd 374
> > -#elif defined(__powewrpc__)
> > +#elif defined(__powerpc__)
> >  #define __NR_userfaultfd 364
> > +#elif defined(__ia64__)
> > +#define __NR_userfaultfd 1343
> > +#elif defined(__arm__)
> > +#define __NR_userfaultfd 388
> > +#elif defined(__aarch64__)
> > +/* this is from the generic syscall table, used also on other 
> > architectures */
> > +#define __NR_userfaultfd 283
> >  #else
> >  #error "missing __NR_userfaultfd definition"
> >  #endif
> > +#endif /* !__NR_userfaultfd */
> >  
> >  static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size;
> >  
> > 
> 
> This is not okay. User-space shouldn't be (re)defining/duplicating
> syscall numbers. I can't take this patch.

-mm has already been updated to do exactly that. Syscall numbers end
up hardcoded into userland binaries/libs somewhere, so it's not a
bugfix but certainly it's a nice cleanup to remove the whole #ifdef block.

Andre, could you see if linux-next (which includes -mm) works for you
by just running "cd tools/testing/selftests/vm/ && make"? If there's
any further change required could you diff it against linux-next?

Thanks!
Andrea
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/