[PATCH 1/3] libtracefs/sqlhist: Add -B option to use instances for histograms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>

As sqlhist can also create histograms, it should have a way to pass in an
instance value that would be used to create a histogram for a given
instance.

Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
---
 Documentation/libtracefs-sql.txt       | 28 +++++++++++++++++++++-----
 Documentation/libtracefs-sqlhist.txt.1 |  5 +++++
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/Documentation/libtracefs-sql.txt b/Documentation/libtracefs-sql.txt
index 3389090..6297e9a 100644
--- a/Documentation/libtracefs-sql.txt
+++ b/Documentation/libtracefs-sql.txt
@@ -330,7 +330,8 @@ enum action {
 
 #define ACTIONS ((ACTION_MAX - 1))
 
-static int do_sql(const char *buffer, const char *name, const char *var,
+static int do_sql(const char *instance_name,
+		  const char *buffer, const char *name, const char *var,
 		  const char *trace_dir, bool execute, int action,
 		  char **save_fields)
 {
@@ -409,15 +410,28 @@ static int do_sql(const char *buffer, const char *name, const char *var,
 		if (execute)
 			tracefs_synth_create(synth);
 	} else {
+		struct tracefs_instance *instance = NULL;
 		struct tracefs_hist *hist;
+
 		hist = tracefs_synth_get_start_hist(synth);
 		if (!hist) {
 			perror("get_start_hist");
 			exit(-1);
 		}
-		tracefs_hist_echo_cmd(&seq, NULL, hist, 0);
+		if (instance_name) {
+			if (execute)
+				instance = tracefs_instance_create(instance_name);
+			else
+				instance = tracefs_instance_alloc(trace_dir,
+								  instance_name);
+			if (!instance) {
+				perror("Failed to create instance");
+				exit(-1);
+			}
+		}
+		tracefs_hist_echo_cmd(&seq, instance, hist, 0);
 		if (execute)
-			tracefs_hist_start(NULL, hist);
+			tracefs_hist_start(instance, hist);
 	}
 
 	tracefs_synth_free(synth);
@@ -434,6 +448,7 @@ int main (int argc, char **argv)
 	char buf[BUFSIZ];
 	int buffer_size = 0;
 	const char *file = NULL;
+	const char *instance = NULL;
 	bool execute = false;
 	char **save_fields = NULL;
 	const char *name;
@@ -446,7 +461,7 @@ int main (int argc, char **argv)
 	int i;
 
 	for (;;) {
-		c = getopt(argc, argv, "ht:f:en:m:c:sS:T");
+		c = getopt(argc, argv, "ht:f:en:m:c:sS:TB:");
 		if (c == -1)
 			break;
 
@@ -488,6 +503,9 @@ int main (int argc, char **argv)
 		case 'T':
 			action |= ACTION_TRACE | ACTION_SNAPSHOT;
 			break;
+		case 'B':
+			instance = optarg;
+			break;
 		case 'n':
 			name = optarg;
 			break;
@@ -528,7 +546,7 @@ int main (int argc, char **argv)
 		}
 	}
 
-	do_sql(buffer, name, var, trace_dir, execute, action, save_fields);
+	do_sql(instance, buffer, name, var, trace_dir, execute, action, save_fields);
 	free(buffer);
 
 	return 0;
diff --git a/Documentation/libtracefs-sqlhist.txt.1 b/Documentation/libtracefs-sqlhist.txt.1
index 1e94ea4..875b250 100644
--- a/Documentation/libtracefs-sqlhist.txt.1
+++ b/Documentation/libtracefs-sqlhist.txt.1
@@ -88,6 +88,11 @@ OPTIONS
     Save the given fields. The fields must be fields of the "end" event given
     in the *SQL-select-command*
 
+*-B* 'instance'::
+    For simple statements that only produce a histogram, the instance given here
+    will be where the histogram will be created. This is ignored for full synthetic
+    event creation, as sythetic events have a global affect on all tracing instances,
+    where as, histograms only affect a single instance.
 
 EXAMPLES
 --------
-- 
2.31.1




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux