[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/9] qsp: add sort_by option to qsp_report
From: |
Emilio G. Cota |
Subject: |
[Qemu-devel] [PATCH 2/9] qsp: add sort_by option to qsp_report |
Date: |
Fri, 17 Aug 2018 01:18:46 -0400 |
Signed-off-by: Emilio G. Cota <address@hidden>
---
include/qemu/qsp.h | 8 +++++++-
util/qsp.c | 33 +++++++++++++++++++++++++++------
2 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/include/qemu/qsp.h b/include/qemu/qsp.h
index 9c2bb60ff0..209480b687 100644
--- a/include/qemu/qsp.h
+++ b/include/qemu/qsp.h
@@ -13,7 +13,13 @@
#include "qemu/fprintf-fn.h"
-void qsp_report(FILE *f, fprintf_function cpu_fprintf, size_t max);
+enum QSPSortBy {
+ QSP_SORT_BY_TOTAL_WAIT_TIME,
+ QSP_SORT_BY_AVG_WAIT_TIME,
+};
+
+void qsp_report(FILE *f, fprintf_function cpu_fprintf, size_t max,
+ enum QSPSortBy sort_by);
bool qsp_is_enabled(void);
void qsp_enable(void);
diff --git a/util/qsp.c b/util/qsp.c
index a02c925fe6..b04d4d9986 100644
--- a/util/qsp.c
+++ b/util/qsp.c
@@ -379,14 +379,34 @@ static gint qsp_tree_cmp(gconstpointer ap, gconstpointer
bp, gpointer up)
{
const QSPEntry *a = ap;
const QSPEntry *b = bp;
+ enum QSPSortBy sort_by = *(enum QSPSortBy *)up;
const QSPCallSite *ca;
const QSPCallSite *cb;
- if (a->ns > b->ns) {
- return -1;
- } else if (a->ns < b->ns) {
- return 1;
+ switch (sort_by) {
+ case QSP_SORT_BY_TOTAL_WAIT_TIME:
+ if (a->ns > b->ns) {
+ return -1;
+ } else if (a->ns < b->ns) {
+ return 1;
+ }
+ break;
+ case QSP_SORT_BY_AVG_WAIT_TIME:
+ {
+ double avg_a = a->n_acqs ? a->ns / a->n_acqs : 0;
+ double avg_b = b->n_acqs ? b->ns / b->n_acqs : 0;
+
+ if (avg_a > avg_b) {
+ return -1;
+ } else if (avg_a < avg_b) {
+ return 1;
+ }
+ break;
}
+ default:
+ g_assert_not_reached();
+ }
+
ca = a->callsite;
cb = b->callsite;
/* Break the tie with the object's address */
@@ -564,9 +584,10 @@ static void report_destroy(QSPReport *rep)
g_free(rep->entries);
}
-void qsp_report(FILE *f, fprintf_function cpu_fprintf, size_t max)
+void qsp_report(FILE *f, fprintf_function cpu_fprintf, size_t max,
+ enum QSPSortBy sort_by)
{
- GTree *tree = g_tree_new_full(qsp_tree_cmp, NULL, g_free, NULL);
+ GTree *tree = g_tree_new_full(qsp_tree_cmp, &sort_by, g_free, NULL);
QSPReport rep;
qsp_init();
--
2.17.1
- [Qemu-devel] [PATCH v2 0/9] synchronization profiler, Emilio G. Cota, 2018/08/17
- [Qemu-devel] [PATCH 7/9] vl: add -enable-sync-profile, Emilio G. Cota, 2018/08/17
- [Qemu-devel] [PATCH 2/9] qsp: add sort_by option to qsp_report,
Emilio G. Cota <=
- [Qemu-devel] [PATCH 5/9] qsp: track BQL callers explicitly, Emilio G. Cota, 2018/08/17
- [Qemu-devel] [PATCH 6/9] tests/atomic_add-bench: add -p to enable sync profiler, Emilio G. Cota, 2018/08/17
- [Qemu-devel] [PATCH 3/9] qsp: add qsp_reset, Emilio G. Cota, 2018/08/17
- [Qemu-devel] [PATCH 9/9] hmp-commands-info: add sync-profile, Emilio G. Cota, 2018/08/17
- [Qemu-devel] [PATCH 8/9] hmp-commands: add sync-profile, Emilio G. Cota, 2018/08/17
- [Qemu-devel] [PATCH 4/9] qsp: support call site coalescing, Emilio G. Cota, 2018/08/17
- [Qemu-devel] [PATCH 1/9] qsp: QEMU's Synchronization Profiler, Emilio G. Cota, 2018/08/17