Skip to contentSkip to conversation

Documented new trace-cmd options

PATCH In review Tzvetomir Stoyanov (VMware) 2 participants 6 messages Mar 29, 2021 – Mar 30, 2021 Documentation

lore
Share & tools
lore
#0 lore raw

cover Documented new trace-cmd options

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(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/4 trace-cmd: Add internal API to check if tsc2nsec is supported

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

---
 tracecmd/include/trace-local.h | 2 ++
 tracecmd/trace-record.c        | 5 +++++
 2 files changed, 7 insertions(+)
tracecmd/include/trace-local.h +2 -0
index 7773e9fc..6a4c5f51 100644
@@ -341,4 +341,6 @@ static inline bool is_digits(const char *s)
 	return true;
 }
 
+bool trace_tsc2nsec_is_supported(void);
+
 #endif /* __TRACE_LOCAL_H */
tracecmd/trace-record.c +5 -0
index 5e69cf48..5c9d800f 100644
@@ -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,
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH 1/4] trace-cmd: Add internal API to check if tsc2nsec is supported

Quoted 26 lines · On Mon, 29 Mar 2021 15:58:18 +0300 "Tzvetomir Stoyanov (VMware)"…

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

---
 tracecmd/include/trace-local.h | 2 ++
 tracecmd/trace-record.c        | 5 +++++
 2 files changed, 7 insertions(+)
tracecmd/include/trace-local.h +2 -0
index 7773e9fc..6a4c5f51 100644
@@ -341,4 +341,6 @@ static inline bool is_digits(const char *s)
 	return true;
 }
 
+bool trace_tsc2nsec_is_supported(void);
+
 #endif /* __TRACE_LOCAL_H */
tracecmd/trace-record.c +0 -0
index 5e69cf48..5c9d800f 100644

tracecmd/trace-record.c static int get_tsc_nsec(int *shift, int *mult) · line 5832

Quoted 6 lines
tracecmd/trace-record.c +3 -0
@@ -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

Quoted 5 lines
tracecmd/trace-record.c +2 -0
+}
+
 static void parse_record_options(int argc,
 				 char **argv,
 				 enum trace_cmd curr_cmd,
#3 lore raw

PATCH 2/4 trace-cmd: Add tsc2nsec clock to "list -C" command

In reply to Tzvetomir Stoyanov (VMware)

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

---
 tracecmd/trace-list.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
tracecmd/trace-list.c +15 -1
index f017c938..63216b43 100644
@@ -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);
 }
 
 
Signature · 1 line
2.30.2
#4 lore raw

PATCH 3/4 trace-cmd: Document --tsc2nsec option

In reply to Tzvetomir Stoyanov (VMware)

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

---
 Documentation/trace-cmd/trace-cmd-record.1.txt | 5 +++++
 tracecmd/trace-usage.c                         | 2 ++
 2 files changed, 7 insertions(+)
Documentation/trace-cmd/trace-cmd-record.1.txt +5 -0
index 643659ad..d992002e 100644
@@ -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
tracecmd/trace-usage.c +2 -0
index 22537d20..386e88fe 100644
@@ -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,"
Signature · 1 line
2.30.2
#5 lore raw

PATCH 4/4 trace-cmd: Document --raw-ts option

In reply to Tzvetomir Stoyanov (VMware)

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

---
 Documentation/trace-cmd/trace-cmd-report.1.txt | 3 +++
 tracecmd/trace-usage.c                         | 1 +
 2 files changed, 4 insertions(+)
Documentation/trace-cmd/trace-cmd-report.1.txt +3 -0
index 766c9a57..72b47065 100644
@@ -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
 --------
 
tracecmd/trace-usage.c +1 -0
index 386e88fe..98247074 100644
@@ -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",
Signature · 1 line
2.30.2