Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the instruction tracing subsystem. #168

Open
wants to merge 74 commits into
base: dev
Choose a base branch
from

Conversation

qwattash
Copy link
Contributor

Add tracing backend based on the google perfetto tracing framework.
Add the ability to aggregate statistics within qemu and emit them as part of the perfetto backend.
Add support for generic events associated to instructions.
Add better support for trace filters for each log entry.

configure Outdated Show resolved Hide resolved
Copy link
Member

@arichardson arichardson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generally looks fine to me (only skimmed most of the commits though). Since it's off by default it shouldn't really matter that we pull in boost.

accel/tcg/log_instr.c Outdated Show resolved Hide resolved
include/exec/log_instr.h Outdated Show resolved Hide resolved
target/riscv/op_helper_log_instr.c Outdated Show resolved Hide resolved
stats/meson.build Outdated Show resolved Hide resolved
@qwattash qwattash changed the base branch from qemu-cheri to dev November 20, 2021 00:56
@qwattash qwattash force-pushed the qemu-experimental-tracing branch 2 times, most recently from b0cd6a4 to 9b1e0ee Compare April 26, 2022 19:43
@qwattash qwattash force-pushed the qemu-experimental-tracing branch 2 times, most recently from 7bd5a53 to f7417a1 Compare August 18, 2022 14:21
- Rename cpu_log_instr_info to cpu_log_entry.
The -dfilter qemu option has ad-hoc support within TCG instruction tracing,
this generalizes the trace filtering to an arbitrary per-CPU set of functions
that can filter the trace entry based on any parameter.
Note that for now filters are assumed to be stateless.
Each trace format is moved to a separate file for implementation.
This backend is intended to capture statistics from the instructions
instead of dumping the whole instruction stream.
Note that this is disabled by default in the configuration as it adds
a dependency on libboost.
- Add cheri-perfetto submodule for tracing.
- Plumb the perfetto tracing backend in the build system
- Add initialization code that registers the tracing categories and starts
  the tracing service at startup
- Add skeleton for the perfetto tracing backend glue code
- Add command line option to select filters to use.
- Make sure that the filters from command line are applied to the CPUs at
  initialization.
- Add filter to only emit entries containing events.
For each CPU we create 2 tracks: one for control events (e.g. tracing
start/stop) and another for log events on that CPU.
Currently we emit instructions and stats events on the CPU track.

- Replace the stats backend with a tracing category in the perfetto backend
- Add new CLI options to control the perfetto backend behaviour:
  1. --cheri-trace-perfetto-categories comma-separated list of categories to
     enable.
  2. --cheri-trace-perfetto-logfile log file to use for the perfetto binary
     trace. We do not use the common qemu logfile to avoid accidental pollution
     and passing the qemu file descriptor is painful due to having to lock the
     logfile via RCU.
- Add hook at qemu shutdown to make sure we flush the log buffers, if the
  tracing backend supports this.
Flush TrackEvent data source when we receive a FLUSH event in the instruction
logging subsystem. This helps making sure that we do not have lost events when
running multiple tests on qemu.
qwattash and others added 20 commits January 30, 2023 22:20
Remove the event variant that bypasses log enable. This is useless as
switching on/off tracing around the event is feasible and the event is
rare enough that it is not a performance issue.
Add NOP that guests can use to create and increment/decrement
counters.
The counters are emitted into the perfetto trace stream as normal
perfetto counter tracks.
These are still not hooked to the guest NOPs.
Replace the stats implementation with a new one based on the
cheri-perfetto interval tracks.
The stats implementation tracks basic block icount and hits, along
with branches. Now there are multiple categories for each different
statistic instead of a grouped one.
This works around the inability to use bytes fields in perfetto
track event messages.
This was essentially unused, and can be replicated during initialization.
Add two counters to measure instruction count when tracing is enabled/disabled.
Only maintain the branch and basic block hit histograms when
the corresponding trace categories are enabled.
This should not be needed because we have flags marking TBs whenever
they contain instruction tracing instrumentation.
This is broken by recent liburing versions.
Add disas_one_strbuf() to disassemble one instruction to an existing
string buffer.
Add disas_one_str() to disassemble one instruction to a dynamically
allocated string.
- Conditionally compile cvtrace
- This is done because some of these backends emit binary data that
  is logically incompatible with the standard qemu output file.
  The downside is the we need to handle our own locking if we
  want to support multiple CPUs.
This should help to inform log backends for management purposes.
This is better than instr_info as it reflects its use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants