linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Documented new trace-cmd options
@ 2021-03-29 12:58 Tzvetomir Stoyanov (VMware)
  2021-03-29 12:58 ` [PATCH 1/4] trace-cmd: Add internal API to check if tsc2nsec is supported Tzvetomir Stoyanov (VMware)
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Tzvetomir Stoyanov (VMware) @ 2021-03-29 12:58 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

Documented newly added trace-cmd options.
Extended trace-cmd list command to show new clock.

Tzvetomir Stoyanov (VMware) (4):
  trace-cmd: Add internal API to check if tsc2nsec is supported
  trace-cmd: Add tsc2nsec clock to "list -C" command
  trace-cmd: Document --tsc2nsec option
  trace-cmd: Document --raw-ts option

 Documentation/trace-cmd/trace-cmd-record.1.txt |  5 +++++
 Documentation/trace-cmd/trace-cmd-report.1.txt |  3 +++
 tracecmd/include/trace-local.h                 |  2 ++
 tracecmd/trace-list.c                          | 16 +++++++++++++++-
 tracecmd/trace-record.c                        |  5 +++++
 tracecmd/trace-usage.c                         |  3 +++
 6 files changed, 33 insertions(+), 1 deletion(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] trace-cmd: Add internal API to check if tsc2nsec is supported
  2021-03-29 12:58 [PATCH 0/4] Documented new trace-cmd options Tzvetomir Stoyanov (VMware)
@ 2021-03-29 12:58 ` Tzvetomir Stoyanov (VMware)
  2021-03-30 21:37   ` Steven Rostedt
  2021-03-29 12:58 ` [PATCH 2/4] trace-cmd: Add tsc2nsec clock to "list -C" command Tzvetomir Stoyanov (VMware)
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Tzvetomir Stoyanov (VMware) @ 2021-03-29 12:58 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

A new internal API is added to check is tsc to nanoseconds conversion is
supported:
 bool trace_tsc2nsec_is_supported(void);

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 tracecmd/include/trace-local.h | 2 ++
 tracecmd/trace-record.c        | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/tracecmd/include/trace-local.h b/tracecmd/include/trace-local.h
index 7773e9fc..6a4c5f51 100644
--- a/tracecmd/include/trace-local.h
+++ b/tracecmd/include/trace-local.h
@@ -341,4 +341,6 @@ static inline bool is_digits(const char *s)
 	return true;
 }
 
+bool trace_tsc2nsec_is_supported(void);
+
 #endif /* __TRACE_LOCAL_H */
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 5e69cf48..5c9d800f 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -5827,6 +5827,11 @@ static int get_tsc_nsec(int *shift, int *mult)
 }
 #endif
 
+bool trace_tsc2nsec_is_supported(void)
+{
+	return (get_tsc_nsec(NULL, NULL) == 0);
+}
+
 static void parse_record_options(int argc,
 				 char **argv,
 				 enum trace_cmd curr_cmd,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] trace-cmd: Add tsc2nsec clock to "list -C" command
  2021-03-29 12:58 [PATCH 0/4] Documented new trace-cmd options Tzvetomir Stoyanov (VMware)
  2021-03-29 12:58 ` [PATCH 1/4] trace-cmd: Add internal API to check if tsc2nsec is supported Tzvetomir Stoyanov (VMware)
@ 2021-03-29 12:58 ` Tzvetomir Stoyanov (VMware)
  2021-03-29 12:58 ` [PATCH 3/4] trace-cmd: Document --tsc2nsec option Tzvetomir Stoyanov (VMware)
  2021-03-29 12:58 ` [PATCH 4/4] trace-cmd: Document --raw-ts option Tzvetomir Stoyanov (VMware)
  3 siblings, 0 replies; 6+ messages in thread
From: Tzvetomir Stoyanov (VMware) @ 2021-03-29 12:58 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

Extended the "trace-cmd list -C" command to show tsc2nsec clock, if
supported.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 tracecmd/trace-list.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/tracecmd/trace-list.c b/tracecmd/trace-list.c
index f017c938..63216b43 100644
--- a/tracecmd/trace-list.c
+++ b/tracecmd/trace-list.c
@@ -264,7 +264,21 @@ static void show_options(void)
 
 static void show_clocks(void)
 {
-	show_file("trace_clock");
+	char *clocks;
+	int size;
+
+	clocks = tracefs_instance_file_read(NULL, "trace_clock", &size);
+	if (!clocks)
+		die("getting clocks");
+	if (clocks[size - 1] == '\n')
+		clocks[size - 1] = 0;
+
+	if (trace_tsc2nsec_is_supported())
+		printf("%s %s\n", clocks, TSCNSEC_CLOCK);
+	else
+		printf("%s\n", clocks);
+
+	free(clocks);
 }
 
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] trace-cmd: Document --tsc2nsec option
  2021-03-29 12:58 [PATCH 0/4] Documented new trace-cmd options Tzvetomir Stoyanov (VMware)
  2021-03-29 12:58 ` [PATCH 1/4] trace-cmd: Add internal API to check if tsc2nsec is supported Tzvetomir Stoyanov (VMware)
  2021-03-29 12:58 ` [PATCH 2/4] trace-cmd: Add tsc2nsec clock to "list -C" command Tzvetomir Stoyanov (VMware)
@ 2021-03-29 12:58 ` Tzvetomir Stoyanov (VMware)
  2021-03-29 12:58 ` [PATCH 4/4] trace-cmd: Document --raw-ts option Tzvetomir Stoyanov (VMware)
  3 siblings, 0 replies; 6+ messages in thread
From: Tzvetomir Stoyanov (VMware) @ 2021-03-29 12:58 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

Document the "trace-cmd record --tsc2nsec" option.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 Documentation/trace-cmd/trace-cmd-record.1.txt | 5 +++++
 tracecmd/trace-usage.c                         | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/Documentation/trace-cmd/trace-cmd-record.1.txt b/Documentation/trace-cmd/trace-cmd-record.1.txt
index 643659ad..d992002e 100644
--- a/Documentation/trace-cmd/trace-cmd-record.1.txt
+++ b/Documentation/trace-cmd/trace-cmd-record.1.txt
@@ -349,6 +349,11 @@ OPTIONS
         at the beginning and at the end of the trace.
         Timestamps synchronization with guests works only if there is support for VSOCK.\n"
 
+*--tsc2nsec*::
+    Convert the current clock to nanoseconds, using tsc multiplier and shift from the Linux
+        kernel's perf interface. This option does not change the trace clock, just assumes that
+        the tsc multiplier and shift are applicable for the selected clock. You may use the
+        "-C tsc2nsec" clock, if not sure what clock to select.
 *--stderr*::
     Have output go to stderr instead of stdout, but the output of the command
     executed will not be changed. This is useful if you want to monitor the
diff --git a/tracecmd/trace-usage.c b/tracecmd/trace-usage.c
index 22537d20..386e88fe 100644
--- a/tracecmd/trace-usage.c
+++ b/tracecmd/trace-usage.c
@@ -62,6 +62,8 @@ static struct usage_help usage_help[] = {
 		"          --no-filter include trace-cmd threads in the trace\n"
 		"          --proc-map save the traced processes address map into the trace.dat file\n"
 		"          --user execute the specified [command ...] as given user\n"
+		"          --tsc2nsec Convert the current clock to nanoseconds, using tsc multiplier and shift from the Linux"
+		"               kernel's perf interface\n"
 		"          --tsync-interval set the loop interval, in ms, for timestamps synchronization with guests:"
 		"               If a negative number is specified, timestamps synchronization is disabled"
 		"               If 0 is specified, no loop is performed - timestamps offset is calculated only twice,"
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] trace-cmd: Document --raw-ts option
  2021-03-29 12:58 [PATCH 0/4] Documented new trace-cmd options Tzvetomir Stoyanov (VMware)
                   ` (2 preceding siblings ...)
  2021-03-29 12:58 ` [PATCH 3/4] trace-cmd: Document --tsc2nsec option Tzvetomir Stoyanov (VMware)
@ 2021-03-29 12:58 ` Tzvetomir Stoyanov (VMware)
  3 siblings, 0 replies; 6+ messages in thread
From: Tzvetomir Stoyanov (VMware) @ 2021-03-29 12:58 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

Documented "trace-cmd report --raw-ts" option

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 Documentation/trace-cmd/trace-cmd-report.1.txt | 3 +++
 tracecmd/trace-usage.c                         | 1 +
 2 files changed, 4 insertions(+)

diff --git a/Documentation/trace-cmd/trace-cmd-report.1.txt b/Documentation/trace-cmd/trace-cmd-report.1.txt
index 766c9a57..72b47065 100644
--- a/Documentation/trace-cmd/trace-cmd-report.1.txt
+++ b/Documentation/trace-cmd/trace-cmd-report.1.txt
@@ -309,6 +309,9 @@ OPTIONS
      Make sure no timestamp goes backwards, and if it does, print out a warning
      message of the fact.
 
+*--raw-ts*::
+     Display raw timestamps, without any corrections.
+
 EXAMPLES
 --------
 
diff --git a/tracecmd/trace-usage.c b/tracecmd/trace-usage.c
index 386e88fe..98247074 100644
--- a/tracecmd/trace-usage.c
+++ b/tracecmd/trace-usage.c
@@ -233,6 +233,7 @@ static struct usage_help usage_help[] = {
 		"                     previous data file, in which case it becomes default\n"
 		"          --ts-diff Show the delta timestamp between events.\n"
 		"          --ts-check Check to make sure no time stamp on any CPU goes backwards.\n"
+		"          --raw-ts Display raw timestamps, without any corrections.\n"
 	},
 	{
 		"stream",
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/4] trace-cmd: Add internal API to check if tsc2nsec is supported
  2021-03-29 12:58 ` [PATCH 1/4] trace-cmd: Add internal API to check if tsc2nsec is supported Tzvetomir Stoyanov (VMware)
@ 2021-03-30 21:37   ` Steven Rostedt
  0 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2021-03-30 21:37 UTC (permalink / raw)
  To: Tzvetomir Stoyanov (VMware); +Cc: linux-trace-devel

On Mon, 29 Mar 2021 15:58:18 +0300
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:

> A new internal API is added to check is tsc to nanoseconds conversion is
> supported:
>  bool trace_tsc2nsec_is_supported(void);
> 
> Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> ---
>  tracecmd/include/trace-local.h | 2 ++
>  tracecmd/trace-record.c        | 5 +++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/tracecmd/include/trace-local.h b/tracecmd/include/trace-local.h
> index 7773e9fc..6a4c5f51 100644
> --- a/tracecmd/include/trace-local.h
> +++ b/tracecmd/include/trace-local.h
> @@ -341,4 +341,6 @@ static inline bool is_digits(const char *s)
>  	return true;
>  }
>  
> +bool trace_tsc2nsec_is_supported(void);
> +
>  #endif /* __TRACE_LOCAL_H */
> diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
> index 5e69cf48..5c9d800f 100644
> --- a/tracecmd/trace-record.c
> +++ b/tracecmd/trace-record.c
> @@ -5827,6 +5827,11 @@ static int get_tsc_nsec(int *shift, int *mult)
>  }
>  #endif
>  
> +bool trace_tsc2nsec_is_supported(void)
> +{
> +	return (get_tsc_nsec(NULL, NULL) == 0);

Return is not a function, no need for the external parenthesis.

-- Steve

> +}
> +
>  static void parse_record_options(int argc,
>  				 char **argv,
>  				 enum trace_cmd curr_cmd,


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-30 21:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-29 12:58 [PATCH 0/4] Documented new trace-cmd options Tzvetomir Stoyanov (VMware)
2021-03-29 12:58 ` [PATCH 1/4] trace-cmd: Add internal API to check if tsc2nsec is supported Tzvetomir Stoyanov (VMware)
2021-03-30 21:37   ` Steven Rostedt
2021-03-29 12:58 ` [PATCH 2/4] trace-cmd: Add tsc2nsec clock to "list -C" command Tzvetomir Stoyanov (VMware)
2021-03-29 12:58 ` [PATCH 3/4] trace-cmd: Document --tsc2nsec option Tzvetomir Stoyanov (VMware)
2021-03-29 12:58 ` [PATCH 4/4] trace-cmd: Document --raw-ts option Tzvetomir Stoyanov (VMware)

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).