Fix conftest probes on kernels with allocation profiling - #592
Open
mornepousse wants to merge 1 commit into
Open
Fix conftest probes on kernels with allocation profiling#592mornepousse wants to merge 1 commit into
mornepousse wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
v1.15.0 fails to build on kernels with
CONFIG_MEM_ALLOC_PROFILING=y:That's evdi's fallback
kzalloc_objfromevdi_debug.hshadowing the kernel'sown macro, on a kernel that provides it. The support is in place
(
EVDI_HAVE_KZALLOC_OBJ); detection is what fails.conftest.shcompiles probes with$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -DMODULE, butKBUILD_MODNAMEis aper-object define kbuild adds outside
KBUILD_CFLAGS, so probes never see it.Since the probes define
MODULE, and with allocation profiling on, everyallocator expands through
alloc_hooks→DEFINE_ALLOC_TAG→CT_MODULE_NAME,which
codetag.hdefines asKBUILD_MODNAMEunder#ifdef MODULE:Any probe touching an allocator then fails regardless of whether the API
exists, and
evdi_detect.hreportsEVDI_HAVE_KZALLOC_OBJunset on a kernelthat has it. Kernels without allocation profiling are unaffected —
DEFINE_ALLOC_TAGis 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 buildevdi.ko.Compiling the probe body standalone shows the same split — it fails only with
-DMODULEand noKBUILD_MODNAME, and a probe without an allocation compileseither way.
v1.14.x is unaffected:
conftest.sharrived 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.)