[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 10 of 10] xenalyze: add a batch-size plugin



The batch-size plugin produces a histogram of the different counts in
some of the hypercalls (multical and mmu_update).  This can be useful
to see if different guest kernels are less efficient at batching
hypercalls.

Signed-off-by: David Vrabel <david.vrabel@xxxxxxxxxx>

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,7 @@ xenalyze_OBJS := \
        mread.o \
        plugin.o \
        xenalyze.o \
+       plugins/batch-size.o \
        plugins/skeleton.o
 
 dump-raw_OBJS := \
diff --git a/plugins/batch-size.cc b/plugins/batch-size.cc
new file mode 100644
--- /dev/null
+++ b/plugins/batch-size.cc
@@ -0,0 +1,73 @@
+/*
+ * Hypercall batch size xenalyze plugin.
+ *
+ * Copyright (C) 2012, Citrix Systems R&D Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This plugin produces a histogram of the batch sizes of some of the
+ * hypercalls. Specifically:
+ *
+ *   - number of calls in a multicall.
+ *   - number of updates in a mmu_update.
+ */
+#include <stdio.h>
+#include <map>
+
+#include "plugin.hh"
+#include "pv.h"
+#include "trace.h"
+
+class batch_size_plugin : xenalyze_plugin {
+public:
+    batch_size_plugin() {}
+    ~batch_size_plugin() {}
+
+    void process(const struct record_info *ri);
+    void summary();
+
+private:
+    std::map<int, int> multicall;
+    std::map<int, int> mmu_update;
+};
+
+void batch_size_plugin::process(const struct record_info *ri)
+{
+    uint32_t count;
+
+    if (ri->event == TRC_PV_HYPERCALL_V2) {
+        switch (pv_hypercall_op(ri)) {
+        case 1: /* mmu_update */
+            count = pv_hypercall_arg(ri, 1) & ~MMU_UPDATE_PREEMPTED;
+            mmu_update[count]++;
+            break;
+        case 13: /* multicall */
+            count = pv_hypercall_arg(ri, 1);
+            multicall[count]++;
+            break;
+        }
+    }
+}
+
+static void summarize(const char *name, std::map<int, int> &call)
+{
+    int calls = 0, batches = 0;
+
+    printf("  %s:\n    Size  Count\n", name);
+    for (auto i = call.begin(); i != call.end(); i++) {
+        printf("    %-4d  %d\n", i->first, i->second);
+        calls += i->first * i->second;
+        batches += i->second;
+    }
+    printf("    Average %.1f\n",  (double)calls / (double)batches);
+}
+
+void batch_size_plugin::summary()
+{
+    summarize("multicall", multicall);
+    summarize("mmu_update", mmu_update);
+}
+
+DEFINE_CXX_PLUGIN("batch-size", batch_size_plugin);

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.