diff mbox series

[2/8] kernel-shark: Do not copy the Upper Overflow bin when shifting forward

Message ID 20190213161216.14438-3-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Headers show
Series Various modifications toward KS 1.0 | expand

Commit Message

Yordan Karadzhov Feb. 13, 2019, 4:12 p.m. UTC
ksmodel_shift_forward() copies the mapping indexes of all overlapping
bins of the model starting from bin "0" of the new histo up to bin
"histo->n_bins - n". Then the mapping index of the old Upper Overflow
bin is considered to be the mapping index of first non-overlapping bin,
which is wrong. It is wrong because in ksmodel_set_upper_edge() the
value of "histo->max" is considered inside the range of the model hence
the Upper Overflow bin starts at "histo->max + 1" but the first
non-overlapping bin will start at exactly "histo->max".

Fixes: f97e31f00 ("kernel-shark-qt: Introduce the visualization model used by the Qt-based KS")
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark/src/libkshark-model.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shark/src/libkshark-model.c b/kernel-shark/src/libkshark-model.c
index a4041c3..b71a9b8 100644
--- a/kernel-shark/src/libkshark-model.c
+++ b/kernel-shark/src/libkshark-model.c
@@ -500,13 +500,11 @@  void ksmodel_shift_forward(struct kshark_trace_histo *histo, size_t n)
 		sizeof(histo->map[0]) * (histo->n_bins - n));
 
 	/*
-	 * The mapping index of the old Upper Overflow bin is now index of the
-	 * first new bin.
+	 * Calculate only the content of the new (non-overlapping) bins.
+	 * Start from the last copied bin and set the edge of each consecutive
+	 * bin.
 	 */
-	bin = UOB(histo) - n;
-	histo->map[bin] = histo->map[UOB(histo)];
-
-	/* Calculate only the content of the new (non-overlapping) bins. */
+	bin = histo->n_bins - n - 1;
 	for (; bin < histo->n_bins; ++bin) {
 		ksmodel_set_next_bin_edge(histo, bin, last_row);
 		if (histo->map[bin + 1] > 0)