← Back to Pull requests

perf(cws): Record v2 syscall samples in a per-process bitmap #58897

Closed
unknown closed this pull request without merging on Oct 29, 2026 00:06 UTC
View on GitHub
unknown unknown commented on Oct 26, 2026 16:23 UTC
Author

What does this PR do?


Reworks the Profiles v2 syscall sampler: a dedicated sys_enter_syscall_usage program sets the syscall's bit in a per-process bitmap, and a 1 Hz ticker plus the exec/exit hooks send one EVENT_SYSCALLS per process. This replaces the per-(process, syscall) map, rate limiter, ignored syscalls list and refresh events of #54996.
  • The sampler runs when syscalls is in security_profile.v2.event_types (the default). The event_sampling.syscalls settings are removed.

  • security_profile.v2.max_syscalls_events_per_second (default 1024) caps the ticker sends. Syscalls not sent because of the cap or a dropped event are kept for the next tick.

  • Needs bpf_for_each_map_elem (5.13+, 5.17+ on arm64), and turns itself off on older kernels.
  • Motivation


    With the #54996 sampler, sys_enter costs ~600ns per syscall (redis -21%). Tradeoffs: new syscalls reach userspace 1-2s later, a send racing with a first use can drop a bit (no atomics), and the map takes ~4.2MB on 16 CPUs (256B per process, 4 cache lines) instead of ~1.8MB.

    Describe how you validated your changes


  • Benchmark (5 runs per variant, on 67d67dc1b75): vs #54996, sys_enter is 5-6x cheaper per call and redis +17%. Vs sampling off: +145ns per syscall, redis -7.5%, postgres -3.5%, nginx -1.2%.

  • Functional tests: TestWorkloadProfileDedicatedSyscallsReporting (while running, on exec, refresh) and TestWorkloadProfileDedicatedSyscalls (on exit). Baloum tests: TestSyscallUsageRecord, TestSyscallUsageExcluded.

  • Manually checked that the ticker loads on 6.8 arm64 (6.7+ verifiers check the bpf_for_each_map_elem callback as a loop, so the ticker keeps its send counter in a map).
  • Additional Notes


    The activity dump / drift monitor in sys_enter only runs when enabled (the kill fallback is kept). The ticker cap and the re-queue of dropped events have no test: baloum doesn't support bpf_for_each_map_elem.

    Diff: 241 lines (+180 / -61) across 3 files Reviewer: mftoure Review duration: 3342m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 241 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.328
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #58897"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 38.8% (MEDIUM) · Higher = larger blast radius
    38.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.3% · Safe to merge
    15.3%