qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

qsp: Simplify how qsp_report() prints

qsp_report() takes an fprintf()-like callback and a FILE * to pass to
it.

Its only caller hmp_sync_profile() passes monitor_fprintf() and the
current monitor cast to FILE *. monitor_fprintf() casts it right
back, and is otherwise identical to monitor_printf(). The
type-punning is ugly.

Drop the callback, and call qemu_printf() instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190417191805.28198-7-armbru@redhat.com>

+15 -15
+1
include/block/qapi.h
··· 27 27 28 28 #include "block/block.h" 29 29 #include "block/snapshot.h" 30 + #include "qemu/fprintf-fn.h" 30 31 31 32 BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, 32 33 BlockDriverState *bs, Error **errp);
+2 -4
include/qemu/qsp.h
··· 11 11 #ifndef QEMU_QSP_H 12 12 #define QEMU_QSP_H 13 13 14 - #include "qemu/fprintf-fn.h" 15 - 16 14 enum QSPSortBy { 17 15 QSP_SORT_BY_TOTAL_WAIT_TIME, 18 16 QSP_SORT_BY_AVG_WAIT_TIME, 19 17 }; 20 18 21 - void qsp_report(FILE *f, fprintf_function cpu_fprintf, size_t max, 22 - enum QSPSortBy sort_by, bool callsite_coalesce); 19 + void qsp_report(size_t max, enum QSPSortBy sort_by, 20 + bool callsite_coalesce); 23 21 24 22 bool qsp_is_enabled(void); 25 23 void qsp_enable(void);
+1 -1
monitor.c
··· 1336 1336 enum QSPSortBy sort_by; 1337 1337 1338 1338 sort_by = mean ? QSP_SORT_BY_AVG_WAIT_TIME : QSP_SORT_BY_TOTAL_WAIT_TIME; 1339 - qsp_report((FILE *)mon, monitor_fprintf, max, sort_by, coalesce); 1339 + qsp_report(max, sort_by, coalesce); 1340 1340 } 1341 1341 1342 1342 static void hmp_info_history(Monitor *mon, const QDict *qdict)
+11 -10
util/qsp.c
··· 56 56 * Critical-Section Execution to Improve the Performance of Multithreaded 57 57 * Applications", USENIX ATC'12. 58 58 */ 59 + 59 60 #include "qemu/osdep.h" 61 + #include "qemu/qemu-print.h" 60 62 #include "qemu/thread.h" 61 63 #include "qemu/timer.h" 62 64 #include "qemu/qht.h" ··· 678 680 return FALSE; 679 681 } 680 682 681 - static void 682 - pr_report(const QSPReport *rep, FILE *f, fprintf_function pr) 683 + static void pr_report(const QSPReport *rep) 683 684 { 684 685 char *dashes; 685 686 size_t max_len = 0; ··· 702 703 /* white space to leave to the right of "Call site" */ 703 704 callsite_rspace = callsite_len - strlen("Call site"); 704 705 705 - pr(f, "Type Object Call site%*s Wait Time (s) " 706 - " Count Average (us)\n", callsite_rspace, ""); 706 + qemu_printf("Type Object Call site%*s Wait Time (s) " 707 + " Count Average (us)\n", callsite_rspace, ""); 707 708 708 709 /* build a horizontal rule with dashes */ 709 710 n_dashes = 79 + callsite_rspace; 710 711 dashes = g_malloc(n_dashes + 1); 711 712 memset(dashes, '-', n_dashes); 712 713 dashes[n_dashes] = '\0'; 713 - pr(f, "%s\n", dashes); 714 + qemu_printf("%s\n", dashes); 714 715 715 716 for (i = 0; i < rep->n_entries; i++) { 716 717 const QSPReportEntry *e = &rep->entries[i]; ··· 726 727 e->callsite_at, 727 728 callsite_len - (int)strlen(e->callsite_at), "", 728 729 e->time_s, e->n_acqs, e->ns_avg * 1e-3); 729 - pr(f, "%s", s->str); 730 + qemu_printf("%s", s->str); 730 731 g_string_free(s, TRUE); 731 732 } 732 733 733 - pr(f, "%s\n", dashes); 734 + qemu_printf("%s\n", dashes); 734 735 g_free(dashes); 735 736 } 736 737 ··· 746 747 g_free(rep->entries); 747 748 } 748 749 749 - void qsp_report(FILE *f, fprintf_function cpu_fprintf, size_t max, 750 - enum QSPSortBy sort_by, bool callsite_coalesce) 750 + void qsp_report(size_t max, enum QSPSortBy sort_by, 751 + bool callsite_coalesce) 751 752 { 752 753 GTree *tree = g_tree_new_full(qsp_tree_cmp, &sort_by, g_free, NULL); 753 754 QSPReport rep; ··· 762 763 g_tree_foreach(tree, qsp_tree_report, &rep); 763 764 g_tree_destroy(tree); 764 765 765 - pr_report(&rep, f, cpu_fprintf); 766 + pr_report(&rep); 766 767 report_destroy(&rep); 767 768 } 768 769