diff mbox series

[6/8] kernel-shark-qt: Add tot_count field to the model descriptor

Message ID 20181107161410.22507-7-ykaradzhov@vmware.com (mailing list archive)
State Superseded
Headers show
Series New/improved KernelShark plugins | expand

Commit Message

Yordan Karadzhov Nov. 7, 2018, 4:14 p.m. UTC
The tot_count field of the Visualization model descriptor provides
fast access to the total number of entries being currently visualized.

Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark-qt/src/libkshark-model.c | 7 +++++++
 kernel-shark-qt/src/libkshark-model.h | 3 +++
 2 files changed, 10 insertions(+)

Comments

Steven Rostedt Nov. 9, 2018, 2:12 a.m. UTC | #1
On Wed, 7 Nov 2018 16:14:38 +0000
Yordan Karadzhov <ykaradzhov@vmware.com> wrote:

> The tot_count field of the Visualization model descriptor provides
> fast access to the total number of entries being currently visualized.

I'm pulling these patches as is, but just for the future, it's best to
add a bit more about "why" a change like this is added. You could add
something like:

 "This will be useful for the sched event plugin for knowing when to
 plot wakeup latency"

Or something like that.

-- Steve


> 
> Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
>
diff mbox series

Patch

diff --git a/kernel-shark-qt/src/libkshark-model.c b/kernel-shark-qt/src/libkshark-model.c
index ef6ad48..461f88e 100644
--- a/kernel-shark-qt/src/libkshark-model.c
+++ b/kernel-shark-qt/src/libkshark-model.c
@@ -298,6 +298,7 @@  static void ksmodel_set_bin_counts(struct kshark_trace_histo *histo)
 {
 	int i = 0, prev_not_empty;
 
+	histo->tot_count = 0;
 	memset(&histo->bin_count[0], 0,
 	       (histo->n_bins) * sizeof(histo->bin_count[0]));
 	/*
@@ -329,6 +330,10 @@  static void ksmodel_set_bin_counts(struct kshark_trace_histo *histo)
 			histo->bin_count[prev_not_empty] =
 				histo->map[i] - histo->map[prev_not_empty];
 
+			if (prev_not_empty != LOB(histo))
+				histo->tot_count +=
+					histo->bin_count[prev_not_empty];
+
 			prev_not_empty = i;
 		}
 	}
@@ -350,6 +355,8 @@  static void ksmodel_set_bin_counts(struct kshark_trace_histo *histo)
 		histo->bin_count[prev_not_empty] = histo->map[UOB(histo)] -
 						   histo->map[prev_not_empty];
 	}
+
+	histo->tot_count += histo->bin_count[prev_not_empty];
 }
 
 /**
diff --git a/kernel-shark-qt/src/libkshark-model.h b/kernel-shark-qt/src/libkshark-model.h
index db681cc..95c30b6 100644
--- a/kernel-shark-qt/src/libkshark-model.h
+++ b/kernel-shark-qt/src/libkshark-model.h
@@ -51,6 +51,9 @@  struct kshark_trace_histo {
 	/** Number of entries in each bin. */
 	size_t			*bin_count;
 
+	/** Total number of entries in all bin except the overflow bins. */
+	int			tot_count;
+
 	/**
 	 * Lower edge of the time-window to be visualized. Only entries having
 	 * timestamp >= min will be visualized.