Skip to content

Commit 9385541

Browse files
authored
reporter: emit CUDA PC-sample frames (cuda-pc) for per-function symbolization (#3186)
Add the CUDAPCFrame case to both location-writer paths (appendLocationV2 and the V1 record path): one mapping per cubin (build_id = cubin CRC FileID), the kernel's mangled name as the system name of a placeholder line (line 0, no function name), and the "cuda-pc" frame type. The backend resolves the source line per function off the kernel name. The stall reason and SASS instruction arrive as the cuda_stall_reason / cuda_sass_instruction sample labels (trace.CustomLabels, handled generically), independent of the frame. Bumps the ebpf-profiler fork to pick up libpf.CUDAPCFrame and the single-frame GPU PC-sample emission (parca-dev/opentelemetry-ebpf-profiler#300). Pinned to a main commit pending a tagged release.
1 parent 0b51e14 commit 9385541

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

reporter/parca_reporter.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,32 @@ func (r *ParcaReporter) appendLocationV2(frame libpf.Frame) uint32 {
614614
StartLine: 0,
615615
}))
616616

617+
case libpf.CUDAPCFrame:
618+
// CUDA PC sample: a function-relative kernel offset. One mapping per
619+
// cubin (build ID = cubin CRC FileID, never a per-function ID). The
620+
// kernel's mangled name rides as the system name of a placeholder line
621+
// (line 0); the backend resolves the real source line per function,
622+
// gated downstream on the "cuda-pc" frame type.
623+
b.locFrameType.AppendString(frame.Type.String())
624+
625+
var fid libpf.FileID
626+
if frame.Mapping.Valid() {
627+
mf := frame.Mapping.Value().File.Value()
628+
fid = mf.FileID
629+
b.locMappingFile.AppendString(mf.FileName.String())
630+
} else {
631+
b.locMappingFile.AppendNull()
632+
}
633+
b.locMappingID.AppendString(fid.StringNoQuotes())
634+
635+
b.lineNumber.Append(0)
636+
b.lineColumn.Append(0)
637+
b.funcIndices.Append(b.funcDict.AppendFunction(FunctionV2{
638+
SystemName: frame.FunctionName.String(),
639+
Filename: "",
640+
StartLine: 0,
641+
}))
642+
617643
case oomprofMemoryFrame:
618644
b.locFrameType.AppendString(libpf.NativeFrame.String())
619645
b.locMappingFile.AppendString(frame.SourceFile.String())
@@ -1792,6 +1818,32 @@ func (r *ParcaReporter) buildStacktraceRecord(ctx context.Context, stacktraceIDs
17921818
w.FunctionSystemName.AppendString("")
17931819
w.MappingFile.AppendString("[kernel.kallsyms]")
17941820
w.FunctionStartLine.Append(0)
1821+
case libpf.CUDAPCFrame:
1822+
// CUDA PC sample: one mapping per cubin (build_id = cubin CRC
1823+
// FileID). The kernel's mangled name rides as the system name of a
1824+
// placeholder line (line 0, no function name); the backend resolves
1825+
// the source line per function, gated on the "cuda-pc" frame type.
1826+
w.FrameType.AppendString(frame.Type.String())
1827+
1828+
var fid libpf.FileID
1829+
if frame.Mapping.Valid() {
1830+
mf := frame.Mapping.Value().File.Value()
1831+
fid = mf.FileID
1832+
w.MappingFile.AppendString(mf.FileName.String())
1833+
} else {
1834+
w.MappingFile.AppendNull()
1835+
}
1836+
w.MappingBuildID.AppendString(fid.StringNoQuotes())
1837+
1838+
w.Lines.Append(true)
1839+
w.Line.Append(true)
1840+
w.LineNumber.Append(0)
1841+
w.ColumnNumber.Append(0)
1842+
w.FunctionName.AppendNull()
1843+
w.FunctionSystemName.AppendString(frame.FunctionName.String())
1844+
w.FunctionFilename.AppendNull()
1845+
w.FunctionStartLine.Append(0)
1846+
17951847
case oomprofMemoryFrame:
17961848
// This is a special frame that is used to report OOMProf samples.
17971849
w.FrameType.AppendString(libpf.NativeFrame.String())

0 commit comments

Comments
 (0)