This is an archive of the discontinued LLVM Phabricator instance.

[trace][intelpt] Support system-wide tracing [5] - Disable/enable per-core tracing based on the process state
ClosedPublic

Authored by wallace on May 4 2022, 1:48 PM.

Details

Summary

When tracing on per-core mode, we are tracing all processes, which means
that after hitting a breakpoint, our process will stop running (thus
producing no more tracing data) but other processes will continue
writing to our trace buffers. This causes a big data loss for our trace.
As a way to remediate this, I'm adding some logic to pause and unpause
tracing based on the target's state. The earlier we do it the better,
however, I'm not adding the trigger at the earliest possible point for
simplicity of this diff. Later we can improve that part.

Diff Detail

Event Timeline

wallace created this revision.May 4 2022, 1:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2022, 1:48 PM
wallace requested review of this revision.May 4 2022, 1:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2022, 1:48 PM
wallace updated this revision to Diff 427448.May 5 2022, 2:21 PM

add better error handling

jj10306 added inline comments.May 10 2022, 9:33 AM
lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
271

What's the purpose of this new flush flag? When would you want to call this method with it set to false? I can only think of cases when you want to flush the buffer if you're trying to read its data

lldb/source/Plugins/Process/Linux/Perf.h
221–227

Nice, happy to see we are extending the mini perf API (:
In the future we also can update this to control whether or not the event is enabled at perf_event_open time because that's the default but there may be cases where you don't want the event to be enabled until you explicitly enable it w ioctl

wallace added inline comments.May 11 2022, 9:17 AM
lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
271

This is nonsense, I shouldn't have created this flag =P

lldb/source/Plugins/Process/Linux/Perf.h
221–227

that's a good idea. I think I'll do it now

wallace updated this revision to Diff 428695.May 11 2022, 9:29 AM
  • remove the flush parameter
  • use perf_event_attr.disabled to set the initial state of the collection
jj10306 accepted this revision.May 17 2022, 11:41 AM
jj10306 added inline comments.
lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
211

nit: from the "Set" name, my first impression was this method was simply setting m_collection_state, but in reality it's doing some nontrivial operations, namely changing the state of the perf event via ioctl. Consider changing the name from "Set" to avoid giving the impression of a trivial operation

309

nice

This revision is now accepted and ready to land.May 17 2022, 11:41 AM