diff mbox series

[2/3] kernel-shark: Fix a bug in shift_XXX methods of the visualization model

Message ID 20190221124205.21115-3-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Commit e9fc4f3265eead58e1935cc370e1708d43fb1b65
Headers show
Series KernelShark visualization model fixes | expand

Commit Message

Yordan Karadzhov Feb. 21, 2019, 12:42 p.m. UTC
In ksmodel_shift_forward() and ksmodel_shift_backward() we are supposed
to recalculate only the content of the new (non-overlapping) Bins. However
the loop does not take into account that the static function used to do
the job actually calculates next Bin (bin + 1). The result is this
misunderstanding is that we recalculate also the first overlapping
Bin (n). This wipes up the effect of the bug fixed by the previous patch.

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

Patch

diff --git a/kernel-shark/src/libkshark-model.c b/kernel-shark/src/libkshark-model.c
index a185d6b..b6d3612 100644
--- a/kernel-shark/src/libkshark-model.c
+++ b/kernel-shark/src/libkshark-model.c
@@ -505,7 +505,11 @@  void ksmodel_shift_forward(struct kshark_trace_histo *histo, size_t n)
 	 * bin.
 	 */
 	bin = histo->n_bins - n - 1;
-	for (; bin < histo->n_bins; ++bin) {
+	for (; bin < histo->n_bins - 1; ++bin) {
+		/*
+		 * Note that this function will set the bin having index
+		 * "bin + 1".
+		 */
 		ksmodel_set_next_bin_edge(histo, bin, last_row);
 		if (histo->map[bin + 1] > 0)
 			last_row = histo->map[bin + 1];
@@ -570,7 +574,11 @@  void ksmodel_shift_backward(struct kshark_trace_histo *histo, size_t n)
 	ksmodel_set_lower_edge(histo);
 
 	/* Calculate only the content of the new (non-overlapping) bins. */
-	for (bin = 0; bin < n; ++bin) {
+	for (bin = 0; bin < n - 1; ++bin) {
+		/*
+		 * Note that this function will set the bin having index
+		 * "bin + 1".
+		 */
 		ksmodel_set_next_bin_edge(histo, bin, last_row);
 		if (histo->map[bin + 1] > 0)
 			last_row = histo->map[bin + 1];