Conversation
Member
|
The main branch is currently target at 6.17.8, so your kernel (6.12) is actually older than main's target, not newer, and it looks like most of the changes in this PR are to account for kernel interface changes. At this point I'd prefer not to add support for 6.12 (even 6.17 is getting a bit old; I'll probably switch to something newer in the not-too-distant future). Any chance that you could upgrade to 6.17.8 for your development work? |
Author
|
Thanks @johnousterhout . I will proceed with UDP changes. |
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.
HomaModule_main unit test fixes for newer kernels (6.12+)
Context: the unit test suite in
test/failed to build/pass on a newerkernel (6.12). Starting point: build failed to link (
pcpu_hotundefinedreferences), and after a first workaround only 308/804 tests passed. End
result after the fixes below: 804/804 tests pass (with ASan disabled;
see the ASan section at the end for its current status).
Files changed
test/Makefiletest/mock.htest/mock.c1.
pcpu_hotundefined reference (mock.c)Kernel 6.12 introduced
struct pcpu_hot(cache-hot per-CPU fields:current_task,preempt_count,cpu_number,top_of_stack, ...) inarch/x86/include/asm/current.h.raw_smp_processor_id()and other inlinekernel functions reference this per-CPU variable directly, so the unit test
binary needs real storage for the symbol to link. Added to
mock.c:2. Preempt-count-imbalance failures (mock.h restructure + Makefile)
Static inline functions and macros in C bake in whichever macro definition
is textually active at their definition point, not at the call site.
Many kernel headers (
skbuff.h,kthread.h,sched/signal.h, etc.,transitively pulled in by
homa_impl.hbefore it reached the old#include "mock.h"line) define inline functions using the realpreempt_disable()/preempt_enable()/smp_processor_id()/raw_smp_processor_id(),because mock.h's overrides weren't active yet when those headers were first
parsed. This caused ~495 tests to fail with "preempt_disables still active
after test".
Fix:
WARN/WARN_ON/WARN_ON_ONCE/WARN_ONCEoverrides and thepreempt_disable/preempt_enable/smp_processor_id/raw_smp_processor_idoverrides to the very top of
mock.h(right after the include guard).-include mock.hto the Makefile'sCINCLUDES(right after-include $(KDIR)/include/linux/kconfig.h), forcingmock.hto be thefirst header processed for every compiled
.cfile (test files andproduction
../*.cfiles alike).CCINCLUDES(used only forccutils.cc) was left unchanged.3. Macro-redefinition-as-error (mock.h)
Once mock.h ran first, its own later object-style overrides
(
HOMA_BPAGE_SIZE,HOMA_MIN_DEFAULT_PORT,net_generic,register_net_sysctl,tcp_v4_check,tcp_v6_check,this_cpu_ptr) wereapplied before the real headers/
homa.hdefined those symbols. Whenhoma_impl.h's normal include chain later pulled in the real headers, thereal definitions silently redefined the mocks — fatal under
-Werror.Fix: added early includes of the real headers, right after the new
preempt/smp override block and before mock.h's own later overrides:
homa_wire.hwas needed for a related but distinct reason: mock.h's ownfunction prototypes further down (e.g.
mock_skb_alloc(..., struct homa_common_hdr *h, ...)) were the first-ever reference tostruct homa_common_hdrin the translation unit. In C, a struct tag whosefirst appearance is inside a function prototype's parameter list gets only
function-prototype scope, not file scope — so it became a distinct,
incompatible type from the real
struct homa_common_hdrlater defined byhoma_wire.h, causing "incompatible pointer type" errors where thecompiler printed the identical type name on both sides of the diagnostic.
Including
homa_wire.hearly (so the real, complete, file-scope definitionexists first) fixed this.
4. Unused-variable warning from a kernel header (Makefile)
Pulling
net/tcp.hin earlier than before (via the include chain above)caused
net/sch_generic.h'sqdisc_cb_private_validate()to be parsedearlier too. Its local variable
qcbis only referenced insideBUILD_BUG_ON(sizeof(...)), which the compiler counts as unused — a realwarning that
-Wall -Werrorturned into a fatal error. Added-Wno-unused-variabletoWARNS.5. Runtime segfault in
rt6_get_cookie/fib6_get_cookie_safeAfter the build succeeded,
./unitsegfaulted immediately(
homa_peer_get→homa_peer_alloc→homa_peer_reset_dst→rt6_get_cookie).mock.c'sip6_dst_lookup_flow()returns apartially-initialized mock
struct rtable(onlydst.__rcuref,dst.ops,dst.dev,dst.obsoleteare set); calling the realrt6_get_cookie()inline function on it dereferences uninitialized/garbagefields. Diagnosed via a core dump + backtrace.
Fix: added a mock override to
mock.hso the real function is nevercalled in unit tests:
6. ASan removed, then restored
ASan (
-fsanitize=address -fno-omit-frame-pointerinCFLAGS/CCFLAGS,-lasanon theunit/s_unitlink targets) was temporarily removed toget a clean build/test signal while debugging the issues above, then
restored afterward. With ASan restored, compilation succeeds but linking
currently fails on the test machine used:
Please Test with asan lib on your system