[guest][vmm] Trace device interrupts
Trace interrupt requests from virtual devices across process boundaries.
Test: Ran "fx traceutil" with "zircon-guest".
Change-Id: I6af7f69ce5b54cba26833fd6f9e9f8dca83fa5fb
diff --git a/bin/guest/vmm/device/BUILD.gn b/bin/guest/vmm/device/BUILD.gn
index c5023a0..6e56a2b 100644
--- a/bin/guest/vmm/device/BUILD.gn
+++ b/bin/guest/vmm/device/BUILD.gn
@@ -31,6 +31,7 @@
"//garnet/lib/machina/device",
"//garnet/lib/machina/fidl:fuchsia.guest.device",
"//garnet/public/lib/component/cpp",
+ "//garnet/public/lib/fsl",
"//zircon/public/lib/async-loop-cpp",
"//zircon/public/lib/fs",
"//zircon/public/lib/trace-provider",
diff --git a/bin/guest/vmm/device/device_base.h b/bin/guest/vmm/device/device_base.h
index bfbca59..f7d221b 100644
--- a/bin/guest/vmm/device/device_base.h
+++ b/bin/guest/vmm/device/device_base.h
@@ -10,6 +10,8 @@
#include <lib/async/default.h>
#include <lib/component/cpp/startup_context.h>
#include <lib/fidl/cpp/binding_set.h>
+#include <lib/fsl/handles/object_info.h>
+#include <trace/event.h>
#include <zx/event.h>
#include "garnet/lib/machina/device/config.h"
@@ -31,6 +33,7 @@
fidl::BindingSet<T> bindings_;
zx_gpaddr_t trap_addr_;
zx::event event_;
+ zx_koid_t event_koid_;
machina::PhysMem phys_mem_;
async::GuestBellTrapMethod<DeviceBase, &DeviceBase::OnQueueNotify> trap_{
this};
@@ -45,6 +48,7 @@
FXL_CHECK(!event_) << "Device has already been started";
event_ = std::move(start_info.event);
+ event_koid_ = fsl::GetKoid(event_.get());
zx_status_t status = phys_mem_.Init(std::move(start_info.vmo));
FXL_CHECK(status == ZX_OK)
<< "Failed to init guest physical memory " << status;
@@ -59,6 +63,7 @@
// Signals an interrupt for the device.
zx_status_t Interrupt(uint8_t actions) {
+ TRACE_FLOW_BEGIN("machina", "device:interrupt", event_koid_);
return event_.signal(0, static_cast<zx_signals_t>(actions)
<< machina::kDeviceInterruptShift);
}
diff --git a/lib/machina/virtio_device.h b/lib/machina/virtio_device.h
index e4f41cf..04ec3f3 100644
--- a/lib/machina/virtio_device.h
+++ b/lib/machina/virtio_device.h
@@ -8,6 +8,7 @@
#include <atomic>
#include <fuchsia/guest/device/cpp/fidl.h>
+#include <lib/fsl/handles/object_info.h>
#include <trace-engine/types.h>
#include <trace/event.h>
@@ -204,6 +205,7 @@
std::move(ready_device)) {
zx_status_t status = zx::event::create(0, &event_);
FXL_CHECK(status == ZX_OK) << "Failed to create event";
+ event_koid_ = fsl::GetKoid(event_.get());
wait_.set_object(event_.get());
wait_.set_trigger(ZX_USER_SIGNAL_ALL);
}
@@ -248,6 +250,7 @@
if (status != ZX_OK) {
return;
}
+ TRACE_FLOW_END("machina", "device:interrupt", event_koid_);
status = event_.signal(signal->trigger, 0);
if (status != ZX_OK) {
FXL_LOG(ERROR) << "Failed to clear interrupt signal " << status;
@@ -265,6 +268,7 @@
}
zx::event event_;
+ zx_koid_t event_koid_;
async::WaitMethod<VirtioComponentDevice, &VirtioComponentDevice::OnInterrupt>
wait_{this};
};