Skip to content

Fix conftest probes on kernels with allocation profiling - #592

Open
mornepousse wants to merge 1 commit into
DisplayLink:mainfrom
mornepousse:conftest-kbuild-modname
Open

Fix conftest probes on kernels with allocation profiling#592
mornepousse wants to merge 1 commit into
DisplayLink:mainfrom
mornepousse:conftest-kbuild-modname

Conversation

@mornepousse

Copy link
Copy Markdown

v1.15.0 fails to build on kernels with CONFIG_MEM_ALLOC_PROFILING=y:

include/linux/acpi.h:69:50: error: macro 'kzalloc_obj' requires 2 arguments, but only 1 given

That's evdi's fallback kzalloc_obj from evdi_debug.h shadowing the kernel's
own macro, on a kernel that provides it. The support is in place
(EVDI_HAVE_KZALLOC_OBJ); detection is what fails.

conftest.sh compiles probes with $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -DMODULE, but KBUILD_MODNAME is a
per-object define kbuild adds outside KBUILD_CFLAGS, so probes never see it.
Since the probes define MODULE, and with allocation profiling on, every
allocator expands through alloc_hooksDEFINE_ALLOC_TAGCT_MODULE_NAME,
which codetag.h defines as KBUILD_MODNAME under #ifdef MODULE:

include/linux/codetag.h:64:24: error: 'KBUILD_MODNAME' undeclared

Any probe touching an allocator then fails regardless of whether the API
exists, and evdi_detect.h reports EVDI_HAVE_KZALLOC_OBJ unset on a kernel
that has it. Kernels without allocation profiling are unaffected —
DEFINE_ALLOC_TAG is empty there — which likely explains why CI stayed green.

Giving the probes a module name is enough:

 CFLAGS=$(requote "$@")
+CFLAGS="$CFLAGS '-DKBUILD_MODNAME=\"conftest\"' '-DKBUILD_BASENAME=\"conftest\"'"

This is not tied to one kernel release: I reproduced the failure and the fix on
both Linux 7.1.8 and 7.2.0 (CachyOS x86-64-v3, CONFIG_MEM_ALLOC_PROFILING=y,
gcc 15.3). Unpatched, both fail at acpi.h:69; patched, both build evdi.ko.
Compiling the probe body standalone shows the same split — it fails only with
-DMODULE and no KBUILD_MODNAME, and a probe without an allocation compiles
either way.

v1.14.x is unaffected: conftest.sh arrived with 490e1e8, released in v1.15.0.

(Disclosure: diagnosed and tested with Claude Code — Claude Fable 5 for the
first analysis, Claude Opus 5 for the verification and this text. I reviewed
the reasoning and ran the builds.)

Probes are compiled with $(KBUILD_CFLAGS) -DMODULE, but KBUILD_MODNAME is a
per-object define kbuild adds outside KBUILD_CFLAGS, so probes never see it.
On kernels with CONFIG_MEM_ALLOC_PROFILING=y every allocator expands through
alloc_hooks -> DEFINE_ALLOC_TAG -> CT_MODULE_NAME, which codetag.h defines as
KBUILD_MODNAME under #ifdef MODULE. Any probe touching an allocator then fails
to compile regardless of whether the API exists:

  include/linux/codetag.h:64:24: error: 'KBUILD_MODNAME' undeclared

EVDI_HAVE_KZALLOC_OBJ is left unset on kernels that do provide kzalloc_obj, the
fallback in evdi_debug.h shadows the kernel macro, and the build fails:

  include/linux/acpi.h:69:50: error: macro 'kzalloc_obj' requires 2 arguments, but only 1 given

Reproduced and fixed on Linux 7.1.8 and 7.2.0 with allocation profiling on;
kernels built without it are unaffected, since DEFINE_ALLOC_TAG is empty there.

Assisted-by: Claude Code (Claude Opus 5)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y8tKd3MUQYNFFo89sXDm3P
DArtagan added a commit to DArtagan/dotfiles that referenced this pull request Sep 1, 2026
evdi 1.14.15 fails to compile against kernel 7.2. DRM renamed the atomic
callback argument (struct drm_atomic_state -> drm_atomic_commit), so the
crtc/plane atomic_begin and atomic_flush hooks in evdi_modeset.c became
incompatible-pointer-type errors, which gcc 15 treats as fatal.

The root cause is that evdi's conftest.sh feature probes misdetect the
kernel API: the probe compiles lack KBUILD_MODNAME, so they fail for the
wrong reason and evdi selects the pre-rename variant. Vendor the upstream
conftest fix (DisplayLink/evdi#592) alongside the version bump.

evdi is in the closure because this host sets xserver.videoDrivers to
include "displaylink" for the Dell USB-C dock.

This mirrors nixpkgs#555981, which is still open. Drop the overlay once
that lands.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DaRQ5yiWeZuXNfDJa3yTCg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant