From: Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: Re: [PATCH v7 17/25] trace-cmd library: Read strings sections on file load
Date: Mon, 17 Jan 2022 18:11:38 +0200 [thread overview]
Message-ID: <CAPpZLN58EfUYk7uik0YWERcpvFXA=D_EpXdjjn-RTsQuYRNpnQ@mail.gmail.com> (raw)
In-Reply-To: <20220115110445.6ea63c4a@gandalf.local.home>
On Sat, Jan 15, 2022 at 6:04 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Fri, 10 Dec 2021 12:54:40 +0200
> "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:
>
> > Internal strings database is added to trace input handle, containing all
> > metadata strings from trace file. When a trace file is opened, all
> > strings sections are located and the internal strings database is
> > initialised.
> >
> > Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> > ---
> > lib/trace-cmd/include/trace-cmd-local.h | 1 +
> > lib/trace-cmd/trace-input.c | 64 +++++++++++++++++++++++++
> > lib/trace-cmd/trace-output.c | 1 +
> > 3 files changed, 66 insertions(+)
> >
> > diff --git a/lib/trace-cmd/include/trace-cmd-local.h b/lib/trace-cmd/include/trace-cmd-local.h
> > index 4a0a691c..ac7e7f17 100644
> > --- a/lib/trace-cmd/include/trace-cmd-local.h
> > +++ b/lib/trace-cmd/include/trace-cmd-local.h
> > @@ -53,5 +53,6 @@ struct cpu_data_source {
> > int out_write_cpu_data(struct tracecmd_output *handle, int cpus,
> > struct cpu_data_source *data, const char *buff_name);
> > off64_t msg_lseek(struct tracecmd_msg_handle *msg_handle, off_t offset, int whence);
> > +unsigned int get_meta_strings_size(struct tracecmd_input *handle);
> >
> > #endif /* _TRACE_CMD_LOCAL_H */
> > diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
> > index 9027729e..6cc8ee90 100644
> > --- a/lib/trace-cmd/trace-input.c
> > +++ b/lib/trace-cmd/trace-input.c
> > @@ -147,6 +147,9 @@ struct tracecmd_input {
> > long long ts_offset;
> > struct tsc2nsec tsc_calc;
> >
> > + unsigned int strings_size; /* size of the metadata strings */
> > + char *strings; /* metadata strings */
> > +
> > struct host_trace_info host;
> > double ts2secs;
> > char * cpustats;
> > @@ -984,6 +987,14 @@ static int read_headers_v6(struct tracecmd_input *handle, enum tracecmd_file_sta
> >
> > static int handle_options(struct tracecmd_input *handle);
> >
> > +static const char *get_metadata_string(struct tracecmd_input *handle, int offset)
> > +{
> > + if (!handle || !handle->strings || offset < 0 || handle->strings_size >= offset)
> > + return NULL;
> > +
> > + return handle->strings + offset;
> > +}
> > +
> > static int read_section_header(struct tracecmd_input *handle, unsigned short *id,
> > unsigned short *flags, unsigned long long *size, const char **description)
> > {
> > @@ -1007,6 +1018,8 @@ static int read_section_header(struct tracecmd_input *handle, unsigned short *id
> > *flags = fl;
> > if (size)
> > *size = sz;
> > + if (description)
> > + *description = get_metadata_string(handle, desc);
> >
> > return 0;
> > }
> > @@ -2839,6 +2852,11 @@ tracecmd_search_task_map(struct tracecmd_input *handle,
> > return lib;
> > }
> >
> > +__hidden unsigned int get_meta_strings_size(struct tracecmd_input *handle)
> > +{
> > + return handle->strings_size;
> > +}
> > +
> > static int handle_options(struct tracecmd_input *handle)
> > {
> > long long offset;
> > @@ -3472,6 +3490,50 @@ struct hook_list *tracecmd_hooks(struct tracecmd_input *handle)
> > return handle->hooks;
> > }
> >
> > +static int init_metadata_strings(struct tracecmd_input *handle, int size)
> > +{
> > + char *tmp;
> > +
> > + tmp = realloc(handle->strings, handle->strings_size + size);
>
> Hmm, I don't remember in our conversations. Did we say we would have more
> than one string section? Or allow it to be broken up? How do offsets work
> in such cases?
>
> I was thinking that we could simply mmap the string section, but that won't
> work if there's more than one.
>
The first implementation was with a single string section at the end
of the file. But when I tested that design with the trace-cmd
guest-host tracing, I realized it is impossible to work without major
changes in the host-guest protocol. The problem is that in the current
host-guest tracing logic, part of the guest metadata file is written
in the guest context, part in the host context. Each of these parts
can put strings in the string section. That will change the way guest
metadata is written. That's why decided to use multiple string
sections in the file. On file read the strings from all sections are
stored into one memory block, and string offset is the offset in that
block. As these sections are compressed usually, simple mmap will not
work even in case of single section.
> -- Steve
>
>
[...]
--
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center
next prev parent reply other threads:[~2022-01-17 16:11 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-10 10:54 [PATCH v7 00/25] Trace file version 7 - sections Tzvetomir Stoyanov (VMware)
2021-12-10 10:54 ` [PATCH v7 01/25] trace-cmd library: Define trace file version 7 Tzvetomir Stoyanov (VMware)
2021-12-10 10:54 ` [PATCH v7 02/25] trace-cmd library: Add cache functionality to network message handler Tzvetomir Stoyanov (VMware)
2021-12-10 10:54 ` [PATCH v7 03/25] trace-cmd library: New APIs to get and set version of output handler Tzvetomir Stoyanov (VMware)
2021-12-10 10:54 ` [PATCH v7 04/25] trace-cmd library: Add strings section in trace file version 7 Tzvetomir Stoyanov (VMware)
2022-01-15 12:53 ` Steven Rostedt
2022-01-17 9:32 ` Tzvetomir Stoyanov
2022-01-17 14:40 ` Steven Rostedt
2022-01-17 14:44 ` Tzvetomir Stoyanov
2021-12-10 10:54 ` [PATCH v7 05/25] trace-cmd library: Add internal helper function for writing headers before file sections Tzvetomir Stoyanov (VMware)
2022-01-15 12:58 ` Steven Rostedt
2022-01-17 10:08 ` Tzvetomir Stoyanov
2021-12-10 10:54 ` [PATCH v7 06/25] trace-cmd library: Write header " Tzvetomir Stoyanov (VMware)
2021-12-10 10:54 ` [PATCH v7 07/25] trace-cmd library: Add multiple options sections in trace file version 7 Tzvetomir Stoyanov (VMware)
2022-01-15 14:57 ` Steven Rostedt
2022-01-17 17:12 ` Tzvetomir Stoyanov
2021-12-10 10:54 ` [PATCH v7 08/25] trace-cmd library: Do not write CPU count section in trace files " Tzvetomir Stoyanov (VMware)
2021-12-10 10:54 ` [PATCH v7 09/25] trace-cmd library: Move CPU flyrecord trace metadata into the buffer option, for trace file " Tzvetomir Stoyanov (VMware)
2022-01-15 15:12 ` Steven Rostedt
2022-01-17 13:43 ` Tzvetomir Stoyanov
2021-12-10 10:54 ` [PATCH v7 10/25] trace-cmd library: Add section header before flyrecord trace data Tzvetomir Stoyanov (VMware)
2021-12-10 10:54 ` [PATCH v7 11/25] trace-cmd library: Fit CPU latency trace data in the new trace file version 7 format Tzvetomir Stoyanov (VMware)
2022-01-15 15:20 ` Steven Rostedt
2022-01-17 14:11 ` Tzvetomir Stoyanov
2021-12-10 10:54 ` [PATCH v7 12/25] trace-cmd library: Add macro to check file state on reading Tzvetomir Stoyanov (VMware)
2021-12-10 10:54 ` [PATCH v7 13/25] trace-cmd library: Introduce sections in trace file reading logic Tzvetomir Stoyanov (VMware)
2022-01-15 15:27 ` Steven Rostedt
2021-12-10 10:54 ` [PATCH v7 14/25] trace-cmd library: Initialize internal sections database on file read Tzvetomir Stoyanov (VMware)
2021-12-10 10:54 ` [PATCH v7 15/25] trace-cmd library: Use sections database when reading parts of the trace file Tzvetomir Stoyanov (VMware)
2021-12-10 10:54 ` [PATCH v7 16/25] trace-cmd library: Read headers from trace file version 7 Tzvetomir Stoyanov (VMware)
2022-01-15 15:59 ` Steven Rostedt
2022-01-17 15:47 ` Tzvetomir Stoyanov
2022-01-17 16:17 ` Steven Rostedt
2021-12-10 10:54 ` [PATCH v7 17/25] trace-cmd library: Read strings sections on file load Tzvetomir Stoyanov (VMware)
2022-01-15 16:04 ` Steven Rostedt
2022-01-17 16:11 ` Tzvetomir Stoyanov [this message]
2022-01-17 16:18 ` Steven Rostedt
2021-12-10 10:54 ` [PATCH v7 18/25] trace-cmd library: Read extended BUFFER option Tzvetomir Stoyanov (VMware)
2022-01-15 16:10 ` Steven Rostedt
2021-12-10 10:54 ` [PATCH v7 19/25] trace-cmd library: Handle the extended DONE option Tzvetomir Stoyanov (VMware)
2022-01-15 16:12 ` Steven Rostedt
2021-12-10 10:54 ` [PATCH v7 20/25] trace-cmd library: Initialize CPU data for reading from version 7 trace files Tzvetomir Stoyanov (VMware)
2021-12-10 10:54 ` [PATCH v7 21/25] trace-cmd library: Handle latency trace in version 7 files Tzvetomir Stoyanov (VMware)
2021-12-10 10:54 ` [PATCH v7 22/25] trace-cmd library: Handle buffer trace data init for " Tzvetomir Stoyanov (VMware)
2021-12-10 10:54 ` [PATCH v7 23/25] trace-cmd report: Use the new latency API to read data Tzvetomir Stoyanov (VMware)
2021-12-10 10:54 ` [PATCH v7 24/25] trace-cmd: Write buffers metadata in trace files version 6 Tzvetomir Stoyanov (VMware)
2021-12-10 10:54 ` [PATCH v7 25/25] trace-cmd report: Add new parameter for trace file version Tzvetomir Stoyanov (VMware)
2022-01-15 16:20 ` Steven Rostedt
2022-01-15 16:21 ` [PATCH v7 00/25] Trace file version 7 - sections Steven Rostedt
2022-01-17 9:03 ` Tzvetomir Stoyanov
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='CAPpZLN58EfUYk7uik0YWERcpvFXA=D_EpXdjjn-RTsQuYRNpnQ@mail.gmail.com' \
--to=tz.stoyanov@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 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).