Man page - tracefs_buffer_stat_commit_overrun(3)
Packages contains this manual
- tracefs_instance_get_subbuf_size(3)
- tracefs_tracer_clear(3)
- tracefs_function_notrace(3)
- tracefs_instance_file_append(3)
- tracefs_hist_alloc_nd(3)
- tracefs_instance_get_affinity(3)
- tracefs_error_clear(3)
- tracefs_instance_get_dir(3)
- tracefs_filter_pid_function_clear(3)
- tracefs_buffer_stat_timestamp(3)
- tracefs_hist_add_key(3)
- tracefs_set_loglevel(3)
- tracefs_trace_pipe_stop(3)
- tracefs_instance_file_open(3)
- tracefs_iterate_stop(3)
- tracefs_synth_append_end_filter(3)
- tracefs_vprintf(3)
- tracefs_instance_put_stat(3)
- tracefs_hist_add_value(3)
- tracefs_cpu_read(3)
- tracefs_synth_free(3)
- tracefs_event_file_exists(3)
- tracefs_instance_clear(3)
- tracefs_event_enable(3)
- tracefs_dynevent_get(3)
- tracefs_synth_add_match_field(3)
- tracefs_mapped_is_supported(3)
- tracefs_list_add(3)
- tracefs_load_cmdlines(3)
- tracefs_instance_set_affinity_raw(3)
- libtracefs(3)
- tracefs_hist_set_sort_key(3)
- tracefs_event_filter_clear(3)
- tracefs_tracing_dir_is_mounted(3)
- tracefs_binary_write(3)
- tracefs_cpu_snapshot_open(3)
- tracefs_cpu_unmap(3)
- tracefs_synth_add_compare_field(3)
- tracefs_synth_show_event(3)
- tracefs_follow_event(3)
- tracefs_option_name(3)
- tracefs_instance_free(3)
- tracefs_synth_add_end_field(3)
- tracefs_uretprobe_alloc(3)
- tracefs_synth_snapshot(3)
- tracefs_hist_alloc_nd_cnt(3)
- tracefs_synth_trace(3)
- tracefs_option_mask_is_set(3)
- tracefs_buffer_stat_commit_overrun(3)
- tracefs_tracer_available(3)
- tracefs_instance_get_buffer_percent(3)
- tracefs_instance_file_read_number(3)
- tracefs_cpu_flush(3)
- tracefs_synth_get_name(3)
- tracefs_synth_get_event(3)
- tracefs_dir_exists(3)
- tracefs_printf(3)
- tracefs_event_systems(3)
- tracefs_error_all(3)
- tracefs_cpu_stop(3)
- tracefs_hist_alloc(3)
- tracefs_trace_on_get_fd(3)
- tracefs_instance_get_stat(3)
- tracefs_snapshot_snap(3)
- tracefs_buffer_stat_dropped_events(3)
- tracefs_event_disable(3)
- tracefs_hist_get_name(3)
- tracefs_iterate_snapshot_events(3)
- tracefs_synth_set_instance(3)
- tracefs_filter_string_verify(3)
- tracefs_trace_off(3)
- tracefs_synth_show_end_hist(3)
- tracefs_dynevent_info(3)
- tracefs_sql(3)
- tracefs_error_last(3)
- tracefs_dynevent_get_all(3)
- tracefs_file_exists(3)
- tracefs_synth_show_start_hist(3)
- tracefs_hist_add_sort_key(3)
- tracefs_instance_file_clear(3)
- tracefs_kprobe_raw(3)
- tracefs_dynevent_destroy_all(3)
- tracefs_dynevent_free(3)
- tracefs_cpu_open(3)
- tracefs_load_headers(3)
- tracefs_filter_pid_events_clear(3)
- tracefs_instance_tracers(3)
- tracefs_instance_reset(3)
- tracefs_tracers(3)
- tracefs_cpu_is_mapped(3)
- tracefs_hist_add_key_cnt(3)
- tracefs_debug_dir(3)
- tracefs_hist_add_name(3)
- tracefs_instance_destroy(3)
- tracefs_event_file_append(3)
- tracefs_buffer_stat_bytes(3)
- tracefs_cpu_flush_write(3)
- tracefs_instances(3)
- tracefs_cpu_close(3)
- tracefs_hist_destroy(3)
- tracefs_option_is_supported(3)
- tracefs_cpu_open_mapped(3)
- tracefs_buffer_stat_overrun(3)
- tracefs_dynevent_destroy(3)
- sqlhist(1)
- tracefs_instance_file_read(3)
- tracefs_cpu_read_buf(3)
- tracefs_instance_get_affinity_set(3)
- tracefs_snapshot_free(3)
- tracefs_instances_walk(3)
- tracefs_set_tracing_dir(3)
- tracefs_hist_pause(3)
- tracefs_synth_complete(3)
- tracefs_option_id(3)
- tracefs_cpu_free_fd(3)
- tracefs_hist_sort_key_direction(3)
- tracefs_hist_continue(3)
- tracefs_kretprobe_raw(3)
- tracefs_trace_on_fd(3)
- tracefs_synth_raw_fmt(3)
- tracefs_hist_echo_cmd(3)
- tracefs_time_conversion(3)
- tracefs_filter_pid_events(3)
- tracefs_hist_free(3)
- tracefs_hist_get_event(3)
- tracefs_buffer_stat_entries(3)
- tracefs_follow_missed_events(3)
- tracefs_synth_echo_cmd(3)
- tracefs_filter_pid_function(3)
- tracefs_get_clock(3)
- tracefs_get_tracing_file(3)
- tracefs_cpu_flush_buf(3)
- tracefs_options_get_enabled(3)
- tracefs_print_close(3)
- tracefs_local_events(3)
- tracefs_dynevent_list_free(3)
- tracefs_cpu_buffered_read_buf(3)
- tracefs_cpu_buffered_read(3)
- tracefs_trace_on(3)
- tracefs_event_file_clear(3)
- tracefs_option_enable(3)
- tracefs_snapshot_clear(3)
- tracefs_function_filter(3)
- tracefs_hist_append_filter(3)
- tracefs_list_free(3)
- tracefs_synth_add_start_field(3)
- tracefs_trace_pipe_print(3)
- tracefs_buffer_stat_read_events(3)
- tracefs_trace_is_on(3)
- tracefs_instance_set_buffer_size(3)
- tracefs_instance_get_affinity_raw(3)
- tracefs_hist_command(3)
- tracefs_instance_find_cid_pid(3)
- tracefs_follow_event_clear(3)
- tracefs_trace_pipe_stream(3)
- tracefs_event_is_enabled(3)
- tracefs_trace_off_fd(3)
- tracefs_cpu_read_size(3)
- tracefs_binary_close(3)
- tracefs_find_cid_pid(3)
- tracefs_instance_create(3)
- tracefs_instance_get_name(3)
- tracefs_buffer_stat_event_timestamp(3)
- tracefs_instance_set_affinity_set(3)
- tracefs_instance_get_file(3)
- tracefs_kprobe_alloc(3)
- tracefs_options_get_supported(3)
- tracefs_follow_missed_events_clear(3)
- tracefs_hist_start(3)
- tracefs_kretprobe_alloc(3)
- tracefs_hist_reset(3)
- tracefs_synth_destroy(3)
- tracefs_instance_get_buffer_size(3)
- tracefs_option_is_enabled(3)
- tracefs_binary_init(3)
- tracefs_instance_file_write(3)
- tracefs_instance_set_buffer_percent(3)
- tracefs_eprobe_alloc(3)
- tracefs_synth_create(3)
- tracefs_put_tracing_file(3)
- tracefs_event_filter_apply(3)
- tracefs_instance_alloc(3)
- tracefs_uprobe_alloc(3)
- tracefs_instance_get_trace_dir(3)
- tracefs_event_file_read(3)
- tracefs_option_disable(3)
- tracefs_iterate_raw_events(3)
- tracefs_event_file_write(3)
- tracefs_system_events(3)
- tracefs_fill_local_events(3)
- tracefs_cpu_map(3)
- tracefs_dynevent_get_event(3)
- tracefs_cpu_write(3)
- tracefs_dynevent_create(3)
- tracefs_synth_append_start_filter(3)
- tracefs_synth_get_start_hist(3)
- tracefs_instance_file_write_number(3)
- tracefs_list_size(3)
- tracefs_print_init(3)
- tracefs_filter_functions(3)
- tracefs_instance_exists(3)
- tracefs_instance_set_affinity(3)
- tracefs_options(3)
- tracefs_kprobe_destroy(3)
- tracefs_hist_get_system(3)
- tracefs_cpu_pipe(3)
- tracefs_hist_alloc_2d(3)
- tracefs_synth_save(3)
- tracefs_instance_set_subbuf_size(3)
- tracefs_filter_string_append(3)
- tracefs_cpu_alloc_fd(3)
- tracefs_event_get_file(3)
- tracefs_tracing_dir(3)
- tracefs_instance_is_new(3)
- tracefs_local_events_system(3)
- tracefs_tracer_set(3)
- tracefs_synth_alloc(3)
apt-get install libtracefs-doc
Manual
LIBTRACEFS
NAMESYNOPSIS
DESCRIPTION
RETURN VALUE
EXAMPLE
FILES
SEE ALSO
AUTHOR
REPORTING BUGS
LICENSE
RESOURCES
COPYING
NOTES
NAME
tracefs_instance_get_stat, tracefs_instance_put_stat, tracefs_buffer_stat_entries, tracefs_buffer_stat_overrun, tracefs_buffer_stat_commit_overrun, tracefs_buffer_stat_bytes, tracefs_buffer_stat_event_timestamp, tracefs_buffer_stat_timestamp, tracefs_buffer_stat_dropped_events, tracefs_buffer_stat_read_events - Handling tracing buffer stats
SYNOPSIS
#include <tracefs.h>
struct
tracefs_buffer_stat *
tracefs_instance_get_stat
(struct
tracefs_instance *
instance
, int
cpu
);
void
tracefs_instance_put_stat
(struct
tracefs_buffer_stat *
tstat
);
ssize_t
tracefs_buffer_stat_entries
(struct
tracefs_buffer_stat *
tstat
);
ssize_t
tracefs_buffer_stat_overrun
(struct
tracefs_buffer_stat *
tstat
);
ssize_t
tracefs_buffer_stat_commit_overrun
(struct
tracefs_buffer_stat *
tstat
);
ssize_t
tracefs_buffer_stat_bytes
(struct
tracefs_buffer_stat *
tstat
);
long long
tracefs_buffer_stat_event_timestamp
(struct
tracefs_buffer_stat *
tstat
);
long long
tracefs_buffer_stat_timestamp
(struct
tracefs_buffer_stat *
tstat
);
ssize_t
tracefs_buffer_stat_dropped_events
(struct
tracefs_buffer_stat *
tstat
);
ssize_t
tracefs_buffer_stat_read_events
(struct
tracefs_buffer_stat *
tstat
);
DESCRIPTION
This set of functions read and parse the tracefs/per_cpu/cpuX/stats file. These files hold the statistics of the per CPU ring buffer, such as how many events are in the ring buffer, how many have been read and so on.
The tracefs_instance_get_stat() function will read and parse a given statistics file for a given instance and cpu . As the ring buffer is split into per_cpu buffers, the information is only associated to the given cpu . The returned tracefs_buffer_stat pointer can be used with the other tracefs_buffer_stat functions and must be freed with tracefs_instance_put_stat() .
The tracefs_instance_put_stat() will free the resources allocated for the given stat that was created by tracefs_instance_get_stat() .
The tracefs_buffer_stat_entries() returns the number of events that are currently in the ring buffer associated with tstat .
The tracefs_buffer_stat_overrun() returns the number of events that were lost by the ring buffer writer overrunning the reader.
The tracefs_buffer_stat_commit_overrun() returns the number of events that were lost because the ring buffer was too small and an interrupt interrupted a lower context event being recorded and it added more events than the ring buffer could hold. Note this is not a common occurrence and when it happens it means that something was not set up properly.
The tracefs_buffer_stat_bytes() returns the number of bytes that the current events take up. Note, it includes the meta data for the events, but does not include the meta data for the sub-buffers.
The tracefs_buffer_stat_event_timestamp() returns the timestamp of the last event in the ring buffer.
The tracefs_buffer_stat_timestamp() returns the current timestamp of the ring buffer. Note, it is only read when tracefs_instance_get_stat() is called. It will have the timestamp of the ring buffer when that function was called.
The tracefs_buffer_stat_dropped_events() returns the number of events that were dropped if overwrite mode is disabled. It will show the events that were lost because the writer caught up to the reader and could not write any more events.
The tracefs_buffer_stat_read_events() returns the number of events that were consumed by a reader.
RETURN VALUE
The tracefs_instance_get_stat() returns a tracefs_buffer_stat structure that can be used to retrieve the statistics via the other functions. It must be freed with tracefs_instance_put_stat() .
The other functions that return different values from the tracefs_buffer_stat structure all return the value, or -1 if the value was not found.
EXAMPLE
#include
<stdlib.h>
#include <unistd.h>
#include <tracefs.h>
int main(int
argc, char **argv)
{
char *trace;
char buf[1000];
int ret;
int i;
for (i = 0; i
< sizeof(buf) - 1; i++) {
buf[i] = '0' + i % 10;
}
buf[i] = '\0';
tracefs_instance_clear(NULL);
for (i = 0; i
< 4; i++) {
ret = tracefs_printf(NULL, "%s\n", buf);
if (ret < 0)
perror("write");
}
trace =
tracefs_instance_file_read(NULL, "trace", NULL);
printf("%s\n", trace);
free(trace);
for (i = 0; i
< sysconf(_SC_NPROCESSORS_CONF); i++) {
struct tracefs_buffer_stat *tstat;
ssize_t entries, eread;
tstat =
tracefs_instance_get_stat(NULL, i);
if (!tstat)
continue;
entries =
tracefs_buffer_stat_entries(tstat);
eread = tracefs_buffer_stat_read_events(tstat);
if (!entries && !eread) {
tracefs_instance_put_stat(tstat);
continue;
}
printf("CPU:
%d\n", i);;
printf("\tentries: %zd\n", entries);
printf("\toverrun: %zd\n",
tracefs_buffer_stat_overrun(tstat));
printf("\tcommit_overrun: %zd\n",
tracefs_buffer_stat_commit_overrun(tstat));
printf("\tbytes: %zd\n",
tracefs_buffer_stat_bytes(tstat));
printf("\tevent_timestamp: %lld\n",
tracefs_buffer_stat_event_timestamp(tstat));
printf("\ttimestamp: %lld\n",
tracefs_buffer_stat_timestamp(tstat));
printf("\tdropped_events: %zd\n",
tracefs_buffer_stat_dropped_events(tstat));
printf("\tread_events: %zd\n", eread);
tracefs_instance_put_stat(tstat);
}
}
FILES
tracefs.h
Header file to include in order to have access to the
library APIs.
-ltracefs
Linker switch to add when building a program that uses the
library.
SEE ALSO
libtracefs (3), libtraceevent (3), trace-cmd (1)
AUTHOR
Steven Rostedt < rostedt@goodmis.org [1] >
REPORTING BUGS
Report bugs to < linux-trace-devel@vger.kernel.org [2] >
LICENSE
libtracefs is Free Software licensed under the GNU LGPL 2.1
RESOURCES
https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/
COPYING
Copyright (C) 2020 VMware, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).
NOTES
|
1. |
rostedt@goodmis.org |
mailto:rostedt@goodmis.org
|
2. |
linux-trace-devel@vger.kernel.org |
mailto:linux-trace-devel@vger.kernel.org