All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v4 14/20] kernel-shark: Provide merging of multiple data streams
Date: Thu, 19 Nov 2020 18:14:36 +0200	[thread overview]
Message-ID: <83fe0b27-f5cb-a1cf-6afd-bf48cd2f61bc@gmail.com> (raw)
In-Reply-To: <20201118210025.0bc6326b@oasis.local.home>



On 19.11.20 г. 4:00 ч., Steven Rostedt wrote:
> On Wed, 18 Nov 2020 16:49:57 +0200
> "Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:
> 
>> The C API provides loading of the trace data in two different forms.
>> The firs one is an array of kshark_entries and is being used by the
> 
>    "first one"
> 
>> KernelShark GUI. The second is a matrix-like structure that has all
>> the fields of the kshark_entry stored in separate arrays, forming the
>> columns of the matrix. The second form of the data is used by
>> trace-cruncher. In this patch we add methods for merging of several
>> data streams into a single data set. Both kshark_entries and matrix
>> forms of the data are supported. This patch includes a simple example
>> that demonstrate how to open a file that contains multiple buffers.
>> Each buffers is loaded into a separate Data stream and those streams
>> are merged together.
>>
>> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
>> ---
>>   examples/CMakeLists.txt    |   4 +
>>   examples/multibufferload.c |  60 +++++++++
>>   src/libkshark.c            | 255 +++++++++++++++++++++++++++++++++++++
>>   src/libkshark.h            |  47 +++++++
>>   4 files changed, 366 insertions(+)
>>   create mode 100644 examples/multibufferload.c
>>
>> diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
>> index 8d40e42c..831eee24 100644
>> --- a/examples/CMakeLists.txt
>> +++ b/examples/CMakeLists.txt
>> @@ -8,6 +8,10 @@ message(STATUS "datafilter")
>>   add_executable(dfilter          datafilter.c)
>>   target_link_libraries(dfilter   kshark)
>>   
>> +message(STATUS "multibufferload")
>> +add_executable(mbload          multibufferload.c)
>> +target_link_libraries(mbload   kshark)
>> +
>>   # message(STATUS "datahisto")
>>   # add_executable(dhisto          datahisto.c)
>>   # target_link_libraries(dhisto   kshark)
>> diff --git a/examples/multibufferload.c b/examples/multibufferload.c
>> new file mode 100644
>> index 00000000..70b2733a
>> --- /dev/null
>> +++ b/examples/multibufferload.c
>> @@ -0,0 +1,60 @@
>> +#include <stdio.h>
>> +#include <stdlib.h>
>> +
>> +#include "libkshark.h"
>> +#include "libkshark-tepdata.h"
>> +
>> +const char *default_file = "trace.dat";
>> +
>> +void put_entry(struct kshark_entry *e)
>> +{
>> +	char *entry_str = kshark_dump_entry(e);
>> +	puts(entry_str);
>> +	free(entry_str);
>> +}
>> +
>> +int main(int argc, char **argv)
>> +{
>> +	struct kshark_context *kshark_ctx;
>> +	struct kshark_entry **data = NULL;
>> +	ssize_t r, n_rows;
>> +	int sd;
>> +
>> +	/* Create a new kshark session. */
>> +	kshark_ctx = NULL;
>> +	if (!kshark_instance(&kshark_ctx))
>> +		return 1;
>> +
>> +	/* Open a trace data file produced by trace-cmd. */
>> +	if (argc > 1)
>> +		sd = kshark_open(kshark_ctx, argv[1]);
>> +	else
>> +		sd = kshark_open(kshark_ctx, default_file);
> 
> I'm confused. It doesn't look like this merges more than one stream.


Hi Steven,

Here it only opens the "top" buffer in the file.

> 
> -- Steve
> 
>> +
>> +	if (sd < 0) {
>> +		kshark_free(kshark_ctx);
>> +		return 1;
>> +	}
>> +
>> +	/* Initialize data streams for all buffers in this file. */
>> +	kshark_tep_init_all_buffers(kshark_ctx, sd);

And here is the place where it opens in separate streams the other 
buffers that are in the same file.


>> +
>> +	/* Load all buffers. */
>> +	n_rows = kshark_load_all_entries(kshark_ctx, &data);
>> +

Here it loads and merges the entries from all buffers.

Thanks!
Yordan

>> +	/* Print to the screen the first 20 entries. */
>> +	for (r = 0; r < 20; ++r)
>> +		put_entry(data[r]);
>> +
>> +	/* Free the memory. */
>> +	for (r = 0; r < n_rows; ++r)
>> +		free(data[r]);
>> +	free(data);
>> +
>> +	kshark_close_all(kshark_ctx);
>> +
>> +	/* Close the session. */
>> +	kshark_free(kshark_ctx);
>> +
>> +	return 0;
>> +}

  reply	other threads:[~2020-11-19 16:14 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-18 14:49 [PATCH v4 00/20] Start KernelShark v2 transformation Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 01/20] kernel-shark: Use only signed types in kshark_entry Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 02/20] kernel-shark: Add stream_id to kshark_entry Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 03/20] kernel-shark: Introduce libkshark-hash Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 04/20] kernel-shark: Introduce Data streams Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 05/20] kernel-shark: Rename static methods in libkshark Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 06/20] kernel-shark: Add basic methods for Data streams Yordan Karadzhov (VMware)
2020-11-18 22:13   ` Steven Rostedt
2020-11-19 16:01     ` Yordan Karadzhov (VMware)
2020-11-19 16:38       ` Steven Rostedt
2020-11-18 22:17   ` Steven Rostedt
2020-11-19 16:04     ` Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 07/20] kernel-shark: Housekeeping before implementing stream interface Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 08/20] kernel-shark: Add stream interface for trace-cmd data Yordan Karadzhov (VMware)
2020-11-19  1:11   ` Steven Rostedt
2020-11-19 16:06     ` Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 09/20] kernel-shark: Start introducing KernelShark 2.0 Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 10/20] kernel-shark: Start using data streams Yordan Karadzhov (VMware)
2020-11-19  1:29   ` Steven Rostedt
2020-11-19 16:08     ` Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 11/20] kernel-shark: Remove dead code Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 12/20] kernel-shark: Redesign the plugin interface Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 13/20] kernel-shark: Complete the stream integration Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 14/20] kernel-shark: Provide merging of multiple data streams Yordan Karadzhov (VMware)
2020-11-19  2:00   ` Steven Rostedt
2020-11-19 16:14     ` Yordan Karadzhov (VMware) [this message]
2020-11-19 16:43       ` Steven Rostedt
2020-11-19 17:48         ` Yordan Karadzhov (VMware)
2020-11-19 20:43           ` Steven Rostedt
2020-11-18 14:49 ` [PATCH v4 15/20] kernel-shark: Integrate the stream definitions with data model Yordan Karadzhov (VMware)
2020-11-18 14:49 ` [PATCH v4 16/20] kernel-shark: Use only signed types for model defs Yordan Karadzhov (VMware)
2020-11-18 14:50 ` [PATCH v4 17/20] kernel-shark: Add ksmodel_get_bin() Yordan Karadzhov (VMware)
2020-11-18 14:50 ` [PATCH v4 18/20] kernel-shark: Protect ksmodel_set_in_range_bining() Yordan Karadzhov (VMware)
2020-11-18 14:50 ` [PATCH v4 19/20] kernel-shark: Add methods for time calibration Yordan Karadzhov (VMware)
2020-11-18 14:50 ` [PATCH v4 20/20] kernel-shark: Integrate streams with libkshark-configio Yordan Karadzhov (VMware)

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=83fe0b27-f5cb-a1cf-6afd-bf48cd2f61bc@gmail.com \
    --to=y.karadz@gmail.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.