All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yordan Karadzhov <ykaradzhov@vmware.com>
To: "rostedt@goodmis.org" <rostedt@goodmis.org>
Cc: "linux-trace-devel@vger.kernel.org"
	<linux-trace-devel@vger.kernel.org>,
	Yordan Karadzhov <ykaradzhov@vmware.com>
Subject: [PATCH v3 5/5] kernel-shark-qt: Fix a bug in kshark_data_collection_alloc()
Date: Fri, 5 Oct 2018 18:33:32 +0000	[thread overview]
Message-ID: <20181005183241.27026-6-ykaradzhov@vmware.com> (raw)
In-Reply-To: <20181005183241.27026-1-ykaradzhov@vmware.com>

The margin data added at the end of the data interval of the collection
may actually include the beginning of another interval. Because of this
we have to iterate over the margin data and check for "good" entries. In
the case of a "good" entry being found, we have to continue extending the
last interval.

Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark-qt/src/libkshark-collection.c | 27 +++++++++++++++-------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/kernel-shark-qt/src/libkshark-collection.c b/kernel-shark-qt/src/libkshark-collection.c
index 79b6fff..9838042 100644
--- a/kernel-shark-qt/src/libkshark-collection.c
+++ b/kernel-shark-qt/src/libkshark-collection.c
@@ -157,14 +157,25 @@ kshark_data_collection_alloc(struct kshark_context *kshark_ctx,
 			 * number of margin entries requested, keep adding
 			 * until you fill the margin.
 			 */
-			if (i + margin < j)
-				i = j;
-			else
-				i += margin;
-
-			last_added = i;
-			collection_add_entry(&temp, i, COLLECTION_BREAK);
-			++break_count;
+			if (i + margin >= j) {
+				for (;j < i + margin; ++j) {
+					if (cond(kshark_ctx, data[j], val)) {
+						/*
+						 * Good data has been found.
+						 * Continue extending the
+						 * previous data interval.
+						 */
+						good_data = true;
+						break;
+					}
+				}
+			}
+
+			last_added = i = j;
+			if (!good_data) {
+				collection_add_entry(&temp, i, COLLECTION_BREAK);
+				++break_count;
+			}
 		}
 	}
 
-- 
2.17.1

      parent reply	other threads:[~2018-10-06  1:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-05 18:33 [PATCH v3 0/5] Final preparation before adding the KernelShark GUI Yordan Karadzhov
2018-10-05 18:33 ` [PATCH v3 1/5] kernel-shark-qt: Add kshark_get_X_easy() functions Yordan Karadzhov
2018-10-05 19:20   ` Steven Rostedt
2018-10-05 18:33 ` [PATCH v3 2/5] kernel-shark-qt: Add kshark_convert_nano() function Yordan Karadzhov
2018-10-05 18:33 ` [PATCH v3 3/5] kernel-shark-qt: Add functions for fast clearing of the filters Yordan Karadzhov
2018-10-05 18:33 ` [PATCH v3 4/5] kernel-shark-qt: Rename the Cmake-generated header file Yordan Karadzhov
2018-10-05 18:33 ` Yordan Karadzhov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181005183241.27026-6-ykaradzhov@vmware.com \
    --to=ykaradzhov@vmware.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.