Hello Nikos Nikoleris,

I'd like you to do a code review. Please visit

    https://gem5-review.googlesource.com/4287

to review the following change.


Change subject: kvm: Add a helper method to access device event queues
......................................................................

kvm: Add a helper method to access device event queues

The VM's event queue is normally used for devices in multi-core KVM
mode. Add a helper method, BaseKvmCPU::deviceEventQueue(), to access
this queue. This makes the intention of code migrating to device event
queues clearer.

Change-Id: Ifb10f553a6d7445c8d562f658cf9d0b1f4c577ff
Signed-off-by: Andreas Sandberg <andreas.sandb...@arm.com>
Reviewed-by: Nikos Nikoleris <nikos.nikole...@arm.com>
---
M src/cpu/kvm/base.cc
M src/cpu/kvm/base.hh
M src/cpu/kvm/x86_cpu.cc
3 files changed, 16 insertions(+), 8 deletions(-)



diff --git a/src/cpu/kvm/base.cc b/src/cpu/kvm/base.cc
index 6ea99ce..d0f7515 100644
--- a/src/cpu/kvm/base.cc
+++ b/src/cpu/kvm/base.cc
@@ -1147,10 +1147,9 @@
         delete pkt;
         return clockPeriod() * ipr_delay;
     } else {
-        // Temporarily lock and migrate to the event queue of the
-        // VM. This queue is assumed to "own" all devices we need to
-        // access if running in multi-core mode.
-        EventQueue::ScopedMigration migrate(vm.eventQueue());
+        // Temporarily lock and migrate to the device event queue to
+        // prevent races in multi-core mode.
+        EventQueue::ScopedMigration migrate(deviceEventQueue());

         return dataPort.submitIO(pkt);
     }
diff --git a/src/cpu/kvm/base.hh b/src/cpu/kvm/base.hh
index 29872e7..a22637f 100644
--- a/src/cpu/kvm/base.hh
+++ b/src/cpu/kvm/base.hh
@@ -419,6 +419,16 @@
     void syncThreadContext();

     /**
+     * Get a pointer to the event queue owning devices.
+     *
+     * Devices always live in a separate device event queue when
+     * running in multi-core mode. We need to temporarily migrate to
+     * this queue when accessing devices. By convention, devices and
+     * the VM use the same event queue.
+     */
+    EventQueue *deviceEventQueue() { return vm.eventQueue(); }
+
+    /**
      * Update the KVM if the thread context is dirty.
      */
     void syncKvmState();
diff --git a/src/cpu/kvm/x86_cpu.cc b/src/cpu/kvm/x86_cpu.cc
index bdbdadf..467e1ba 100644
--- a/src/cpu/kvm/x86_cpu.cc
+++ b/src/cpu/kvm/x86_cpu.cc
@@ -1346,10 +1346,9 @@
     }

     const MemCmd cmd(isWrite ? MemCmd::WriteReq : MemCmd::ReadReq);
-    // Temporarily lock and migrate to the event queue of the
-    // VM. This queue is assumed to "own" all devices we need to
-    // access if running in multi-core mode.
-    EventQueue::ScopedMigration migrate(vm.eventQueue());
+    // Temporarily lock and migrate to the device event queue to
+    // prevent races in multi-core mode.
+    EventQueue::ScopedMigration migrate(deviceEventQueue());
     for (int i = 0; i < count; ++i) {
         RequestPtr io_req = new Request(pAddr, kvm_run.io.size,
Request::UNCACHEABLE, dataMasterId());

--
To view, visit https://gem5-review.googlesource.com/4287
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifb10f553a6d7445c8d562f658cf9d0b1f4c577ff
Gerrit-Change-Number: 4287
Gerrit-PatchSet: 1
Gerrit-Owner: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Nikos Nikoleris <nikos.nikole...@arm.com>
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to