summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTzvetomir Stoyanov <tstoyanov@vmware.com>2019-04-01 12:43:16 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-04-01 14:18:09 -0400
commit55c34ae076f62ed7ad0fc86cd8b697a6f577c431 (patch)
tree77d66317f332f4c3c848ef3ab8f7d4ab5b781a34
parentfea6b632235b9bedc58c72cd24f1865bb0c365db (diff)
tools tools, tools lib traceevent: Make traceevent APIs more consistent
Rename some traceevent APIs for consistency: tep_pid_is_registered() to tep_is_pid_registered() tep_file_bigendian() to tep_is_file_bigendian() to make the names and return values consistent with other tep_is_... APIs tep_data_lat_fmt() to tep_data_latency_format() to make the name more descriptive tep_host_bigendian() to tep_is_bigendian() tep_set_host_bigendian() to tep_set_local_bigendian() tep_is_host_bigendian() to tep_is_local_bigendian() "host" can be confused with VMs, and "local" is about the local machine. All tep_is_..._bigendian(struct tep_handle *tep) APIs return the saved data in the tep handle, while tep_is_bigendian() returns the running machine's endianness. All tep_is_... functions are modified to return bool value, instead of int. Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/20190327141946.4353-2-tstoyanov@vmware.com Link: http://lkml.kernel.org/r/20190401164344.288624897@goodmis.org [ Removed some extra parenthesis around return statements ] Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/lib/traceevent/event-parse-api.c40
-rw-r--r--tools/lib/traceevent/event-parse.c26
-rw-r--r--tools/lib/traceevent/event-parse.h16
-rw-r--r--tools/lib/traceevent/plugin_kvm.c4
-rw-r--r--tools/perf/util/trace-event-read.c2
-rw-r--r--tools/perf/util/trace-event.c4
6 files changed, 46 insertions, 46 deletions
diff --git a/tools/lib/traceevent/event-parse-api.c b/tools/lib/traceevent/event-parse-api.c
index 002b3f73862b..f7184575f0d9 100644
--- a/tools/lib/traceevent/event-parse-api.c
+++ b/tools/lib/traceevent/event-parse-api.c
@@ -155,10 +155,10 @@ int tep_get_header_page_size(struct tep_handle *pevent)
155} 155}
156 156
157/** 157/**
158 * tep_get_header_timestamp_size - get size of the time stamp in the header page 158 * tep_get_header_timestamp_size - get size of the timestamp in the header page
159 * @tep: a handle to the tep_handle 159 * @tep: a handle to the tep_handle
160 * 160 *
161 * This returns size of the time stamp in the header page 161 * This returns size of the timestamp in the header page
162 * If @tep is NULL, 0 is returned. 162 * If @tep is NULL, 0 is returned.
163 */ 163 */
164int tep_get_header_timestamp_size(struct tep_handle *tep) 164int tep_get_header_timestamp_size(struct tep_handle *tep)
@@ -249,17 +249,17 @@ void tep_set_page_size(struct tep_handle *pevent, int _page_size)
249} 249}
250 250
251/** 251/**
252 * tep_file_bigendian - get if the file is in big endian order 252 * tep_is_file_bigendian - return the endian of the file
253 * @pevent: a handle to the tep_handle 253 * @pevent: a handle to the tep_handle
254 * 254 *
255 * This returns if the file is in big endian order 255 * This returns true if the file is in big endian order
256 * If @pevent is NULL, 0 is returned. 256 * If @pevent is NULL, false is returned.
257 */ 257 */
258int tep_file_bigendian(struct tep_handle *pevent) 258bool tep_is_file_bigendian(struct tep_handle *pevent)
259{ 259{
260 if (pevent) 260 if (pevent)
261 return pevent->file_bigendian; 261 return pevent->file_bigendian == TEP_BIG_ENDIAN;
262 return 0; 262 return false;
263} 263}
264 264
265/** 265/**
@@ -276,27 +276,27 @@ void tep_set_file_bigendian(struct tep_handle *pevent, enum tep_endian endian)
276} 276}
277 277
278/** 278/**
279 * tep_is_host_bigendian - get if the order of the current host is big endian 279 * tep_is_local_bigendian - return the endian of the saved local machine
280 * @pevent: a handle to the tep_handle 280 * @pevent: a handle to the tep_handle
281 * 281 *
282 * This gets if the order of the current host is big endian 282 * This returns true if the saved local machine in @pevent is big endian.
283 * If @pevent is NULL, 0 is returned. 283 * If @pevent is NULL, false is returned.
284 */ 284 */
285int tep_is_host_bigendian(struct tep_handle *pevent) 285bool tep_is_local_bigendian(struct tep_handle *pevent)
286{ 286{
287 if (pevent) 287 if (pevent)
288 return pevent->host_bigendian; 288 return pevent->host_bigendian == TEP_BIG_ENDIAN;
289 return 0; 289 return 0;
290} 290}
291 291
292/** 292/**
293 * tep_set_host_bigendian - set the order of the local host 293 * tep_set_local_bigendian - set the stored local machine endian order
294 * @pevent: a handle to the tep_handle 294 * @pevent: a handle to the tep_handle
295 * @endian: non zero, if the local host has big endian order 295 * @endian: non zero, if the local host has big endian order
296 * 296 *
297 * This sets the order of the local host 297 * This sets the endian order for the local machine.
298 */ 298 */
299void tep_set_host_bigendian(struct tep_handle *pevent, enum tep_endian endian) 299void tep_set_local_bigendian(struct tep_handle *pevent, enum tep_endian endian)
300{ 300{
301 if (pevent) 301 if (pevent)
302 pevent->host_bigendian = endian; 302 pevent->host_bigendian = endian;
@@ -306,14 +306,14 @@ void tep_set_host_bigendian(struct tep_handle *pevent, enum tep_endian endian)
306 * tep_is_latency_format - get if the latency output format is configured 306 * tep_is_latency_format - get if the latency output format is configured
307 * @pevent: a handle to the tep_handle 307 * @pevent: a handle to the tep_handle
308 * 308 *
309 * This gets if the latency output format is configured 309 * This returns true if the latency output format is configured
310 * If @pevent is NULL, 0 is returned. 310 * If @pevent is NULL, false is returned.
311 */ 311 */
312int tep_is_latency_format(struct tep_handle *pevent) 312bool tep_is_latency_format(struct tep_handle *pevent)
313{ 313{
314 if (pevent) 314 if (pevent)
315 return pevent->latency_format; 315 return pevent->latency_format;
316 return 0; 316 return false;
317} 317}
318 318
319/** 319/**
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 000ab7514be7..8836702122be 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -199,23 +199,23 @@ static const char *find_cmdline(struct tep_handle *pevent, int pid)
199} 199}
200 200
201/** 201/**
202 * tep_pid_is_registered - return if a pid has a cmdline registered 202 * tep_is_pid_registered - return if a pid has a cmdline registered
203 * @pevent: handle for the pevent 203 * @pevent: handle for the pevent
204 * @pid: The pid to check if it has a cmdline registered with. 204 * @pid: The pid to check if it has a cmdline registered with.
205 * 205 *
206 * Returns 1 if the pid has a cmdline mapped to it 206 * Returns true if the pid has a cmdline mapped to it
207 * 0 otherwise. 207 * false otherwise.
208 */ 208 */
209int tep_pid_is_registered(struct tep_handle *pevent, int pid) 209bool tep_is_pid_registered(struct tep_handle *pevent, int pid)
210{ 210{
211 const struct tep_cmdline *comm; 211 const struct tep_cmdline *comm;
212 struct tep_cmdline key; 212 struct tep_cmdline key;
213 213
214 if (!pid) 214 if (!pid)
215 return 1; 215 return true;
216 216
217 if (!pevent->cmdlines && cmdline_init(pevent)) 217 if (!pevent->cmdlines && cmdline_init(pevent))
218 return 0; 218 return false;
219 219
220 key.pid = pid; 220 key.pid = pid;
221 221
@@ -223,8 +223,8 @@ int tep_pid_is_registered(struct tep_handle *pevent, int pid)
223 sizeof(*pevent->cmdlines), cmdline_cmp); 223 sizeof(*pevent->cmdlines), cmdline_cmp);
224 224
225 if (comm) 225 if (comm)
226 return 1; 226 return true;
227 return 0; 227 return false;
228} 228}
229 229
230/* 230/*
@@ -5172,7 +5172,7 @@ out_failed:
5172} 5172}
5173 5173
5174/** 5174/**
5175 * tep_data_lat_fmt - parse the data for the latency format 5175 * tep_data_latency_format - parse the data for the latency format
5176 * @pevent: a handle to the pevent 5176 * @pevent: a handle to the pevent
5177 * @s: the trace_seq to write to 5177 * @s: the trace_seq to write to
5178 * @record: the record to read from 5178 * @record: the record to read from
@@ -5181,8 +5181,8 @@ out_failed:
5181 * need rescheduling, in hard/soft interrupt, preempt count 5181 * need rescheduling, in hard/soft interrupt, preempt count
5182 * and lock depth) and places it into the trace_seq. 5182 * and lock depth) and places it into the trace_seq.
5183 */ 5183 */
5184void tep_data_lat_fmt(struct tep_handle *pevent, 5184void tep_data_latency_format(struct tep_handle *pevent,
5185 struct trace_seq *s, struct tep_record *record) 5185 struct trace_seq *s, struct tep_record *record)
5186{ 5186{
5187 static int check_lock_depth = 1; 5187 static int check_lock_depth = 1;
5188 static int check_migrate_disable = 1; 5188 static int check_migrate_disable = 1;
@@ -5532,7 +5532,7 @@ void tep_print_event_time(struct tep_handle *pevent, struct trace_seq *s,
5532 } 5532 }
5533 5533
5534 if (pevent->latency_format) { 5534 if (pevent->latency_format) {
5535 tep_data_lat_fmt(pevent, s, record); 5535 tep_data_latency_format(pevent, s, record);
5536 } 5536 }
5537 5537
5538 if (use_usec_format) { 5538 if (use_usec_format) {
@@ -6827,7 +6827,7 @@ struct tep_handle *tep_alloc(void)
6827 6827
6828 if (pevent) { 6828 if (pevent) {
6829 pevent->ref_count = 1; 6829 pevent->ref_count = 1;
6830 pevent->host_bigendian = tep_host_bigendian(); 6830 pevent->host_bigendian = tep_is_bigendian();
6831 } 6831 }
6832 6832
6833 return pevent; 6833 return pevent;
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 3833d1384599..d473dc557978 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -412,7 +412,7 @@ void tep_set_flag(struct tep_handle *tep, int flag);
412void tep_clear_flag(struct tep_handle *tep, enum tep_flag flag); 412void tep_clear_flag(struct tep_handle *tep, enum tep_flag flag);
413bool tep_check_flags(struct tep_handle *tep, enum tep_flag flags); 413bool tep_check_flags(struct tep_handle *tep, enum tep_flag flags);
414 414
415static inline int tep_host_bigendian(void) 415static inline int tep_is_bigendian(void)
416{ 416{
417 unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 }; 417 unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 };
418 unsigned int val; 418 unsigned int val;
@@ -440,7 +440,7 @@ int tep_register_function(struct tep_handle *pevent, char *name,
440 unsigned long long addr, char *mod); 440 unsigned long long addr, char *mod);
441int tep_register_print_string(struct tep_handle *pevent, const char *fmt, 441int tep_register_print_string(struct tep_handle *pevent, const char *fmt,
442 unsigned long long addr); 442 unsigned long long addr);
443int tep_pid_is_registered(struct tep_handle *pevent, int pid); 443bool tep_is_pid_registered(struct tep_handle *pevent, int pid);
444 444
445void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s, 445void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s,
446 struct tep_event *event, 446 struct tep_event *event,
@@ -525,8 +525,8 @@ tep_find_event_by_name(struct tep_handle *pevent, const char *sys, const char *n
525struct tep_event * 525struct tep_event *
526tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record); 526tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record);
527 527
528void tep_data_lat_fmt(struct tep_handle *pevent, 528void tep_data_latency_format(struct tep_handle *pevent,
529 struct trace_seq *s, struct tep_record *record); 529 struct trace_seq *s, struct tep_record *record);
530int tep_data_type(struct tep_handle *pevent, struct tep_record *rec); 530int tep_data_type(struct tep_handle *pevent, struct tep_record *rec);
531int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec); 531int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec);
532int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec); 532int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec);
@@ -563,11 +563,11 @@ int tep_get_long_size(struct tep_handle *pevent);
563void tep_set_long_size(struct tep_handle *pevent, int long_size); 563void tep_set_long_size(struct tep_handle *pevent, int long_size);
564int tep_get_page_size(struct tep_handle *pevent); 564int tep_get_page_size(struct tep_handle *pevent);
565void tep_set_page_size(struct tep_handle *pevent, int _page_size); 565void tep_set_page_size(struct tep_handle *pevent, int _page_size);
566int tep_file_bigendian(struct tep_handle *pevent); 566bool tep_is_file_bigendian(struct tep_handle *pevent);
567void tep_set_file_bigendian(struct tep_handle *pevent, enum tep_endian endian); 567void tep_set_file_bigendian(struct tep_handle *pevent, enum tep_endian endian);
568int tep_is_host_bigendian(struct tep_handle *pevent); 568bool tep_is_local_bigendian(struct tep_handle *pevent);
569void tep_set_host_bigendian(struct tep_handle *pevent, enum tep_endian endian); 569void tep_set_local_bigendian(struct tep_handle *pevent, enum tep_endian endian);
570int tep_is_latency_format(struct tep_handle *pevent); 570bool tep_is_latency_format(struct tep_handle *pevent);
571void tep_set_latency_format(struct tep_handle *pevent, int lat); 571void tep_set_latency_format(struct tep_handle *pevent, int lat);
572int tep_get_header_page_size(struct tep_handle *pevent); 572int tep_get_header_page_size(struct tep_handle *pevent);
573int tep_get_header_timestamp_size(struct tep_handle *tep); 573int tep_get_header_timestamp_size(struct tep_handle *tep);
diff --git a/tools/lib/traceevent/plugin_kvm.c b/tools/lib/traceevent/plugin_kvm.c
index 64b9c25a1fd3..688e5d97d7a7 100644
--- a/tools/lib/traceevent/plugin_kvm.c
+++ b/tools/lib/traceevent/plugin_kvm.c
@@ -389,8 +389,8 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record,
389 * We can only use the structure if file is of the same 389 * We can only use the structure if file is of the same
390 * endianness. 390 * endianness.
391 */ 391 */
392 if (tep_file_bigendian(event->pevent) == 392 if (tep_is_file_bigendian(event->pevent) ==
393 tep_is_host_bigendian(event->pevent)) { 393 tep_is_local_bigendian(event->pevent)) {
394 394
395 trace_seq_printf(s, "%u q%u%s %s%s %spae %snxe %swp%s%s%s", 395 trace_seq_printf(s, "%u q%u%s %s%s %spae %snxe %swp%s%s%s",
396 role.level, 396 role.level,
diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
index efe2f58cff4e..48d53d8e3e16 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -442,7 +442,7 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe)
442 442
443 tep_set_flag(pevent, TEP_NSEC_OUTPUT); 443 tep_set_flag(pevent, TEP_NSEC_OUTPUT);
444 tep_set_file_bigendian(pevent, file_bigendian); 444 tep_set_file_bigendian(pevent, file_bigendian);
445 tep_set_host_bigendian(pevent, host_bigendian); 445 tep_set_local_bigendian(pevent, host_bigendian);
446 446
447 if (do_read(buf, 1) < 0) 447 if (do_read(buf, 1) < 0)
448 goto out; 448 goto out;
diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c
index cbe0dd758e3a..01b9d89bf5bf 100644
--- a/tools/perf/util/trace-event.c
+++ b/tools/perf/util/trace-event.c
@@ -40,7 +40,7 @@ int trace_event__init(struct trace_event *t)
40 40
41static int trace_event__init2(void) 41static int trace_event__init2(void)
42{ 42{
43 int be = tep_host_bigendian(); 43 int be = tep_is_bigendian();
44 struct tep_handle *pevent; 44 struct tep_handle *pevent;
45 45
46 if (trace_event__init(&tevent)) 46 if (trace_event__init(&tevent))
@@ -49,7 +49,7 @@ static int trace_event__init2(void)
49 pevent = tevent.pevent; 49 pevent = tevent.pevent;
50 tep_set_flag(pevent, TEP_NSEC_OUTPUT); 50 tep_set_flag(pevent, TEP_NSEC_OUTPUT);
51 tep_set_file_bigendian(pevent, be); 51 tep_set_file_bigendian(pevent, be);
52 tep_set_host_bigendian(pevent, be); 52 tep_set_local_bigendian(pevent, be);
53 tevent_initialized = true; 53 tevent_initialized = true;
54 return 0; 54 return 0;
55} 55}