perf probe: Add --quiet option to suppress output result message
Add --quiet(-q) option to suppress output result message for --add, and --del options (Note that --lines/funcs/vars are not affected). This option is useful if you run the perf probe inside your scripts. Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Hemant Kumar <hemant@linux.vnet.ibm.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Link: http://lkml.kernel.org/r/20141027203131.21219.35170.stgit@localhost.localdomain Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
		
					parent
					
						
							
								2987e32f75
							
						
					
				
			
			
				commit
				
					
						5e17b28f1e
					
				
			
		
					 2 changed files with 20 additions and 9 deletions
				
			
		|  | @ -55,6 +55,7 @@ static struct { | ||||||
| 	bool show_funcs; | 	bool show_funcs; | ||||||
| 	bool mod_events; | 	bool mod_events; | ||||||
| 	bool uprobes; | 	bool uprobes; | ||||||
|  | 	bool quiet; | ||||||
| 	int nevents; | 	int nevents; | ||||||
| 	struct perf_probe_event events[MAX_PROBES]; | 	struct perf_probe_event events[MAX_PROBES]; | ||||||
| 	struct strlist *dellist; | 	struct strlist *dellist; | ||||||
|  | @ -315,6 +316,8 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) | ||||||
| 	struct option options[] = { | 	struct option options[] = { | ||||||
| 	OPT_INCR('v', "verbose", &verbose, | 	OPT_INCR('v', "verbose", &verbose, | ||||||
| 		    "be more verbose (show parsed arguments, etc)"), | 		    "be more verbose (show parsed arguments, etc)"), | ||||||
|  | 	OPT_BOOLEAN('q', "quiet", ¶ms.quiet, | ||||||
|  | 		    "be quiet (do not show any mesages)"), | ||||||
| 	OPT_BOOLEAN('l', "list", ¶ms.list_events, | 	OPT_BOOLEAN('l', "list", ¶ms.list_events, | ||||||
| 		    "list up current probe events"), | 		    "list up current probe events"), | ||||||
| 	OPT_CALLBACK('d', "del", NULL, "[GROUP:]EVENT", "delete a probe event.", | 	OPT_CALLBACK('d', "del", NULL, "[GROUP:]EVENT", "delete a probe event.", | ||||||
|  | @ -404,6 +407,14 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	if (params.quiet) { | ||||||
|  | 		if (verbose != 0) { | ||||||
|  | 			pr_err("  Error: -v and -q are exclusive.\n"); | ||||||
|  | 			return -EINVAL; | ||||||
|  | 		} | ||||||
|  | 		verbose = -1; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	if (params.max_probe_points == 0) | 	if (params.max_probe_points == 0) | ||||||
| 		params.max_probe_points = MAX_PROBES; | 		params.max_probe_points = MAX_PROBES; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1910,21 +1910,21 @@ static int show_perf_probe_event(struct perf_probe_event *pev, | ||||||
| 	if (ret < 0) | 	if (ret < 0) | ||||||
| 		return ret; | 		return ret; | ||||||
| 
 | 
 | ||||||
| 	printf("  %-20s (on %s", buf, place); | 	pr_info("  %-20s (on %s", buf, place); | ||||||
| 	if (module) | 	if (module) | ||||||
| 		printf(" in %s", module); | 		pr_info(" in %s", module); | ||||||
| 
 | 
 | ||||||
| 	if (pev->nargs > 0) { | 	if (pev->nargs > 0) { | ||||||
| 		printf(" with"); | 		pr_info(" with"); | ||||||
| 		for (i = 0; i < pev->nargs; i++) { | 		for (i = 0; i < pev->nargs; i++) { | ||||||
| 			ret = synthesize_perf_probe_arg(&pev->args[i], | 			ret = synthesize_perf_probe_arg(&pev->args[i], | ||||||
| 							buf, 128); | 							buf, 128); | ||||||
| 			if (ret < 0) | 			if (ret < 0) | ||||||
| 				break; | 				break; | ||||||
| 			printf(" %s", buf); | 			pr_info(" %s", buf); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	printf(")\n"); | 	pr_info(")\n"); | ||||||
| 	free(place); | 	free(place); | ||||||
| 	return ret; | 	return ret; | ||||||
| } | } | ||||||
|  | @ -2124,7 +2124,7 @@ static int __add_probe_trace_events(struct perf_probe_event *pev, | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	ret = 0; | 	ret = 0; | ||||||
| 	printf("Added new event%s\n", (ntevs > 1) ? "s:" : ":"); | 	pr_info("Added new event%s\n", (ntevs > 1) ? "s:" : ":"); | ||||||
| 	for (i = 0; i < ntevs; i++) { | 	for (i = 0; i < ntevs; i++) { | ||||||
| 		tev = &tevs[i]; | 		tev = &tevs[i]; | ||||||
| 		if (pev->event) | 		if (pev->event) | ||||||
|  | @ -2179,8 +2179,8 @@ static int __add_probe_trace_events(struct perf_probe_event *pev, | ||||||
| 
 | 
 | ||||||
| 	if (ret >= 0) { | 	if (ret >= 0) { | ||||||
| 		/* Show how to use the event. */ | 		/* Show how to use the event. */ | ||||||
| 		printf("\nYou can now use it in all perf tools, such as:\n\n"); | 		pr_info("\nYou can now use it in all perf tools, such as:\n\n"); | ||||||
| 		printf("\tperf record -e %s:%s -aR sleep 1\n\n", tev->group, | 		pr_info("\tperf record -e %s:%s -aR sleep 1\n\n", tev->group, | ||||||
| 			 tev->event); | 			 tev->event); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -2444,7 +2444,7 @@ static int __del_trace_probe_event(int fd, struct str_node *ent) | ||||||
| 		goto error; | 		goto error; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	printf("Removed event: %s\n", ent->s); | 	pr_info("Removed event: %s\n", ent->s); | ||||||
| 	return 0; | 	return 0; | ||||||
| error: | error: | ||||||
| 	pr_warning("Failed to delete event: %s\n", | 	pr_warning("Failed to delete event: %s\n", | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Masami Hiramatsu
				Masami Hiramatsu