mbox series

[00/34] selftests: Fix incorrect kernel headers search path

Message ID 20230127135755.79929-1-mathieu.desnoyers@efficios.com
Headers show
Series selftests: Fix incorrect kernel headers search path | expand

Message

Mathieu Desnoyers Jan. 27, 2023, 1:57 p.m. UTC
Hi,

This series fixes incorrect kernel header search path in kernel
selftests.

Near the end of the series, a few changes are not tagged as "Fixes"
because the current behavior is to rely on the kernel sources uapi files
rather than on the installed kernel header files. Nevertheless, those
are updated for consistency.

There are situations where "../../../../include/" was added to -I search
path, which is bogus for userspace tests and caused issues with types.h.
Those are removed. 

Thanks,

Mathieu

Mathieu Desnoyers (34):
  selftests: arm64: Fix incorrect kernel headers search path
  selftests: bpf: Fix incorrect kernel headers search path
  selftests: clone3: Fix incorrect kernel headers search path
  selftests: core: Fix incorrect kernel headers search path
  selftests: dma: Fix incorrect kernel headers search path
  selftests: dmabuf-heaps: Fix incorrect kernel headers search path
  selftests: drivers: Fix incorrect kernel headers search path
  selftests: filesystems: Fix incorrect kernel headers search path
  selftests: futex: Fix incorrect kernel headers search path
  selftests: gpio: Fix incorrect kernel headers search path
  selftests: ipc: Fix incorrect kernel headers search path
  selftests: kcmp: Fix incorrect kernel headers search path
  selftests: media_tests: Fix incorrect kernel headers search path
  selftests: membarrier: Fix incorrect kernel headers search path
  selftests: mount_setattr: Fix incorrect kernel headers search path
  selftests: move_mount_set_group: Fix incorrect kernel headers search
    path
  selftests: net: Fix incorrect kernel headers search path
  selftests: perf_events: Fix incorrect kernel headers search path
  selftests: pid_namespace: Fix incorrect kernel headers search path
  selftests: pidfd: Fix incorrect kernel headers search path
  selftests: powerpc: Fix incorrect kernel headers search path
  selftests: ptp: Fix incorrect kernel headers search path
  selftests: rseq: Fix incorrect kernel headers search path
  selftests: sched: Fix incorrect kernel headers search path
  selftests: seccomp: Fix incorrect kernel headers search path
  selftests: sync: Fix incorrect kernel headers search path
  selftests: user_events: Fix incorrect kernel headers search path
  selftests: vm: Fix incorrect kernel headers search path
  selftests: x86: Fix incorrect kernel headers search path
  selftests: bpf docs: Use installed kernel headers search path
  selftests: iommu: Use installed kernel headers search path
  selftests: memfd: Use installed kernel headers search path
  selftests: ptrace: Use installed kernel headers search path
  selftests: tdx: Use installed kernel headers search path

 tools/testing/selftests/arm64/fp/Makefile               | 2 +-
 tools/testing/selftests/arm64/tags/Makefile             | 2 +-
 tools/testing/selftests/bpf/Makefile                    | 2 +-
 tools/testing/selftests/bpf/Makefile.docs               | 2 +-
 tools/testing/selftests/clone3/Makefile                 | 2 +-
 tools/testing/selftests/core/Makefile                   | 2 +-
 tools/testing/selftests/dma/Makefile                    | 2 +-
 tools/testing/selftests/dmabuf-heaps/Makefile           | 2 +-
 tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c      | 3 +--
 tools/testing/selftests/drivers/dma-buf/Makefile        | 2 +-
 tools/testing/selftests/drivers/s390x/uvdevice/Makefile | 3 +--
 tools/testing/selftests/filesystems/Makefile            | 2 +-
 tools/testing/selftests/filesystems/binderfs/Makefile   | 2 +-
 tools/testing/selftests/filesystems/epoll/Makefile      | 2 +-
 tools/testing/selftests/futex/functional/Makefile       | 2 +-
 tools/testing/selftests/gpio/Makefile                   | 2 +-
 tools/testing/selftests/iommu/Makefile                  | 3 +--
 tools/testing/selftests/ipc/Makefile                    | 2 +-
 tools/testing/selftests/kcmp/Makefile                   | 2 +-
 tools/testing/selftests/media_tests/Makefile            | 2 +-
 tools/testing/selftests/membarrier/Makefile             | 2 +-
 tools/testing/selftests/memfd/Makefile                  | 4 +---
 tools/testing/selftests/mount_setattr/Makefile          | 2 +-
 tools/testing/selftests/move_mount_set_group/Makefile   | 2 +-
 tools/testing/selftests/net/Makefile                    | 2 +-
 tools/testing/selftests/net/bpf/Makefile                | 2 +-
 tools/testing/selftests/net/mptcp/Makefile              | 2 +-
 tools/testing/selftests/net/openvswitch/Makefile        | 2 +-
 tools/testing/selftests/perf_events/Makefile            | 2 +-
 tools/testing/selftests/pid_namespace/Makefile          | 2 +-
 tools/testing/selftests/pidfd/Makefile                  | 2 +-
 tools/testing/selftests/powerpc/ptrace/Makefile         | 2 +-
 tools/testing/selftests/powerpc/security/Makefile       | 2 +-
 tools/testing/selftests/powerpc/syscalls/Makefile       | 2 +-
 tools/testing/selftests/powerpc/tm/Makefile             | 2 +-
 tools/testing/selftests/ptp/Makefile                    | 2 +-
 tools/testing/selftests/ptrace/Makefile                 | 2 +-
 tools/testing/selftests/rseq/Makefile                   | 2 +-
 tools/testing/selftests/sched/Makefile                  | 2 +-
 tools/testing/selftests/seccomp/Makefile                | 2 +-
 tools/testing/selftests/sync/Makefile                   | 2 +-
 tools/testing/selftests/tdx/Makefile                    | 2 +-
 tools/testing/selftests/tdx/tdx_guest_test.c            | 2 +-
 tools/testing/selftests/user_events/Makefile            | 2 +-
 tools/testing/selftests/vm/Makefile                     | 2 +-
 tools/testing/selftests/x86/Makefile                    | 2 +-
 46 files changed, 46 insertions(+), 51 deletions(-)

Comments

Matthieu Baerts Jan. 27, 2023, 4:21 p.m. UTC | #1
Hi Mathieu,

On 27/01/2023 14:57, Mathieu Desnoyers wrote:
> Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents
> building against kernel headers from the build environment in scenarios
> where kernel headers are installed into a specific output directory
> (O=...).

Thank you for the patch!

> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Cc: Shuah Khan <shuah@kernel.org>
> Cc: linux-kselftest@vger.kernel.org
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: <stable@vger.kernel.org>    [5.18+]

(It might be useful to add a "Fixes" tag as well to clearly indicate the
dependence with a specific commit and better understand the fix.)

(and add all the individual maintainers of the files you modify -- feel
free to use 'b4' to help you for this task ;-) )

(...)

> diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/selftests/net/mptcp/Makefile
> index 43a723626126..06bba013bcef 100644
> --- a/tools/testing/selftests/net/mptcp/Makefile
> +++ b/tools/testing/selftests/net/mptcp/Makefile
> @@ -2,7 +2,7 @@
>  
>  top_srcdir = ../../../../..
>  
> -CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES)
> +CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g $(KHDR_INCLUDES)

I only looked at the modification here with MPTCP selftests and it looks
good to me. It makes sense because if KHDR_INCLUDES is not set, it will
be set later by lib.mk I suppose.

Just one small thing: I guess you can also remove "top_srcdir" variable
that is no longer used, right? I see that "lib.mk" uses a variable with
the same name but it overrides its value anyway. But it is likely I
missed something there :)

If indeed it is no longer needed, I guess a few Makefile can be adapted
according to:

  git grep top_srcdir -- tools/testing/selftests/*/

I guess most of these Makefile are very similar, no? For MPTCP, we
simply looked at what was done elsewhere :)

Cheers,
Matt
Shuah Khan Jan. 30, 2023, 4:12 p.m. UTC | #2
On 1/27/23 06:57, Mathieu Desnoyers wrote:
> Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents
> building against kernel headers from the build environment in scenarios
> where kernel headers are installed into a specific output directory
> (O=...).
> 
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Cc: Shuah Khan <shuah@kernel.org>
> Cc: linux-kselftest@vger.kernel.org
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: <stable@vger.kernel.org>    [5.18+]
> ---
>   tools/testing/selftests/bpf/Makefile | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index c22c43bbee19..6998c816afef 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -327,7 +327,7 @@ endif
>   CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
>   BPF_CFLAGS = -g -Werror -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN) 		\
>   	     -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR)			\
> -	     -I$(abspath $(OUTPUT)/../usr/include)
> +	     $(KHDR_INCLUDES)
>   
>   CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \
>   	       -Wno-compare-distinct-pointer-types



Adding bpf maintainers - bpf patches usually go through bpf tree.

Acked-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah
Alexei Starovoitov Jan. 30, 2023, 4:26 p.m. UTC | #3
On Mon, Jan 30, 2023 at 8:12 AM Shuah Khan <skhan@linuxfoundation.org> wrote:
>
> On 1/27/23 06:57, Mathieu Desnoyers wrote:
> > Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents
> > building against kernel headers from the build environment in scenarios
> > where kernel headers are installed into a specific output directory
> > (O=...).
> >
> > Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> > Cc: Shuah Khan <shuah@kernel.org>
> > Cc: linux-kselftest@vger.kernel.org
> > Cc: Ingo Molnar <mingo@redhat.com>
> > Cc: <stable@vger.kernel.org>    [5.18+]
> > ---
> >   tools/testing/selftests/bpf/Makefile | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> > index c22c43bbee19..6998c816afef 100644
> > --- a/tools/testing/selftests/bpf/Makefile
> > +++ b/tools/testing/selftests/bpf/Makefile
> > @@ -327,7 +327,7 @@ endif
> >   CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
> >   BPF_CFLAGS = -g -Werror -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN)               \
> >            -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR)                   \
> > -          -I$(abspath $(OUTPUT)/../usr/include)
> > +          $(KHDR_INCLUDES)
> >
> >   CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \
> >              -Wno-compare-distinct-pointer-types
>
>
>
> Adding bpf maintainers - bpf patches usually go through bpf tree.
>
> Acked-by: Shuah Khan <skhan@linuxfoundation.org>

Please resubmit as separate patch with [PATCH bpf-next] subj
and cc bpf@vger, so that BPF CI can test it on various architectures
and config combinations.
Shuah Khan Jan. 30, 2023, 4:51 p.m. UTC | #4
On 1/30/23 09:44, Shuah Khan wrote:
> On 1/27/23 06:57, Mathieu Desnoyers wrote:
>> Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents
>> building against kernel headers from the build environment in scenarios
>> where kernel headers are installed into a specific output directory
>> (O=...).
>>
>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>> Cc: Shuah Khan <shuah@kernel.org>
>> Cc: linux-kselftest@vger.kernel.org
>> Cc: Ingo Molnar <mingo@redhat.com>
>> Cc: <stable@vger.kernel.org>    [5.18+]
>> ---
>>   tools/testing/selftests/sync/Makefile | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/sync/Makefile b/tools/testing/selftests/sync/Makefile
>> index d0121a8a3523..df0f91bf6890 100644
>> --- a/tools/testing/selftests/sync/Makefile
>> +++ b/tools/testing/selftests/sync/Makefile
>> @@ -1,6 +1,6 @@
>>   # SPDX-License-Identifier: GPL-2.0
>>   CFLAGS += -O2 -g -std=gnu89 -pthread -Wall -Wextra
>> -CFLAGS += -I../../../../usr/include/
>> +CFLAGS += $(KHDR_INCLUDES)
>>   LDFLAGS += -pthread
>>   .PHONY: all clean
> 
> Adding seccomp maintainers:
> 
> kees,
> 
> I plan to take this through kselftest unless there are conflicts.
> In case there are conflicts and you want to take this through yours
> 
> Acked-by: Shuah Khan <skhan@linuxfoundation.org>
> 
Sorry wrong message. I am taking this one through mine.

-- Shuah
Shuah Khan Jan. 30, 2023, 4:55 p.m. UTC | #5
On 1/27/23 06:57, Mathieu Desnoyers wrote:
> Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents
> building against kernel headers from the build environment in scenarios
> where kernel headers are installed into a specific output directory
> (O=...).
> 
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Cc: Shuah Khan <shuah@kernel.org>
> Cc: linux-kselftest@vger.kernel.org
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: <stable@vger.kernel.org>    [5.18+]
> ---
>   tools/testing/selftests/vm/Makefile | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
> index 89c14e41bd43..ac9366065fd2 100644
> --- a/tools/testing/selftests/vm/Makefile
> +++ b/tools/testing/selftests/vm/Makefile
> @@ -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 $(top_srcdir) -I $(top_srcdir)/usr/include $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
> +CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
>   LDLIBS = -lrt -lpthread
>   TEST_GEN_FILES = cow
>   TEST_GEN_FILES += compaction_test

Adding mm maintainers.

Andrew,

Would you me to take this patch through kselftest tree? If you
decide to take this through yours:

Acked-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah
Mathieu Desnoyers Jan. 30, 2023, 5 p.m. UTC | #6
On 2023-01-30 11:26, Alexei Starovoitov wrote:
> On Mon, Jan 30, 2023 at 8:12 AM Shuah Khan <skhan@linuxfoundation.org> wrote:
>>
>> On 1/27/23 06:57, Mathieu Desnoyers wrote:
>>> Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents
>>> building against kernel headers from the build environment in scenarios
>>> where kernel headers are installed into a specific output directory
>>> (O=...).
>>>
>>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>>> Cc: Shuah Khan <shuah@kernel.org>
>>> Cc: linux-kselftest@vger.kernel.org
>>> Cc: Ingo Molnar <mingo@redhat.com>
>>> Cc: <stable@vger.kernel.org>    [5.18+]
>>> ---
>>>    tools/testing/selftests/bpf/Makefile | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
>>> index c22c43bbee19..6998c816afef 100644
>>> --- a/tools/testing/selftests/bpf/Makefile
>>> +++ b/tools/testing/selftests/bpf/Makefile
>>> @@ -327,7 +327,7 @@ endif
>>>    CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
>>>    BPF_CFLAGS = -g -Werror -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN)               \
>>>             -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR)                   \
>>> -          -I$(abspath $(OUTPUT)/../usr/include)
>>> +          $(KHDR_INCLUDES)
>>>
>>>    CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \
>>>               -Wno-compare-distinct-pointer-types
>>
>>
>>
>> Adding bpf maintainers - bpf patches usually go through bpf tree.
>>
>> Acked-by: Shuah Khan <skhan@linuxfoundation.org>
> 
> Please resubmit as separate patch with [PATCH bpf-next] subj
> and cc bpf@vger, so that BPF CI can test it on various architectures
> and config combinations.

Hi Shuah,

Do you have means to resubmit it on your end, or should I do it ?

Thanks,

Mathieu
Shuah Khan Jan. 30, 2023, 5:09 p.m. UTC | #7
On 1/30/23 10:00, Mathieu Desnoyers wrote:
> On 2023-01-30 11:26, Alexei Starovoitov wrote:
>> On Mon, Jan 30, 2023 at 8:12 AM Shuah Khan <skhan@linuxfoundation.org> wrote:
>>>
>>> On 1/27/23 06:57, Mathieu Desnoyers wrote:
>>>> Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents
>>>> building against kernel headers from the build environment in scenarios
>>>> where kernel headers are installed into a specific output directory
>>>> (O=...).
>>>>
>>>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>>>> Cc: Shuah Khan <shuah@kernel.org>
>>>> Cc: linux-kselftest@vger.kernel.org
>>>> Cc: Ingo Molnar <mingo@redhat.com>
>>>> Cc: <stable@vger.kernel.org>    [5.18+]
>>>> ---
>>>>    tools/testing/selftests/bpf/Makefile | 2 +-
>>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
>>>> index c22c43bbee19..6998c816afef 100644
>>>> --- a/tools/testing/selftests/bpf/Makefile
>>>> +++ b/tools/testing/selftests/bpf/Makefile
>>>> @@ -327,7 +327,7 @@ endif
>>>>    CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
>>>>    BPF_CFLAGS = -g -Werror -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN)               \
>>>>             -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR)                   \
>>>> -          -I$(abspath $(OUTPUT)/../usr/include)
>>>> +          $(KHDR_INCLUDES)
>>>>
>>>>    CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \
>>>>               -Wno-compare-distinct-pointer-types
>>>
>>>
>>>
>>> Adding bpf maintainers - bpf patches usually go through bpf tree.
>>>
>>> Acked-by: Shuah Khan <skhan@linuxfoundation.org>
>>
>> Please resubmit as separate patch with [PATCH bpf-next] subj
>> and cc bpf@vger, so that BPF CI can test it on various architectures
>> and config combinations.
> 
> Hi Shuah,
> 
> Do you have means to resubmit it on your end, or should I do it ?
> 

Hi Mathieu,

Please go ahead and resubmit.

thanks,
-- Shuah
Shuah Khan Jan. 30, 2023, 5:20 p.m. UTC | #8
On 1/30/23 10:14, Catalin Marinas wrote:
> Hi Shuah,
> 
> On Mon, Jan 30, 2023 at 09:09:42AM -0700, Shuah Khan wrote:
>> On 1/27/23 06:57, Mathieu Desnoyers wrote:
>>> Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents
>>> building against kernel headers from the build environment in scenarios
>>> where kernel headers are installed into a specific output directory
>>> (O=...).
>>>
>>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>>> Cc: Shuah Khan <shuah@kernel.org>
>>> Cc: linux-kselftest@vger.kernel.org
>>> Cc: Ingo Molnar <mingo@redhat.com>
>>> Cc: <stable@vger.kernel.org>    [5.18+]
>>> ---
>>>    tools/testing/selftests/arm64/fp/Makefile   | 2 +-
>>>    tools/testing/selftests/arm64/tags/Makefile | 2 +-
>>>    2 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>
>> Adding arm maintainers.
>>
>> Would you me to take this patch through kselftest tree? If you
>> decide to take this through yours:
> 
> Are you taking the whole series? If yes:
> 
> Acked-by: Catalin Marinas <catalin.marinas@arm.com>
> 
> (otherwise I can pick this up)
> 

I am taking several patches in the series with an exception
when maintainers want to take them through theirs.

I will apply to mine and take this through.

thanks,
-- Shuah
Shuah Khan Jan. 30, 2023, 10:29 p.m. UTC | #9
On 1/27/23 06:57, Mathieu Desnoyers wrote:
> Hi,
> 
> This series fixes incorrect kernel header search path in kernel
> selftests.
> 
> Near the end of the series, a few changes are not tagged as "Fixes"
> because the current behavior is to rely on the kernel sources uapi files
> rather than on the installed kernel header files. Nevertheless, those
> are updated for consistency.
> 
> There are situations where "../../../../include/" was added to -I search
> path, which is bogus for userspace tests and caused issues with types.h.
> Those are removed.
> 
> Thanks,
> 
> Mathieu
> 
> Mathieu Desnoyers (34):

The below patches are now applied to linux-kselftest next for Linux 6.3-rc1

>    selftests: arm64: Fix incorrect kernel headers search path
>    selftests: clone3: Fix incorrect kernel headers search path
>    selftests: core: Fix incorrect kernel headers search path
>    selftests: dma: Fix incorrect kernel headers search path
>    selftests: dmabuf-heaps: Fix incorrect kernel headers search path
>    selftests: drivers: Fix incorrect kernel headers search path
>    selftests: filesystems: Fix incorrect kernel headers search path
>    selftests: futex: Fix incorrect kernel headers search path
>    selftests: gpio: Fix incorrect kernel headers search path
>    selftests: ipc: Fix incorrect kernel headers search path
>    selftests: kcmp: Fix incorrect kernel headers search path
>    selftests: media_tests: Fix incorrect kernel headers search path
>    selftests: membarrier: Fix incorrect kernel headers search path
>    selftests: mount_setattr: Fix incorrect kernel headers search path
>    selftests: move_mount_set_group: Fix incorrect kernel headers search
>      path
>    selftests: perf_events: Fix incorrect kernel headers search path
>    selftests: pid_namespace: Fix incorrect kernel headers search path
>    selftests: pidfd: Fix incorrect kernel headers search path
>    selftests: ptp: Fix incorrect kernel headers search path
>    selftests: rseq: Fix incorrect kernel headers search path
>    selftests: sched: Fix incorrect kernel headers search path
>    selftests: seccomp: Fix incorrect kernel headers search path
>    selftests: sync: Fix incorrect kernel headers search path
>    selftests: user_events: Fix incorrect kernel headers search path
>    selftests: vm: Fix incorrect kernel headers search path
>    selftests: x86: Fix incorrect kernel headers search path
>    selftests: iommu: Use installed kernel headers search path
>    selftests: memfd: Use installed kernel headers search path
>    selftests: ptrace: Use installed kernel headers search path
>    selftests: tdx: Use installed kernel headers search path
> 

These will be applied by maintainers to their trees.

>    selftests: bpf: Fix incorrect kernel headers search path # 02/34
>    selftests: net: Fix incorrect kernel headers search path # 17/34
>    selftests: powerpc: Fix incorrect kernel headers search path # 21/34
>    selftests: bpf docs: Use installed kernel headers search path # 30/34

thanks,
-- Shuah
Alexei Starovoitov Jan. 30, 2023, 11:45 p.m. UTC | #10
On Mon, Jan 30, 2023 at 2:46 PM Shuah Khan <skhan@linuxfoundation.org> wrote:
>
> On 1/27/23 06:57, Mathieu Desnoyers wrote:
> > Hi,
> >
> > This series fixes incorrect kernel header search path in kernel
> > selftests.
> >
> > Near the end of the series, a few changes are not tagged as "Fixes"
> > because the current behavior is to rely on the kernel sources uapi files
> > rather than on the installed kernel header files. Nevertheless, those
> > are updated for consistency.
> >
> > There are situations where "../../../../include/" was added to -I search
> > path, which is bogus for userspace tests and caused issues with types.h.
> > Those are removed.
> >
> > Thanks,
> >
> > Mathieu
> >
> > Mathieu Desnoyers (34):
>
> The below patches are now applied to linux-kselftest next for Linux 6.3-rc1
>
> >    selftests: arm64: Fix incorrect kernel headers search path
> >    selftests: clone3: Fix incorrect kernel headers search path
> >    selftests: core: Fix incorrect kernel headers search path
> >    selftests: dma: Fix incorrect kernel headers search path
> >    selftests: dmabuf-heaps: Fix incorrect kernel headers search path
> >    selftests: drivers: Fix incorrect kernel headers search path
> >    selftests: filesystems: Fix incorrect kernel headers search path
> >    selftests: futex: Fix incorrect kernel headers search path
> >    selftests: gpio: Fix incorrect kernel headers search path
> >    selftests: ipc: Fix incorrect kernel headers search path
> >    selftests: kcmp: Fix incorrect kernel headers search path
> >    selftests: media_tests: Fix incorrect kernel headers search path
> >    selftests: membarrier: Fix incorrect kernel headers search path
> >    selftests: mount_setattr: Fix incorrect kernel headers search path
> >    selftests: move_mount_set_group: Fix incorrect kernel headers search
> >      path
> >    selftests: perf_events: Fix incorrect kernel headers search path
> >    selftests: pid_namespace: Fix incorrect kernel headers search path
> >    selftests: pidfd: Fix incorrect kernel headers search path
> >    selftests: ptp: Fix incorrect kernel headers search path
> >    selftests: rseq: Fix incorrect kernel headers search path
> >    selftests: sched: Fix incorrect kernel headers search path
> >    selftests: seccomp: Fix incorrect kernel headers search path
> >    selftests: sync: Fix incorrect kernel headers search path
> >    selftests: user_events: Fix incorrect kernel headers search path
> >    selftests: vm: Fix incorrect kernel headers search path
> >    selftests: x86: Fix incorrect kernel headers search path
> >    selftests: iommu: Use installed kernel headers search path
> >    selftests: memfd: Use installed kernel headers search path
> >    selftests: ptrace: Use installed kernel headers search path
> >    selftests: tdx: Use installed kernel headers search path
> >
>
> These will be applied by maintainers to their trees.

Not in this form. They break the build.

> >    selftests: bpf: Fix incorrect kernel headers search path # 02/34
> >    selftests: net: Fix incorrect kernel headers search path # 17/34
> >    selftests: powerpc: Fix incorrect kernel headers search path # 21/34
> >    selftests: bpf docs: Use installed kernel headers search path # 30/34
>
> thanks,
> -- Shuah
Shuah Khan Jan. 30, 2023, 11:48 p.m. UTC | #11
On 1/30/23 16:45, Alexei Starovoitov wrote:
> On Mon, Jan 30, 2023 at 2:46 PM Shuah Khan <skhan@linuxfoundation.org> wrote:
>>
>> On 1/27/23 06:57, Mathieu Desnoyers wrote:
>>> Hi,
>>>
>>> This series fixes incorrect kernel header search path in kernel
>>> selftests.
>>>
>>> Near the end of the series, a few changes are not tagged as "Fixes"
>>> because the current behavior is to rely on the kernel sources uapi files
>>> rather than on the installed kernel header files. Nevertheless, those
>>> are updated for consistency.
>>>
>>> There are situations where "../../../../include/" was added to -I search
>>> path, which is bogus for userspace tests and caused issues with types.h.
>>> Those are removed.
>>>
>>> Thanks,
>>>
>>> Mathieu
>>>
>>> Mathieu Desnoyers (34):
>>
>> The below patches are now applied to linux-kselftest next for Linux 6.3-rc1
>>
>>>     selftests: arm64: Fix incorrect kernel headers search path
>>>     selftests: clone3: Fix incorrect kernel headers search path
>>>     selftests: core: Fix incorrect kernel headers search path
>>>     selftests: dma: Fix incorrect kernel headers search path
>>>     selftests: dmabuf-heaps: Fix incorrect kernel headers search path
>>>     selftests: drivers: Fix incorrect kernel headers search path
>>>     selftests: filesystems: Fix incorrect kernel headers search path
>>>     selftests: futex: Fix incorrect kernel headers search path
>>>     selftests: gpio: Fix incorrect kernel headers search path
>>>     selftests: ipc: Fix incorrect kernel headers search path
>>>     selftests: kcmp: Fix incorrect kernel headers search path
>>>     selftests: media_tests: Fix incorrect kernel headers search path
>>>     selftests: membarrier: Fix incorrect kernel headers search path
>>>     selftests: mount_setattr: Fix incorrect kernel headers search path
>>>     selftests: move_mount_set_group: Fix incorrect kernel headers search
>>>       path
>>>     selftests: perf_events: Fix incorrect kernel headers search path
>>>     selftests: pid_namespace: Fix incorrect kernel headers search path
>>>     selftests: pidfd: Fix incorrect kernel headers search path
>>>     selftests: ptp: Fix incorrect kernel headers search path
>>>     selftests: rseq: Fix incorrect kernel headers search path
>>>     selftests: sched: Fix incorrect kernel headers search path
>>>     selftests: seccomp: Fix incorrect kernel headers search path
>>>     selftests: sync: Fix incorrect kernel headers search path
>>>     selftests: user_events: Fix incorrect kernel headers search path
>>>     selftests: vm: Fix incorrect kernel headers search path
>>>     selftests: x86: Fix incorrect kernel headers search path
>>>     selftests: iommu: Use installed kernel headers search path
>>>     selftests: memfd: Use installed kernel headers search path
>>>     selftests: ptrace: Use installed kernel headers search path
>>>     selftests: tdx: Use installed kernel headers search path
>>>
>>
>> These will be applied by maintainers to their trees.
> 
> Not in this form. They break the build.

Mathieu is sending you the patches in the format you requested in
the thread on this patch.

thanks,
-- Shuah
Alexei Starovoitov Jan. 30, 2023, 11:49 p.m. UTC | #12
On Mon, Jan 30, 2023 at 3:48 PM Shuah Khan <skhan@linuxfoundation.org> wrote:
>
> >>
> >> These will be applied by maintainers to their trees.
> >
> > Not in this form. They break the build.
>
> Mathieu is sending you the patches in the format you requested in
> the thread on this patch.

It's not the format, but the patch itself is incorrect.
Shuah Khan Feb. 2, 2023, 2:07 a.m. UTC | #13
Hi Mathieu,

On 1/30/23 15:29, Shuah Khan wrote:
> On 1/27/23 06:57, Mathieu Desnoyers wrote:
>> Hi,
>>
>> This series fixes incorrect kernel header search path in kernel
>> selftests.
>>
>> Near the end of the series, a few changes are not tagged as "Fixes"
>> because the current behavior is to rely on the kernel sources uapi files
>> rather than on the installed kernel header files. Nevertheless, those
>> are updated for consistency.
>>
>> There are situations where "../../../../include/" was added to -I search
>> path, which is bogus for userspace tests and caused issues with types.h.
>> Those are removed.
>>

Thanks again for taking care of this. I did out of tree build testing on
x86 on linux-kselftest next with these patches below. I haven't seen
any problems introduced by the patch set.

>>    selftests: dma: Fix incorrect kernel headers search path
This one needs a change and I will send a patch on top of yours.
Even with that this test depends on unexported header from the
repo and won't build out of tree. This is not related to your
change.

>>    selftests: mount_setattr: Fix incorrect kernel headers search path
This one fails to build with our without patch - an existing error.

I have to do cross-build tests on arm64 and other arch patches still.
This will happen later this week.

>>    selftests: arm64: Fix incorrect kernel headers search path

drivers patch below had arch specific tests - testing todo

The rest looks good. I will try to run bpf patches on my system.
I do have clang, llvm installed on mine. TODO

thanks,
-- Shuah
Shuah Khan Feb. 4, 2023, 1:06 a.m. UTC | #14
On 2/1/23 19:07, Shuah Khan wrote:
> Hi Mathieu,
> 
> On 1/30/23 15:29, Shuah Khan wrote:
>> On 1/27/23 06:57, Mathieu Desnoyers wrote:
>>> Hi,
>>>
>>> This series fixes incorrect kernel header search path in kernel
>>> selftests.
>>>
>>> Near the end of the series, a few changes are not tagged as "Fixes"
>>> because the current behavior is to rely on the kernel sources uapi files
>>> rather than on the installed kernel header files. Nevertheless, those
>>> are updated for consistency.
>>>
>>> There are situations where "../../../../include/" was added to -I search
>>> path, which is bogus for userspace tests and caused issues with types.h.
>>> Those are removed.
>>>
> 
> Thanks again for taking care of this. I did out of tree build testing on
> x86 on linux-kselftest next with these patches below. I haven't seen
> any problems introduced by the patch set.
> 
>>>    selftests: dma: Fix incorrect kernel headers search path
> This one needs a change and I will send a patch on top of yours.
> Even with that this test depends on unexported header from the
> repo and won't build out of tree. This is not related to your
> change.
> 
>>>    selftests: mount_setattr: Fix incorrect kernel headers search path
> This one fails to build with our without patch - an existing error.
> 
> I have to do cross-build tests on arm64 and other arch patches still.
> This will happen later this week.

arm64, s390 patches look good.

thanks,
-- Shuah
Shuah Khan Feb. 11, 2023, 12:15 a.m. UTC | #15
On 2/3/23 18:06, Shuah Khan wrote:
> On 2/1/23 19:07, Shuah Khan wrote:
>> Hi Mathieu,
>>
>> On 1/30/23 15:29, Shuah Khan wrote:
>>> On 1/27/23 06:57, Mathieu Desnoyers wrote:
>>>> Hi,
>>>>
>>>> This series fixes incorrect kernel header search path in kernel
>>>> selftests.
>>>>
>>>> Near the end of the series, a few changes are not tagged as "Fixes"
>>>> because the current behavior is to rely on the kernel sources uapi files
>>>> rather than on the installed kernel header files. Nevertheless, those
>>>> are updated for consistency.
>>>>
>>>> There are situations where "../../../../include/" was added to -I search
>>>> path, which is bogus for userspace tests and caused issues with types.h.
>>>> Those are removed.
>>>>
>>
>> Thanks again for taking care of this. I did out of tree build testing on
>> x86 on linux-kselftest next with these patches below. I haven't seen
>> any problems introduced by the patch set.
>>
>>>>    selftests: dma: Fix incorrect kernel headers search path
>> This one needs a change and I will send a patch on top of yours.
>> Even with that this test depends on unexported header from the
>> repo and won't build out of tree. This is not related to your
>> change.
>>
>>>>    selftests: mount_setattr: Fix incorrect kernel headers search path
>> This one fails to build with our without patch - an existing error.
>>
>> I have to do cross-build tests on arm64 and other arch patches still.
>> This will happen later this week.
> 
> arm64, s390 patches look good.
> 

I am seeing problem with selftests/dma and selfttests/user_events.

1. selftests: dma: Fix incorrect kernel headers search path

dma test no longer builds. This test depends on linux/map_benchmark.h
which is not included in uapi

The order of include directorries -isystem followed by installed kernel
headers, breaks the test build with the change to use KHDR_INCLUDES


I am going to revert this patch for now and figure a longer term fix.
The problem is the dependency on a non-uapi file: linux/map_benchmark.h

Fixes: 8ddde07a3d28 ("dma-mapping: benchmark: extract a common
header file for map_benchmark definition") change added this
dependency on including linux/map_benchmark.h

Christoph, Do you see this map_benchmark.h as part of uapi?


2. selftests: user_events: Fix incorrect kernel headers search path
This one depends on linux/user_events.h which has bee removed from
uapi in this commit:

commit 5cfff569cab8bf544bab62c911c5d6efd5af5e05
Author: Steven Rostedt (Google) <rostedt@goodmis.org>
Date:   Fri Apr 1 14:39:03 2022 -0400

     tracing: Move user_events.h temporarily out of include/uapi

This isn't a regression from 6.2 - this test stopped building once
user_events.h has been removed from uapi. I will add a note that
this test depends on a non-uapi header and can't be built at the
moment.

thanks,
-- Shuah
Michael Ellerman Feb. 20, 2023, 3:49 a.m. UTC | #16
On Fri, 27 Jan 2023 08:57:21 -0500, Mathieu Desnoyers wrote:
> This series fixes incorrect kernel header search path in kernel
> selftests.
> 
> Near the end of the series, a few changes are not tagged as "Fixes"
> because the current behavior is to rely on the kernel sources uapi files
> rather than on the installed kernel header files. Nevertheless, those
> are updated for consistency.
> 
> [...]

Applied to powerpc/next.

[21/34] selftests: powerpc: Fix incorrect kernel headers search path
        https://git.kernel.org/powerpc/c/4f11410bf6da87defe8fd59b0413f0d9f71744da

cheers