gfio: move disk utilization to a private tab in per-client results
authorJens Axboe <axboe@kernel.dk>
Thu, 15 Mar 2012 12:45:02 +0000 (13:45 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 15 Mar 2012 12:45:02 +0000 (13:45 +0100)
The disk util results are shared for all clients, so it's more
appropriate to put it in a tab.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
gfio.c

diff --git a/gfio.c b/gfio.c
index 7dcb18822db81516830fd2def5c0865be5190fb1..3ed5528bcf04653dcee6714f9d93eac466bee219 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -157,11 +157,11 @@ struct gui_entry {
        GtkWidget *notebook;
        GtkWidget *error_info_bar;
        GtkWidget *error_label;
        GtkWidget *notebook;
        GtkWidget *error_info_bar;
        GtkWidget *error_label;
-       GtkWidget *results_notebook;
        GtkWidget *results_window;
        GtkWidget *results_window;
+       GtkWidget *results_notebook;
        GtkUIManager *results_uimanager;
        GtkUIManager *results_uimanager;
-       GtkWidget *results_vbox;
        GtkWidget *results_menu;
        GtkWidget *results_menu;
+       GtkWidget *disk_util_vbox;
        GtkListStore *log_model;
        GtkWidget *log_tree;
        GtkWidget *log_view;
        GtkListStore *log_model;
        GtkWidget *log_tree;
        GtkWidget *log_view;
@@ -188,14 +188,15 @@ struct end_results {
 struct gfio_client {
        struct gui_entry *ge;
        struct fio_client *client;
 struct gfio_client {
        struct gui_entry *ge;
        struct fio_client *client;
-       GtkWidget *results_widget;
-       GtkWidget *disk_util_vbox;
        GtkWidget *err_entry;
        unsigned int job_added;
        struct thread_options o;
 
        struct end_results *results;
        unsigned int nr_results;
        GtkWidget *err_entry;
        unsigned int job_added;
        struct thread_options o;
 
        struct end_results *results;
        unsigned int nr_results;
+
+       struct cmd_du_pdu *du;
+       unsigned int nr_du;
 };
 
 static void gfio_update_thread_status(struct gui_entry *ge, char *status_message, double perc);
 };
 
 static void gfio_update_thread_status(struct gui_entry *ge, char *status_message, double perc);
@@ -1247,6 +1248,110 @@ static GtkWidget *get_results_window(struct gui_entry *ge)
        return ge->results_notebook;
 }
 
        return ge->results_notebook;
 }
 
+static void disk_util_destroy(GtkWidget *w, gpointer data)
+{
+       struct gui_entry *ge = (struct gui_entry *) data;
+
+       ge->disk_util_vbox = NULL;
+       gtk_widget_destroy(w);
+}
+
+static int __gfio_disk_util_show(GtkWidget *res_notebook,
+                                struct gfio_client *gc, struct cmd_du_pdu *p)
+{
+       GtkWidget *box, *frame, *entry, *vbox;
+       struct gui_entry *ge = gc->ge;
+       double util;
+       char tmp[16];
+
+       res_notebook = get_results_window(ge);
+
+       if (!ge->disk_util_vbox) {
+               vbox = gtk_vbox_new(FALSE, 3);
+               gtk_notebook_append_page(GTK_NOTEBOOK(res_notebook), vbox, gtk_label_new("Disk utilization"));
+               ge->disk_util_vbox = vbox;
+               g_signal_connect(vbox, "destroy", G_CALLBACK(disk_util_destroy), ge);
+       }
+
+       vbox = gtk_vbox_new(FALSE, 3);
+       gtk_container_add(GTK_CONTAINER(ge->disk_util_vbox), vbox);
+
+       frame = gtk_frame_new((char *) p->dus.name);
+       gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 2);
+
+       box = gtk_vbox_new(FALSE, 3);
+       gtk_container_add(GTK_CONTAINER(frame), box);
+
+       frame = gtk_frame_new("Read");
+       gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2);
+       vbox = gtk_hbox_new(TRUE, 3);
+       gtk_container_add(GTK_CONTAINER(frame), vbox);
+       entry = new_info_entry_in_frame(vbox, "IOs");
+       entry_set_int_value(entry, p->dus.ios[0]);
+       entry = new_info_entry_in_frame(vbox, "Merges");
+       entry_set_int_value(entry, p->dus.merges[0]);
+       entry = new_info_entry_in_frame(vbox, "Sectors");
+       entry_set_int_value(entry, p->dus.sectors[0]);
+       entry = new_info_entry_in_frame(vbox, "Ticks");
+       entry_set_int_value(entry, p->dus.ticks[0]);
+
+       frame = gtk_frame_new("Write");
+       gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2);
+       vbox = gtk_hbox_new(TRUE, 3);
+       gtk_container_add(GTK_CONTAINER(frame), vbox);
+       entry = new_info_entry_in_frame(vbox, "IOs");
+       entry_set_int_value(entry, p->dus.ios[1]);
+       entry = new_info_entry_in_frame(vbox, "Merges");
+       entry_set_int_value(entry, p->dus.merges[1]);
+       entry = new_info_entry_in_frame(vbox, "Sectors");
+       entry_set_int_value(entry, p->dus.sectors[1]);
+       entry = new_info_entry_in_frame(vbox, "Ticks");
+       entry_set_int_value(entry, p->dus.ticks[1]);
+
+       frame = gtk_frame_new("Shared");
+       gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2);
+       vbox = gtk_hbox_new(TRUE, 3);
+       gtk_container_add(GTK_CONTAINER(frame), vbox);
+       entry = new_info_entry_in_frame(vbox, "IO ticks");
+       entry_set_int_value(entry, p->dus.io_ticks);
+       entry = new_info_entry_in_frame(vbox, "Time in queue");
+       entry_set_int_value(entry, p->dus.time_in_queue);
+
+       util = 0.0;
+       if (p->dus.msec)
+               util = (double) 100 * p->dus.io_ticks / (double) p->dus.msec;
+       if (util > 100.0)
+               util = 100.0;
+
+       sprintf(tmp, "%3.2f%%", util);
+       entry = new_info_entry_in_frame(vbox, "Disk utilization");
+       gtk_entry_set_text(GTK_ENTRY(entry), tmp);
+
+       gtk_widget_show_all(ge->results_window);
+       return 0;
+}
+
+static int gfio_disk_util_show(struct gfio_client *gc)
+{
+       struct gui_entry *ge = gc->ge;
+       GtkWidget *res_notebook;
+       int i;
+
+       if (!gc->nr_du)
+               return 1;
+
+       res_notebook = get_results_window(ge);
+
+       for (i = 0; i < gc->nr_du; i++) {
+               struct cmd_du_pdu *p = &gc->du[i];
+
+               __gfio_disk_util_show(res_notebook, gc, p);
+       }
+
+       gtk_widget_show_all(ge->results_window);
+       return 0;
+}
+
 static void gfio_add_end_results(struct gfio_client *gc, struct thread_stat *ts,
                                 struct group_run_stats *rs)
 {
 static void gfio_add_end_results(struct gfio_client *gc, struct thread_stat *ts,
                                 struct group_run_stats *rs)
 {
@@ -1277,8 +1382,6 @@ static void __gfio_display_end_results(GtkWidget *win, struct gfio_client *gc,
 
        gtk_notebook_append_page(GTK_NOTEBOOK(win), scroll, gtk_label_new(ts->name));
 
 
        gtk_notebook_append_page(GTK_NOTEBOOK(win), scroll, gtk_label_new(ts->name));
 
-       gc->results_widget = vbox;
-
        entry = new_info_entry_in_frame(box, "Name");
        gtk_entry_set_text(GTK_ENTRY(entry), ts->name);
        if (strlen(ts->description)) {
        entry = new_info_entry_in_frame(box, "Name");
        gtk_entry_set_text(GTK_ENTRY(entry), ts->name);
        if (strlen(ts->description)) {
@@ -1318,7 +1421,8 @@ static void gfio_display_end_results(struct gfio_client *gc)
                __gfio_display_end_results(res_notebook, gc, &e->ts, &e->gs);
        }
 
                __gfio_display_end_results(res_notebook, gc, &e->ts, &e->gs);
        }
 
-       gtk_widget_show_all(ge->results_window);
+       if (gfio_disk_util_show(gc))
+               gtk_widget_show_all(ge->results_window);
 }
 
 static void gfio_display_ts(struct fio_client *client, struct thread_stat *ts,
 }
 
 static void gfio_display_ts(struct fio_client *client, struct thread_stat *ts,
@@ -1365,79 +1469,14 @@ static void gfio_disk_util_op(struct fio_client *client, struct fio_net_cmd *cmd
 {
        struct cmd_du_pdu *p = (struct cmd_du_pdu *) cmd->payload;
        struct gfio_client *gc = client->client_data;
 {
        struct cmd_du_pdu *p = (struct cmd_du_pdu *) cmd->payload;
        struct gfio_client *gc = client->client_data;
-       GtkWidget *box, *frame, *entry, *vbox;
-       double util;
-       char tmp[16];
+       unsigned int nr = gc->nr_du;
 
 
-       gdk_threads_enter();
-
-       if (!gc->results_widget)
-               goto out;
+       gc->du = realloc(gc->du, (nr + 1) * sizeof(struct cmd_du_pdu));
+       memcpy(&gc->du[nr], p, sizeof(*p));
+       gc->nr_du++;
 
 
-       if (!gc->disk_util_vbox) {
-               frame = gtk_frame_new("Disk utilization");
-               gtk_box_pack_start(GTK_BOX(gc->results_widget), frame, FALSE, FALSE, 5);
-               vbox = gtk_vbox_new(FALSE, 3);
-               gtk_container_add(GTK_CONTAINER(frame), vbox);
-               gc->disk_util_vbox = vbox;
-       }
-
-       vbox = gtk_vbox_new(FALSE, 3);
-       gtk_container_add(GTK_CONTAINER(gc->disk_util_vbox), vbox);
-
-       frame = gtk_frame_new((char *) p->dus.name);
-       gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 2);
-
-       box = gtk_vbox_new(FALSE, 3);
-       gtk_container_add(GTK_CONTAINER(frame), box);
-
-       frame = gtk_frame_new("Read");
-       gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2);
-       vbox = gtk_hbox_new(TRUE, 3);
-       gtk_container_add(GTK_CONTAINER(frame), vbox);
-       entry = new_info_entry_in_frame(vbox, "IOs");
-       entry_set_int_value(entry, p->dus.ios[0]);
-       entry = new_info_entry_in_frame(vbox, "Merges");
-       entry_set_int_value(entry, p->dus.merges[0]);
-       entry = new_info_entry_in_frame(vbox, "Sectors");
-       entry_set_int_value(entry, p->dus.sectors[0]);
-       entry = new_info_entry_in_frame(vbox, "Ticks");
-       entry_set_int_value(entry, p->dus.ticks[0]);
-
-       frame = gtk_frame_new("Write");
-       gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2);
-       vbox = gtk_hbox_new(TRUE, 3);
-       gtk_container_add(GTK_CONTAINER(frame), vbox);
-       entry = new_info_entry_in_frame(vbox, "IOs");
-       entry_set_int_value(entry, p->dus.ios[1]);
-       entry = new_info_entry_in_frame(vbox, "Merges");
-       entry_set_int_value(entry, p->dus.merges[1]);
-       entry = new_info_entry_in_frame(vbox, "Sectors");
-       entry_set_int_value(entry, p->dus.sectors[1]);
-       entry = new_info_entry_in_frame(vbox, "Ticks");
-       entry_set_int_value(entry, p->dus.ticks[1]);
-
-       frame = gtk_frame_new("Shared");
-       gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2);
-       vbox = gtk_hbox_new(TRUE, 3);
-       gtk_container_add(GTK_CONTAINER(frame), vbox);
-       entry = new_info_entry_in_frame(vbox, "IO ticks");
-       entry_set_int_value(entry, p->dus.io_ticks);
-       entry = new_info_entry_in_frame(vbox, "Time in queue");
-       entry_set_int_value(entry, p->dus.time_in_queue);
-
-       util = 0.0;
-       if (p->dus.msec)
-               util = (double) 100 * p->dus.io_ticks / (double) p->dus.msec;
-       if (util > 100.0)
-               util = 100.0;
-
-       sprintf(tmp, "%3.2f%%", util);
-       entry = new_info_entry_in_frame(vbox, "Disk utilization");
-       gtk_entry_set_text(GTK_ENTRY(entry), tmp);
-
-       gtk_widget_show_all(gc->results_widget);
-out:
+       gdk_threads_enter();
+       gfio_disk_util_show(gc);
        gdk_threads_leave();
 }
 
        gdk_threads_leave();
 }
 
@@ -2632,7 +2671,6 @@ static void view_results(GtkWidget *w, gpointer data)
                gfio_display_end_results(gc);
 }
 
                gfio_display_end_results(gc);
 }
 
-
 static void __update_graph_limits(struct gfio_graphs *g)
 {
        line_graph_set_data_count_limit(g->iops_graph, gfio_graph_limit);
 static void __update_graph_limits(struct gfio_graphs *g)
 {
        line_graph_set_data_count_limit(g->iops_graph, gfio_graph_limit);