linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yordan Karadzhov <ykaradzhov@vmware.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH 12/12] kernel-shark: In collections, handle the case when the data is small
Date: Thu, 14 Mar 2019 17:10:12 +0200	[thread overview]
Message-ID: <20190314151012.905-13-ykaradzhov@vmware.com> (raw)
In-Reply-To: <20190314151012.905-1-ykaradzhov@vmware.com>

In particular, handle the case when the size of the data is smaller
than the required margin.

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

diff --git a/kernel-shark/src/libkshark-collection.c b/kernel-shark/src/libkshark-collection.c
index c70da1e..02a014e 100644
--- a/kernel-shark/src/libkshark-collection.c
+++ b/kernel-shark/src/libkshark-collection.c
@@ -71,7 +71,7 @@ static bool collection_add_entry(struct entry_list **list,
 static struct kshark_entry_collection *
 kshark_data_collection_alloc(struct kshark_context *kshark_ctx,
 			     struct kshark_entry **data,
-			     size_t first,
+			     ssize_t first,
 			     size_t n_rows,
 			     matching_condition_func cond,
 			     int val,
@@ -81,9 +81,19 @@ kshark_data_collection_alloc(struct kshark_context *kshark_ctx,
 	struct kshark_entry *last_vis_entry = NULL;
 	struct entry_list *col_list, *temp;
 	size_t resume_count = 0, break_count = 0;
-	size_t i, j, end, last_added = 0;
+	size_t i, j, last_added = 0;
+	ssize_t end;
 	bool good_data = false;
 
+	/* Create the collection. */
+	col_ptr = calloc(1, sizeof(*col_ptr));
+	if (!col_ptr)
+		goto fail;
+
+	end = first + n_rows - margin;
+	if (first >= end)
+		return col_ptr;
+
 	col_list = malloc(sizeof(*col_list));
 	if (!col_list)
 		goto fail;
@@ -106,7 +116,6 @@ kshark_data_collection_alloc(struct kshark_context *kshark_ctx,
 		temp->type = COLLECTION_IGNORE;
 	}
 
-	end = first + n_rows - margin;
 	for (i = first + margin; i < end; ++i) {
 		if (!cond(kshark_ctx, data[i], val)) {
 			/*
@@ -204,11 +213,6 @@ kshark_data_collection_alloc(struct kshark_context *kshark_ctx,
 	 */
 	assert(break_count == resume_count);
 
-	/* Create the collection. */
-	col_ptr = malloc(sizeof(*col_ptr));
-	if (!col_ptr)
-		goto fail;
-
 	col_ptr->next = NULL;
 
 	col_ptr->resume_points = calloc(resume_count,
-- 
2.19.1


      parent reply	other threads:[~2019-03-14 15:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14 15:10 [PATCH 00/12] Various modifications and fixes toward KS 1.0 Yordan Karadzhov
2019-03-14 15:10 ` [PATCH 01/12] kernel-shark: Fix a spelling typo in KsMainWindow class Yordan Karadzhov
2019-03-14 15:10 ` [PATCH 02/12] kernel-shark: Fix a typo in an error message from libkshark-configio Yordan Karadzhov
2019-03-14 15:10 ` [PATCH 03/12] kernel-shark: Make KsSession::importFromFile return status flag Yordan Karadzhov
2019-03-14 15:10 ` [PATCH 04/12] kernel-shark: Error message if the opening of the session file fails Yordan Karadzhov
2019-03-15 10:23   ` Slavomir Kaslev
2019-03-14 15:10 ` [PATCH 05/12] kernel-shark: Disables automatic quotation for errors in KsMainWindow Yordan Karadzhov
2019-03-14 15:10 ` [PATCH 06/12] kernel-shark: Load Last Session from command line Yordan Karadzhov
2019-03-14 23:47   ` Steven Rostedt
2019-03-15  6:13     ` Yordan Karadzhov (VMware)
2019-03-18 17:44       ` Steven Rostedt
2019-03-14 15:10 ` [PATCH 07/12] kernel-shark: Add destructor for KsGLWidget Yordan Karadzhov
2019-03-14 15:10 ` [PATCH 08/12] kernel-shark: Fix memory leak in KsPlotget::getTaskColorTable() Yordan Karadzhov
2019-03-14 15:10 ` [PATCH 09/12] kernel-shark: Avoid the unnecessary calls of KsGLWidget::loadColors() Yordan Karadzhov
2019-03-14 15:10 ` [PATCH 10/12] kernel-shark: Avoid 0/0 spliter ratio in KsSession Yordan Karadzhov
2019-03-14 15:10 ` [PATCH 11/12] kernel-shark: In model, handle the case when all bins are empty Yordan Karadzhov
2019-03-15 10:21   ` Slavomir Kaslev
2019-03-14 15:10 ` 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=20190314151012.905-13-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).