fix: data race on a tracepoint's shared argument-type info (1.7.2)#38
Merged
Conversation
TSan (added in the sanitizer leg) intermittently caught a data race in get_argument_sizes: the one-time lazy init (first_time_check) mutates the tracepoint's shared static _clltk_types (type fixups, flex_size), and concurrent first callers of the same tracepoint raced on it. This is original code, not new - the sanitizer leg simply surfaced it, and it slipped past the branch CI because TSan detects races only probabilistically. Serialize the init under the global lock (a spinlock in the kernel) and publish with an acquire/release flag, so once warmed up the check stays a plain lock-free load. The init was already idempotent, so there is no behavior change. Also widen the live-stress drain window so its tail check is deterministic under CI load (was read == written - 1 on a slow runner). Signed-off-by: Jo5ta <jo5ta@mail.de>
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.
Follow-up to the sanitizer work (1.7.2).
The TSan leg intermittently flagged a data race in
get_argument_sizes:first_time_checklazily initializes each tracepoint's sharedstatic _clltk_typeson first use (type fixups intypes[],flex_size). When many threads hit the same tracepoint at once, several run that one-time init concurrently and race on it. This is original code — the sanitizer leg surfaced a latent race that had been present since the initial commit; it slipped past branch CI because TSan detects races only probabilistically.Fix: serialize the init under the global lock (a spinlock in the kernel) and publish with an acquire/release flag, so once warmed up the check is a plain lock-free load. The init was already idempotent, so no behavior change.
Also widens the live-stress drain window so its tail assertion is deterministic under CI load (occasionally
read == written - 1on a slow runner).Verified: normal ctest 680/680, full TSan suite 676/676 (including the race-triggering
read_parallel_overwhelmed), kernel module builds with the new sync usage inarguments.c.