Page MenuHomeFreeBSD

hwpmc(4): stop overwalking past _start on amd64 user callchains
ClosedPublic

Authored by nickbanks_netflix.com on Thu, Aug 27, 7:32 PM.
Tags
None
Referenced Files
F170684893: D59229.diff
Sun, Sep 6, 12:41 AM
F170679752: D59229.id185238.diff
Sun, Sep 6, 12:03 AM
F170671441: D59229.id185238.diff
Sat, Sep 5, 10:56 PM
F170649616: D59229.id.diff
Sat, Sep 5, 7:44 PM
F170630311: D59229.id185628.diff
Sat, Sep 5, 5:36 PM
F170601398: D59229.id.diff
Sat, Sep 5, 2:30 PM
F170567658: D59229.id185238.diff
Sat, Sep 5, 10:59 AM
F170566053: D59229.diff
Sat, Sep 5, 10:50 AM
Subscribers

Details

Summary

pmc_save_user_callchain() emits the pc it just loaded before checking
whether fp is the ABI's zero frame-chain terminator. At the bottom of
a well-formed chain under _start, fp comes back 0 as expected, but the
paired pc is stale rtld data left on the stack -- a legal userspace VA
that still passes PMC_IN_USERSPACE(), so it gets emitted as a bogus
extra frame. This shows up in flame graphs as a spurious hex-valued
root frame below _start.

Check fp == 0 alongside the existing checks before emitting, matching
how arm/arm64/powerpc already load the next fp before their check.

Measured via 1kHz hwpmc sampling on an OCA: stacks with any unresolved
hex frame drop from 23.9% to 1.3%, and stacks with hex at the root drop
from 5.5% to 0.3%.

Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 76228
Build 73111: arc lint + arc unit