Re: [PATCH 1/4] selftests/mm: remove flaky header check

Kevin Brodsky
2025-12-29T15:40:35Z

On 18/12/2025 15:25, Mark Brown wrote:
> On Thu, Dec 18, 2025 at 02:24:10PM +0100, Kevin Brodsky wrote:
>> On 17/12/2025 11:04, Mark Brown wrote:
>>> More generally building selftests with random older kernel versions
>>> isn't really something that's expected to be robust:
>> I suppose that Documentation/dev-tools/kselftest.rst talks about
>> *running* against older kernels, not *building* against them. That said,
> Yeah, running is fairly normal but huge swathes of the selftests won't
> build without current kernel headers and it's not an especially useful
> use of time to support that.
>
>> we are dealing with an out-of-tree kernel module here, so the two are
>> essentially the same... Yunsheng suggested an updated check that I think
>> is reasonable, maybe it is a reasonable compromise?
> Well, there's also the selection of KDIR which for some reason defaults
> to the installed kernel so we get:

Overall the kselftests tend to assume that we're building on the same
machine we'll run them, so at least that feels consistent. The same
default is used for most other out-of-tree kselftests modules
(livepatch, net/bench).

> $ make -C tools/testing/selftests LLVM=1 ARCH=arm64 TARGETS=mm
>
> Warning: missing page_frag_cache.h, please use a newer kernel. page_frag test will be skipped.

But yes if cross-compiling the default makes no sense and KDIR has to be
set explicitly.

> Your changelog says it'll work for an in tree build but I can't figure
> out how to do that (using the top level Makefile to recurse doesn't seem
> to DTRT either). Having looked at this more I think the problem here is
> that the selection of KDIR is wrong, not the check.

I use KBUILD_OUTPUT=out and KDIR needs to be absolute, so:
KDIR=$PWD/out. I suppose for an in-tree build KDIR=$PWD would do the
right thing. But yes it's all very wonky.

Maybe the documentation should be updated to recommend setting KDIR
explicitly? Or maybe it could default to KDIR=$PWD or $(abspath
$(KBUILD_OUTPUT)) when cross-compiling?

- Kevin