Commit 55c34ae0 authored by Tzvetomir Stoyanov's avatar Tzvetomir Stoyanov Committed by Arnaldo Carvalho de Melo

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: default avatarTzvetomir 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: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent fea6b632
...@@ -155,10 +155,10 @@ int tep_get_header_page_size(struct tep_handle *pevent) ...@@ -155,10 +155,10 @@ int tep_get_header_page_size(struct tep_handle *pevent)
} }
/** /**
* tep_get_header_timestamp_size - get size of the time stamp in the header page * tep_get_header_timestamp_size - get size of the timestamp in the header page
* @tep: a handle to the tep_handle * @tep: a handle to the tep_handle
* *
* This returns size of the time stamp in the header page * This returns size of the timestamp in the header page
* If @tep is NULL, 0 is returned. * If @tep is NULL, 0 is returned.
*/ */
int tep_get_header_timestamp_size(struct tep_handle *tep) int 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,17 +249,17 @@ void tep_set_page_size(struct tep_handle *pevent, int _page_size)
} }
/** /**
* tep_file_bigendian - get if the file is in big endian order * tep_is_file_bigendian - return the endian of the file
* @pevent: a handle to the tep_handle * @pevent: a handle to the tep_handle
* *
* This returns if the file is in big endian order * This returns true if the file is in big endian order
* If @pevent is NULL, 0 is returned. * If @pevent is NULL, false is returned.
*/ */
int tep_file_bigendian(struct tep_handle *pevent) bool tep_is_file_bigendian(struct tep_handle *pevent)
{ {
if (pevent) if (pevent)
return pevent->file_bigendian; return pevent->file_bigendian == TEP_BIG_ENDIAN;
return 0; return false;
} }
/** /**
...@@ -276,27 +276,27 @@ void tep_set_file_bigendian(struct tep_handle *pevent, enum tep_endian endian) ...@@ -276,27 +276,27 @@ void tep_set_file_bigendian(struct tep_handle *pevent, enum tep_endian endian)
} }
/** /**
* tep_is_host_bigendian - get if the order of the current host is big endian * tep_is_local_bigendian - return the endian of the saved local machine
* @pevent: a handle to the tep_handle * @pevent: a handle to the tep_handle
* *
* This gets if the order of the current host is big endian * This returns true if the saved local machine in @pevent is big endian.
* If @pevent is NULL, 0 is returned. * If @pevent is NULL, false is returned.
*/ */
int tep_is_host_bigendian(struct tep_handle *pevent) bool tep_is_local_bigendian(struct tep_handle *pevent)
{ {
if (pevent) if (pevent)
return pevent->host_bigendian; return pevent->host_bigendian == TEP_BIG_ENDIAN;
return 0; return 0;
} }
/** /**
* tep_set_host_bigendian - set the order of the local host * tep_set_local_bigendian - set the stored local machine endian order
* @pevent: a handle to the tep_handle * @pevent: a handle to the tep_handle
* @endian: non zero, if the local host has big endian order * @endian: non zero, if the local host has big endian order
* *
* This sets the order of the local host * This sets the endian order for the local machine.
*/ */
void tep_set_host_bigendian(struct tep_handle *pevent, enum tep_endian endian) void tep_set_local_bigendian(struct tep_handle *pevent, enum tep_endian endian)
{ {
if (pevent) if (pevent)
pevent->host_bigendian = endian; pevent->host_bigendian = endian;
...@@ -306,14 +306,14 @@ void tep_set_host_bigendian(struct tep_handle *pevent, enum tep_endian endian) ...@@ -306,14 +306,14 @@ void tep_set_host_bigendian(struct tep_handle *pevent, enum tep_endian endian)
* tep_is_latency_format - get if the latency output format is configured * tep_is_latency_format - get if the latency output format is configured
* @pevent: a handle to the tep_handle * @pevent: a handle to the tep_handle
* *
* This gets if the latency output format is configured * This returns true if the latency output format is configured
* If @pevent is NULL, 0 is returned. * If @pevent is NULL, false is returned.
*/ */
int tep_is_latency_format(struct tep_handle *pevent) bool tep_is_latency_format(struct tep_handle *pevent)
{ {
if (pevent) if (pevent)
return pevent->latency_format; return pevent->latency_format;
return 0; return false;
} }
/** /**
......
...@@ -199,23 +199,23 @@ static const char *find_cmdline(struct tep_handle *pevent, int pid) ...@@ -199,23 +199,23 @@ static const char *find_cmdline(struct tep_handle *pevent, int pid)
} }
/** /**
* tep_pid_is_registered - return if a pid has a cmdline registered * tep_is_pid_registered - return if a pid has a cmdline registered
* @pevent: handle for the pevent * @pevent: handle for the pevent
* @pid: The pid to check if it has a cmdline registered with. * @pid: The pid to check if it has a cmdline registered with.
* *
* Returns 1 if the pid has a cmdline mapped to it * Returns true if the pid has a cmdline mapped to it
* 0 otherwise. * false otherwise.
*/ */
int tep_pid_is_registered(struct tep_handle *pevent, int pid) bool tep_is_pid_registered(struct tep_handle *pevent, int pid)
{ {
const struct tep_cmdline *comm; const struct tep_cmdline *comm;
struct tep_cmdline key; struct tep_cmdline key;
if (!pid) if (!pid)
return 1; return true;
if (!pevent->cmdlines && cmdline_init(pevent)) if (!pevent->cmdlines && cmdline_init(pevent))
return 0; return false;
key.pid = pid; key.pid = pid;
...@@ -223,8 +223,8 @@ int tep_pid_is_registered(struct tep_handle *pevent, int pid) ...@@ -223,8 +223,8 @@ int tep_pid_is_registered(struct tep_handle *pevent, int pid)
sizeof(*pevent->cmdlines), cmdline_cmp); sizeof(*pevent->cmdlines), cmdline_cmp);
if (comm) if (comm)
return 1; return true;
return 0; return false;
} }
/* /*
...@@ -5172,7 +5172,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct tep_e ...@@ -5172,7 +5172,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct tep_e
} }
/** /**
* tep_data_lat_fmt - parse the data for the latency format * tep_data_latency_format - parse the data for the latency format
* @pevent: a handle to the pevent * @pevent: a handle to the pevent
* @s: the trace_seq to write to * @s: the trace_seq to write to
* @record: the record to read from * @record: the record to read from
...@@ -5181,7 +5181,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct tep_e ...@@ -5181,7 +5181,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct tep_e
* need rescheduling, in hard/soft interrupt, preempt count * need rescheduling, in hard/soft interrupt, preempt count
* and lock depth) and places it into the trace_seq. * and lock depth) and places it into the trace_seq.
*/ */
void tep_data_lat_fmt(struct tep_handle *pevent, void tep_data_latency_format(struct tep_handle *pevent,
struct trace_seq *s, struct tep_record *record) struct trace_seq *s, struct tep_record *record)
{ {
static int check_lock_depth = 1; static int check_lock_depth = 1;
...@@ -5532,7 +5532,7 @@ void tep_print_event_time(struct tep_handle *pevent, struct trace_seq *s, ...@@ -5532,7 +5532,7 @@ void tep_print_event_time(struct tep_handle *pevent, struct trace_seq *s,
} }
if (pevent->latency_format) { if (pevent->latency_format) {
tep_data_lat_fmt(pevent, s, record); tep_data_latency_format(pevent, s, record);
} }
if (use_usec_format) { if (use_usec_format) {
...@@ -6827,7 +6827,7 @@ struct tep_handle *tep_alloc(void) ...@@ -6827,7 +6827,7 @@ struct tep_handle *tep_alloc(void)
if (pevent) { if (pevent) {
pevent->ref_count = 1; pevent->ref_count = 1;
pevent->host_bigendian = tep_host_bigendian(); pevent->host_bigendian = tep_is_bigendian();
} }
return pevent; return pevent;
......
...@@ -412,7 +412,7 @@ void tep_set_flag(struct tep_handle *tep, int flag); ...@@ -412,7 +412,7 @@ void tep_set_flag(struct tep_handle *tep, int flag);
void tep_clear_flag(struct tep_handle *tep, enum tep_flag flag); void tep_clear_flag(struct tep_handle *tep, enum tep_flag flag);
bool tep_check_flags(struct tep_handle *tep, enum tep_flag flags); bool tep_check_flags(struct tep_handle *tep, enum tep_flag flags);
static inline int tep_host_bigendian(void) static inline int tep_is_bigendian(void)
{ {
unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 }; unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 };
unsigned int val; unsigned int val;
...@@ -440,7 +440,7 @@ int tep_register_function(struct tep_handle *pevent, char *name, ...@@ -440,7 +440,7 @@ int tep_register_function(struct tep_handle *pevent, char *name,
unsigned long long addr, char *mod); unsigned long long addr, char *mod);
int tep_register_print_string(struct tep_handle *pevent, const char *fmt, int tep_register_print_string(struct tep_handle *pevent, const char *fmt,
unsigned long long addr); unsigned long long addr);
int tep_pid_is_registered(struct tep_handle *pevent, int pid); bool tep_is_pid_registered(struct tep_handle *pevent, int pid);
void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s, void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s,
struct tep_event *event, struct tep_event *event,
...@@ -525,7 +525,7 @@ tep_find_event_by_name(struct tep_handle *pevent, const char *sys, const char *n ...@@ -525,7 +525,7 @@ tep_find_event_by_name(struct tep_handle *pevent, const char *sys, const char *n
struct tep_event * struct tep_event *
tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record); tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record);
void tep_data_lat_fmt(struct tep_handle *pevent, void tep_data_latency_format(struct tep_handle *pevent,
struct trace_seq *s, struct tep_record *record); struct trace_seq *s, struct tep_record *record);
int tep_data_type(struct tep_handle *pevent, struct tep_record *rec); int tep_data_type(struct tep_handle *pevent, struct tep_record *rec);
int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec); int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec);
...@@ -563,11 +563,11 @@ int tep_get_long_size(struct tep_handle *pevent); ...@@ -563,11 +563,11 @@ int tep_get_long_size(struct tep_handle *pevent);
void tep_set_long_size(struct tep_handle *pevent, int long_size); void tep_set_long_size(struct tep_handle *pevent, int long_size);
int tep_get_page_size(struct tep_handle *pevent); int tep_get_page_size(struct tep_handle *pevent);
void tep_set_page_size(struct tep_handle *pevent, int _page_size); void tep_set_page_size(struct tep_handle *pevent, int _page_size);
int tep_file_bigendian(struct tep_handle *pevent); bool tep_is_file_bigendian(struct tep_handle *pevent);
void tep_set_file_bigendian(struct tep_handle *pevent, enum tep_endian endian); void tep_set_file_bigendian(struct tep_handle *pevent, enum tep_endian endian);
int tep_is_host_bigendian(struct tep_handle *pevent); bool tep_is_local_bigendian(struct tep_handle *pevent);
void tep_set_host_bigendian(struct tep_handle *pevent, enum tep_endian endian); void tep_set_local_bigendian(struct tep_handle *pevent, enum tep_endian endian);
int tep_is_latency_format(struct tep_handle *pevent); bool tep_is_latency_format(struct tep_handle *pevent);
void tep_set_latency_format(struct tep_handle *pevent, int lat); void tep_set_latency_format(struct tep_handle *pevent, int lat);
int tep_get_header_page_size(struct tep_handle *pevent); int tep_get_header_page_size(struct tep_handle *pevent);
int tep_get_header_timestamp_size(struct tep_handle *tep); int tep_get_header_timestamp_size(struct tep_handle *tep);
......
...@@ -389,8 +389,8 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record, ...@@ -389,8 +389,8 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record,
* We can only use the structure if file is of the same * We can only use the structure if file is of the same
* endianness. * endianness.
*/ */
if (tep_file_bigendian(event->pevent) == if (tep_is_file_bigendian(event->pevent) ==
tep_is_host_bigendian(event->pevent)) { tep_is_local_bigendian(event->pevent)) {
trace_seq_printf(s, "%u q%u%s %s%s %spae %snxe %swp%s%s%s", trace_seq_printf(s, "%u q%u%s %s%s %spae %snxe %swp%s%s%s",
role.level, role.level,
......
...@@ -442,7 +442,7 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe) ...@@ -442,7 +442,7 @@ ssize_t trace_report(int fd, struct trace_event *tevent, bool __repipe)
tep_set_flag(pevent, TEP_NSEC_OUTPUT); tep_set_flag(pevent, TEP_NSEC_OUTPUT);
tep_set_file_bigendian(pevent, file_bigendian); tep_set_file_bigendian(pevent, file_bigendian);
tep_set_host_bigendian(pevent, host_bigendian); tep_set_local_bigendian(pevent, host_bigendian);
if (do_read(buf, 1) < 0) if (do_read(buf, 1) < 0)
goto out; goto out;
......
...@@ -40,7 +40,7 @@ int trace_event__init(struct trace_event *t) ...@@ -40,7 +40,7 @@ int trace_event__init(struct trace_event *t)
static int trace_event__init2(void) static int trace_event__init2(void)
{ {
int be = tep_host_bigendian(); int be = tep_is_bigendian();
struct tep_handle *pevent; struct tep_handle *pevent;
if (trace_event__init(&tevent)) if (trace_event__init(&tevent))
...@@ -49,7 +49,7 @@ static int trace_event__init2(void) ...@@ -49,7 +49,7 @@ static int trace_event__init2(void)
pevent = tevent.pevent; pevent = tevent.pevent;
tep_set_flag(pevent, TEP_NSEC_OUTPUT); tep_set_flag(pevent, TEP_NSEC_OUTPUT);
tep_set_file_bigendian(pevent, be); tep_set_file_bigendian(pevent, be);
tep_set_host_bigendian(pevent, be); tep_set_local_bigendian(pevent, be);
tevent_initialized = true; tevent_initialized = true;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment