Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull perf updates from Thomas Gleixner:
 "Kernel:
   - Improve kallsyms coverage
   - Add x86 entry trampolines to kcore
   - Fix ARM SPE handling
   - Correct PPC event post processing

  Tools:
   - Make the build system more robust
   - Small fixes and enhancements all over the place
   - Update kernel ABI header copies
   - Preparatory work for converting libtraceevnt to a shared library
   - License cleanups"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (100 commits)
  tools arch: Update arch/x86/lib/memcpy_64.S copy used in 'perf bench mem memcpy'
  tools arch x86: Update tools's copy of cpufeatures.h
  perf python: Fix pyrf_evlist__read_on_cpu() interface
  perf mmap: Store real cpu number in 'struct perf_mmap'
  perf tools: Remove ext from struct kmod_path
  perf tools: Add gzip_is_compressed function
  perf tools: Add lzma_is_compressed function
  perf tools: Add is_compressed callback to compressions array
  perf tools: Move the temp file processing into decompress_kmodule
  perf tools: Use compression id in decompress_kmodule()
  perf tools: Store compression id into struct dso
  perf tools: Add compression id into 'struct kmod_path'
  perf tools: Make is_supported_compression() static
  perf tools: Make decompress_to_file() function static
  perf tools: Get rid of dso__needs_decompress() call in __open_dso()
  perf tools: Get rid of dso__needs_decompress() call in symbol__disassemble()
  perf tools: Get rid of dso__needs_decompress() call in read_object_code()
  tools lib traceevent: Change to SPDX License format
  perf llvm: Allow passing options to llc in addition to clang
  perf parser: Improve error message for PMU address filters
  ...
This commit is contained in:
Linus Torvalds 2018-08-26 11:25:21 -07:00
commit d207ea8e74
93 changed files with 3270 additions and 1639 deletions

View File

@ -2,6 +2,8 @@
#include <linux/spinlock.h>
#include <linux/percpu.h>
#include <linux/kallsyms.h>
#include <linux/kcore.h>
#include <asm/cpu_entry_area.h>
#include <asm/pgtable.h>
@ -13,6 +15,7 @@ static DEFINE_PER_CPU_PAGE_ALIGNED(struct entry_stack_page, entry_stack_storage)
#ifdef CONFIG_X86_64
static DEFINE_PER_CPU_PAGE_ALIGNED(char, exception_stacks
[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]);
static DEFINE_PER_CPU(struct kcore_list, kcore_entry_trampoline);
#endif
struct cpu_entry_area *get_cpu_entry_area(int cpu)
@ -146,10 +149,40 @@ static void __init setup_cpu_entry_area(int cpu)
cea_set_pte(&get_cpu_entry_area(cpu)->entry_trampoline,
__pa_symbol(_entry_trampoline), PAGE_KERNEL_RX);
/*
* The cpu_entry_area alias addresses are not in the kernel binary
* so they do not show up in /proc/kcore normally. This adds entries
* for them manually.
*/
kclist_add_remap(&per_cpu(kcore_entry_trampoline, cpu),
_entry_trampoline,
&get_cpu_entry_area(cpu)->entry_trampoline, PAGE_SIZE);
#endif
percpu_setup_debug_store(cpu);
}
#ifdef CONFIG_X86_64
int arch_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
char *name)
{
unsigned int cpu, ncpu = 0;
if (symnum >= num_possible_cpus())
return -EINVAL;
for_each_possible_cpu(cpu) {
if (ncpu++ >= symnum)
break;
}
*value = (unsigned long)&get_cpu_entry_area(cpu)->entry_trampoline;
*type = 't';
strlcpy(name, "__entry_SYSCALL_64_trampoline", KSYM_NAME_LEN);
return 0;
}
#endif
static __init void setup_cpu_entry_area_ptes(void)
{
#ifdef CONFIG_X86_32

View File

@ -359,8 +359,11 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
phdr->p_type = PT_LOAD;
phdr->p_flags = PF_R | PF_W | PF_X;
phdr->p_offset = kc_vaddr_to_offset(m->addr) + data_offset;
phdr->p_vaddr = (size_t)m->addr;
if (m->type == KCORE_RAM)
if (m->type == KCORE_REMAP)
phdr->p_vaddr = (size_t)m->vaddr;
else
phdr->p_vaddr = (size_t)m->addr;
if (m->type == KCORE_RAM || m->type == KCORE_REMAP)
phdr->p_paddr = __pa(m->addr);
else if (m->type == KCORE_TEXT)
phdr->p_paddr = __pa_symbol(m->addr);

View File

@ -12,11 +12,13 @@ enum kcore_type {
KCORE_VMEMMAP,
KCORE_USER,
KCORE_OTHER,
KCORE_REMAP,
};
struct kcore_list {
struct list_head list;
unsigned long addr;
unsigned long vaddr;
size_t size;
int type;
};
@ -36,11 +38,22 @@ struct vmcoredd_node {
#ifdef CONFIG_PROC_KCORE
void __init kclist_add(struct kcore_list *, void *, size_t, int type);
static inline
void kclist_add_remap(struct kcore_list *m, void *addr, void *vaddr, size_t sz)
{
m->vaddr = (unsigned long)vaddr;
kclist_add(m, addr, sz, KCORE_REMAP);
}
#else
static inline
void kclist_add(struct kcore_list *new, void *addr, size_t size, int type)
{
}
static inline
void kclist_add_remap(struct kcore_list *m, void *addr, void *vaddr, size_t sz)
{
}
#endif
#endif /* _LINUX_KCORE_H */

View File

@ -432,6 +432,7 @@ int sprint_backtrace(char *buffer, unsigned long address)
/* To avoid using get_symbol_offset for every symbol, we carry prefix along. */
struct kallsym_iter {
loff_t pos;
loff_t pos_arch_end;
loff_t pos_mod_end;
loff_t pos_ftrace_mod_end;
unsigned long value;
@ -443,9 +444,29 @@ struct kallsym_iter {
int show_value;
};
int __weak arch_get_kallsym(unsigned int symnum, unsigned long *value,
char *type, char *name)
{
return -EINVAL;
}
static int get_ksymbol_arch(struct kallsym_iter *iter)
{
int ret = arch_get_kallsym(iter->pos - kallsyms_num_syms,
&iter->value, &iter->type,
iter->name);
if (ret < 0) {
iter->pos_arch_end = iter->pos;
return 0;
}
return 1;
}
static int get_ksymbol_mod(struct kallsym_iter *iter)
{
int ret = module_get_kallsym(iter->pos - kallsyms_num_syms,
int ret = module_get_kallsym(iter->pos - iter->pos_arch_end,
&iter->value, &iter->type,
iter->name, iter->module_name,
&iter->exported);
@ -501,32 +522,34 @@ static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
iter->nameoff = get_symbol_offset(new_pos);
iter->pos = new_pos;
if (new_pos == 0) {
iter->pos_arch_end = 0;
iter->pos_mod_end = 0;
iter->pos_ftrace_mod_end = 0;
}
}
/*
* The end position (last + 1) of each additional kallsyms section is recorded
* in iter->pos_..._end as each section is added, and so can be used to
* determine which get_ksymbol_...() function to call next.
*/
static int update_iter_mod(struct kallsym_iter *iter, loff_t pos)
{
iter->pos = pos;
if (iter->pos_ftrace_mod_end > 0 &&
iter->pos_ftrace_mod_end < iter->pos)
return get_ksymbol_bpf(iter);
if (iter->pos_mod_end > 0 &&
iter->pos_mod_end < iter->pos) {
if (!get_ksymbol_ftrace_mod(iter))
return get_ksymbol_bpf(iter);
if ((!iter->pos_arch_end || iter->pos_arch_end > pos) &&
get_ksymbol_arch(iter))
return 1;
}
if (!get_ksymbol_mod(iter)) {
if (!get_ksymbol_ftrace_mod(iter))
return get_ksymbol_bpf(iter);
}
if ((!iter->pos_mod_end || iter->pos_mod_end > pos) &&
get_ksymbol_mod(iter))
return 1;
return 1;
if ((!iter->pos_ftrace_mod_end || iter->pos_ftrace_mod_end > pos) &&
get_ksymbol_ftrace_mod(iter))
return 1;
return get_ksymbol_bpf(iter);
}
/* Returns false if pos at or past end of file. */

View File

@ -220,6 +220,7 @@
#define X86_FEATURE_STIBP ( 7*32+27) /* Single Thread Indirect Branch Predictors */
#define X86_FEATURE_ZEN ( 7*32+28) /* "" CPU is AMD family 0x17 (Zen) */
#define X86_FEATURE_L1TF_PTEINV ( 7*32+29) /* "" L1TF workaround PTE inversion */
#define X86_FEATURE_IBRS_ENHANCED ( 7*32+30) /* Enhanced IBRS */
/* Virtualization flags: Linux defined, word 8 */
#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */
@ -230,7 +231,7 @@
#define X86_FEATURE_VMMCALL ( 8*32+15) /* Prefer VMMCALL to VMCALL */
#define X86_FEATURE_XENPV ( 8*32+16) /* "" Xen paravirtual guest */
#define X86_FEATURE_EPT_AD ( 8*32+17) /* Intel Extended Page Table access-dirty bit */
/* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */
#define X86_FEATURE_FSGSBASE ( 9*32+ 0) /* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/

View File

@ -256,7 +256,7 @@ ENTRY(__memcpy_mcsafe)
/* Copy successful. Return zero */
.L_done_memcpy_trap:
xorq %rax, %rax
xorl %eax, %eax
ret
ENDPROC(__memcpy_mcsafe)
EXPORT_SYMBOL_GPL(__memcpy_mcsafe)

View File

@ -129,12 +129,12 @@ $(OUTPUT)liblockdep.a: $(LIB_IN)
tags: force
$(RM) tags
find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \
--regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
--regex-c++='/_PE\(([^,)]*).*/TEP_ERRNO__\1/'
TAGS: force
$(RM) TAGS
find . -name '*.[ch]' | xargs etags \
--regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/'
--regex='/_PE(\([^,)]*\).*/TEP_ERRNO__\1/'
define do_install
$(print_install) \

View File

@ -233,12 +233,12 @@ endef
tags: force
$(RM) tags
find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \
--regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
--regex-c++='/_PE\(([^,)]*).*/TEP_ERRNO__\1/'
TAGS: force
$(RM) TAGS
find . -name '*.[ch]' | xargs etags \
--regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/'
--regex='/_PE(\([^,)]*\).*/TEP_ERRNO__\1/'
define do_install_mkdir
if [ ! -d '$(DESTDIR_SQ)$1' ]; then \

File diff suppressed because it is too large Load Diff

View File

@ -41,7 +41,7 @@
#define DEBUG_RECORD 0
#endif
struct pevent_record {
struct tep_record {
unsigned long long ts;
unsigned long long offset;
long long missed_events; /* buffer dropped events before */
@ -53,8 +53,8 @@ struct pevent_record {
int locked; /* Do not free, even if ref_count is zero */
void *priv;
#if DEBUG_RECORD
struct pevent_record *prev;
struct pevent_record *next;
struct tep_record *prev;
struct tep_record *next;
long alloc_addr;
#endif
};
@ -98,19 +98,19 @@ extern int trace_seq_do_printf(struct trace_seq *s);
/* ----------------------- pevent ----------------------- */
struct pevent;
struct tep_handle;
struct event_format;
typedef int (*pevent_event_handler_func)(struct trace_seq *s,
struct pevent_record *record,
struct event_format *event,
void *context);
typedef int (*tep_event_handler_func)(struct trace_seq *s,
struct tep_record *record,
struct event_format *event,
void *context);
typedef int (*pevent_plugin_load_func)(struct pevent *pevent);
typedef int (*pevent_plugin_unload_func)(struct pevent *pevent);
typedef int (*tep_plugin_load_func)(struct tep_handle *pevent);
typedef int (*tep_plugin_unload_func)(struct tep_handle *pevent);
struct pevent_plugin_option {
struct pevent_plugin_option *next;
struct tep_plugin_option {
struct tep_plugin_option *next;
void *handle;
char *file;
char *name;
@ -124,20 +124,20 @@ struct pevent_plugin_option {
/*
* Plugin hooks that can be called:
*
* PEVENT_PLUGIN_LOADER: (required)
* TEP_PLUGIN_LOADER: (required)
* The function name to initialized the plugin.
*
* int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
* int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
*
* PEVENT_PLUGIN_UNLOADER: (optional)
* TEP_PLUGIN_UNLOADER: (optional)
* The function called just before unloading
*
* int PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
* int TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
*
* PEVENT_PLUGIN_OPTIONS: (optional)
* TEP_PLUGIN_OPTIONS: (optional)
* Plugin options that can be set before loading
*
* struct pevent_plugin_option PEVENT_PLUGIN_OPTIONS[] = {
* struct tep_plugin_option TEP_PLUGIN_OPTIONS[] = {
* {
* .name = "option-name",
* .plugin_alias = "override-file-name", (optional)
@ -158,19 +158,19 @@ struct pevent_plugin_option {
* .set will be processed. If .value is defined, then it is considered
* a string option and .set will be ignored.
*
* PEVENT_PLUGIN_ALIAS: (optional)
* TEP_PLUGIN_ALIAS: (optional)
* The name to use for finding options (uses filename if not defined)
*/
#define PEVENT_PLUGIN_LOADER pevent_plugin_loader
#define PEVENT_PLUGIN_UNLOADER pevent_plugin_unloader
#define PEVENT_PLUGIN_OPTIONS pevent_plugin_options
#define PEVENT_PLUGIN_ALIAS pevent_plugin_alias
#define TEP_PLUGIN_LOADER tep_plugin_loader
#define TEP_PLUGIN_UNLOADER tep_plugin_unloader
#define TEP_PLUGIN_OPTIONS tep_plugin_options
#define TEP_PLUGIN_ALIAS tep_plugin_alias
#define _MAKE_STR(x) #x
#define MAKE_STR(x) _MAKE_STR(x)
#define PEVENT_PLUGIN_LOADER_NAME MAKE_STR(PEVENT_PLUGIN_LOADER)
#define PEVENT_PLUGIN_UNLOADER_NAME MAKE_STR(PEVENT_PLUGIN_UNLOADER)
#define PEVENT_PLUGIN_OPTIONS_NAME MAKE_STR(PEVENT_PLUGIN_OPTIONS)
#define PEVENT_PLUGIN_ALIAS_NAME MAKE_STR(PEVENT_PLUGIN_ALIAS)
#define TEP_PLUGIN_LOADER_NAME MAKE_STR(TEP_PLUGIN_LOADER)
#define TEP_PLUGIN_UNLOADER_NAME MAKE_STR(TEP_PLUGIN_UNLOADER)
#define TEP_PLUGIN_OPTIONS_NAME MAKE_STR(TEP_PLUGIN_OPTIONS)
#define TEP_PLUGIN_ALIAS_NAME MAKE_STR(TEP_PLUGIN_ALIAS)
enum format_flags {
FIELD_IS_ARRAY = 1,
@ -269,10 +269,10 @@ struct print_arg_op {
struct print_arg *right;
};
struct pevent_function_handler;
struct tep_function_handler;
struct print_arg_func {
struct pevent_function_handler *func;
struct tep_function_handler *func;
struct print_arg *args;
};
@ -320,14 +320,14 @@ struct print_fmt {
};
struct event_format {
struct pevent *pevent;
struct tep_handle *pevent;
char *name;
int id;
int flags;
struct format format;
struct print_fmt print_fmt;
char *system;
pevent_event_handler_func handler;
tep_event_handler_func handler;
void *context;
};
@ -361,25 +361,25 @@ enum event_type {
EVENT_SQUOTE,
};
typedef unsigned long long (*pevent_func_handler)(struct trace_seq *s,
unsigned long long *args);
typedef unsigned long long (*tep_func_handler)(struct trace_seq *s,
unsigned long long *args);
enum pevent_func_arg_type {
PEVENT_FUNC_ARG_VOID,
PEVENT_FUNC_ARG_INT,
PEVENT_FUNC_ARG_LONG,
PEVENT_FUNC_ARG_STRING,
PEVENT_FUNC_ARG_PTR,
PEVENT_FUNC_ARG_MAX_TYPES
enum tep_func_arg_type {
TEP_FUNC_ARG_VOID,
TEP_FUNC_ARG_INT,
TEP_FUNC_ARG_LONG,
TEP_FUNC_ARG_STRING,
TEP_FUNC_ARG_PTR,
TEP_FUNC_ARG_MAX_TYPES
};
enum pevent_flag {
PEVENT_NSEC_OUTPUT = 1, /* output in NSECS */
PEVENT_DISABLE_SYS_PLUGINS = 1 << 1,
PEVENT_DISABLE_PLUGINS = 1 << 2,
enum tep_flag {
TEP_NSEC_OUTPUT = 1, /* output in NSECS */
TEP_DISABLE_SYS_PLUGINS = 1 << 1,
TEP_DISABLE_PLUGINS = 1 << 2,
};
#define PEVENT_ERRORS \
#define TEP_ERRORS \
_PE(MEM_ALLOC_FAILED, "failed to allocate memory"), \
_PE(PARSE_EVENT_FAILED, "failed to parse event"), \
_PE(READ_ID_FAILED, "failed to read event id"), \
@ -411,10 +411,10 @@ enum pevent_flag {
_PE(FILTER_MISS, "record does not match to filter")
#undef _PE
#define _PE(__code, __str) PEVENT_ERRNO__ ## __code
enum pevent_errno {
PEVENT_ERRNO__SUCCESS = 0,
PEVENT_ERRNO__FILTER_MATCH = PEVENT_ERRNO__SUCCESS,
#define _PE(__code, __str) TEP_ERRNO__ ## __code
enum tep_errno {
TEP_ERRNO__SUCCESS = 0,
TEP_ERRNO__FILTER_MATCH = TEP_ERRNO__SUCCESS,
/*
* Choose an arbitrary negative big number not to clash with standard
@ -423,11 +423,11 @@ enum pevent_errno {
*
* http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
*/
__PEVENT_ERRNO__START = -100000,
__TEP_ERRNO__START = -100000,
PEVENT_ERRORS,
TEP_ERRORS,
__PEVENT_ERRNO__END,
__TEP_ERRNO__END,
};
#undef _PE
@ -435,17 +435,17 @@ struct plugin_list;
#define INVALID_PLUGIN_LIST_OPTION ((char **)((unsigned long)-1))
struct plugin_list *traceevent_load_plugins(struct pevent *pevent);
void traceevent_unload_plugins(struct plugin_list *plugin_list,
struct pevent *pevent);
char **traceevent_plugin_list_options(void);
void traceevent_plugin_free_options_list(char **list);
int traceevent_plugin_add_options(const char *name,
struct pevent_plugin_option *options);
void traceevent_plugin_remove_options(struct pevent_plugin_option *options);
void traceevent_print_plugins(struct trace_seq *s,
const char *prefix, const char *suffix,
const struct plugin_list *list);
struct plugin_list *tep_load_plugins(struct tep_handle *pevent);
void tep_unload_plugins(struct plugin_list *plugin_list,
struct tep_handle *pevent);
char **tep_plugin_list_options(void);
void tep_plugin_free_options_list(char **list);
int tep_plugin_add_options(const char *name,
struct tep_plugin_option *options);
void tep_plugin_remove_options(struct tep_plugin_option *options);
void tep_print_plugins(struct trace_seq *s,
const char *prefix, const char *suffix,
const struct plugin_list *list);
struct cmdline;
struct cmdline_list;
@ -454,10 +454,10 @@ struct func_list;
struct event_handler;
struct func_resolver;
typedef char *(pevent_func_resolver_t)(void *priv,
unsigned long long *addrp, char **modp);
typedef char *(tep_func_resolver_t)(void *priv,
unsigned long long *addrp, char **modp);
struct pevent {
struct tep_handle {
int ref_count;
int header_page_ts_offset;
@ -524,7 +524,7 @@ struct pevent {
struct format_field *bprint_buf_field;
struct event_handler *handlers;
struct pevent_function_handler *func_handlers;
struct tep_function_handler *func_handlers;
/* cache */
struct event_format *last_event;
@ -532,13 +532,13 @@ struct pevent {
char *trace_clock;
};
static inline void pevent_set_flag(struct pevent *pevent, int flag)
static inline void tep_set_flag(struct tep_handle *pevent, int flag)
{
pevent->flags |= flag;
}
static inline unsigned short
__data2host2(struct pevent *pevent, unsigned short data)
__data2host2(struct tep_handle *pevent, unsigned short data)
{
unsigned short swap;
@ -552,7 +552,7 @@ __data2host2(struct pevent *pevent, unsigned short data)
}
static inline unsigned int
__data2host4(struct pevent *pevent, unsigned int data)
__data2host4(struct tep_handle *pevent, unsigned int data)
{
unsigned int swap;
@ -568,7 +568,7 @@ __data2host4(struct pevent *pevent, unsigned int data)
}
static inline unsigned long long
__data2host8(struct pevent *pevent, unsigned long long data)
__data2host8(struct tep_handle *pevent, unsigned long long data)
{
unsigned long long swap;
@ -597,7 +597,7 @@ __data2host8(struct pevent *pevent, unsigned long long data)
__data2host8(pevent, __val); \
})
static inline int traceevent_host_bigendian(void)
static inline int tep_host_bigendian(void)
{
unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 };
unsigned int val;
@ -615,198 +615,198 @@ enum trace_flag_type {
TRACE_FLAG_SOFTIRQ = 0x10,
};
int pevent_set_function_resolver(struct pevent *pevent,
pevent_func_resolver_t *func, void *priv);
void pevent_reset_function_resolver(struct pevent *pevent);
int pevent_register_comm(struct pevent *pevent, const char *comm, int pid);
int pevent_register_trace_clock(struct pevent *pevent, const char *trace_clock);
int pevent_register_function(struct pevent *pevent, char *name,
unsigned long long addr, char *mod);
int pevent_register_print_string(struct pevent *pevent, const char *fmt,
unsigned long long addr);
int pevent_pid_is_registered(struct pevent *pevent, int pid);
int tep_set_function_resolver(struct tep_handle *pevent,
tep_func_resolver_t *func, void *priv);
void tep_reset_function_resolver(struct tep_handle *pevent);
int tep_register_comm(struct tep_handle *pevent, const char *comm, int pid);
int tep_register_trace_clock(struct tep_handle *pevent, const char *trace_clock);
int tep_register_function(struct tep_handle *pevent, char *name,
unsigned long long addr, char *mod);
int tep_register_print_string(struct tep_handle *pevent, const char *fmt,
unsigned long long addr);
int tep_pid_is_registered(struct tep_handle *pevent, int pid);
void pevent_print_event_task(struct pevent *pevent, struct trace_seq *s,
struct event_format *event,
struct pevent_record *record);
void pevent_print_event_time(struct pevent *pevent, struct trace_seq *s,
struct event_format *event,
struct pevent_record *record,
bool use_trace_clock);
void pevent_print_event_data(struct pevent *pevent, struct trace_seq *s,
struct event_format *event,
struct pevent_record *record);
void pevent_print_event(struct pevent *pevent, struct trace_seq *s,
struct pevent_record *record, bool use_trace_clock);
void tep_print_event_task(struct tep_handle *pevent, struct trace_seq *s,
struct event_format *event,
struct tep_record *record);
void tep_print_event_time(struct tep_handle *pevent, struct trace_seq *s,
struct event_format *event,
struct tep_record *record,
bool use_trace_clock);
void tep_print_event_data(struct tep_handle *pevent, struct trace_seq *s,
struct event_format *event,
struct tep_record *record);
void tep_print_event(struct tep_handle *pevent, struct trace_seq *s,
struct tep_record *record, bool use_trace_clock);
int pevent_parse_header_page(struct pevent *pevent, char *buf, unsigned long size,
int long_size);
int tep_parse_header_page(struct tep_handle *pevent, char *buf, unsigned long size,
int long_size);
enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,
unsigned long size, const char *sys);
enum pevent_errno pevent_parse_format(struct pevent *pevent,
struct event_format **eventp,
const char *buf,
unsigned long size, const char *sys);
void pevent_free_format(struct event_format *event);
void pevent_free_format_field(struct format_field *field);
enum tep_errno tep_parse_event(struct tep_handle *pevent, const char *buf,
unsigned long size, const char *sys);
enum tep_errno tep_parse_format(struct tep_handle *pevent,
struct event_format **eventp,
const char *buf,
unsigned long size, const char *sys);
void tep_free_format(struct event_format *event);
void tep_free_format_field(struct format_field *field);
void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event,
const char *name, struct pevent_record *record,
int *len, int err);
void *tep_get_field_raw(struct trace_seq *s, struct event_format *event,
const char *name, struct tep_record *record,
int *len, int err);
int pevent_get_field_val(struct trace_seq *s, struct event_format *event,
const char *name, struct pevent_record *record,
unsigned long long *val, int err);
int pevent_get_common_field_val(struct trace_seq *s, struct event_format *event,
const char *name, struct pevent_record *record,
unsigned long long *val, int err);
int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event,
const char *name, struct pevent_record *record,
int tep_get_field_val(struct trace_seq *s, struct event_format *event,
const char *name, struct tep_record *record,
unsigned long long *val, int err);
int tep_get_common_field_val(struct trace_seq *s, struct event_format *event,
const char *name, struct tep_record *record,
unsigned long long *val, int err);
int tep_get_any_field_val(struct trace_seq *s, struct event_format *event,
const char *name, struct tep_record *record,
unsigned long long *val, int err);
int pevent_print_num_field(struct trace_seq *s, const char *fmt,
int tep_print_num_field(struct trace_seq *s, const char *fmt,
struct event_format *event, const char *name,
struct pevent_record *record, int err);
struct tep_record *record, int err);
int pevent_print_func_field(struct trace_seq *s, const char *fmt,
struct event_format *event, const char *name,
struct pevent_record *record, int err);
int tep_print_func_field(struct trace_seq *s, const char *fmt,
struct event_format *event, const char *name,
struct tep_record *record, int err);
int pevent_register_event_handler(struct pevent *pevent, int id,
const char *sys_name, const char *event_name,
pevent_event_handler_func func, void *context);
int pevent_unregister_event_handler(struct pevent *pevent, int id,
const char *sys_name, const char *event_name,
pevent_event_handler_func func, void *context);
int pevent_register_print_function(struct pevent *pevent,
pevent_func_handler func,
enum pevent_func_arg_type ret_type,
char *name, ...);
int pevent_unregister_print_function(struct pevent *pevent,
pevent_func_handler func, char *name);
int tep_register_event_handler(struct tep_handle *pevent, int id,
const char *sys_name, const char *event_name,
tep_event_handler_func func, void *context);
int tep_unregister_event_handler(struct tep_handle *pevent, int id,
const char *sys_name, const char *event_name,
tep_event_handler_func func, void *context);
int tep_register_print_function(struct tep_handle *pevent,
tep_func_handler func,
enum tep_func_arg_type ret_type,
char *name, ...);
int tep_unregister_print_function(struct tep_handle *pevent,
tep_func_handler func, char *name);
struct format_field *pevent_find_common_field(struct event_format *event, const char *name);
struct format_field *pevent_find_field(struct event_format *event, const char *name);
struct format_field *pevent_find_any_field(struct event_format *event, const char *name);
struct format_field *tep_find_common_field(struct event_format *event, const char *name);
struct format_field *tep_find_field(struct event_format *event, const char *name);
struct format_field *tep_find_any_field(struct event_format *event, const char *name);
const char *pevent_find_function(struct pevent *pevent, unsigned long long addr);
const char *tep_find_function(struct tep_handle *pevent, unsigned long long addr);
unsigned long long
pevent_find_function_address(struct pevent *pevent, unsigned long long addr);
unsigned long long pevent_read_number(struct pevent *pevent, const void *ptr, int size);
int pevent_read_number_field(struct format_field *field, const void *data,
unsigned long long *value);
tep_find_function_address(struct tep_handle *pevent, unsigned long long addr);
unsigned long long tep_read_number(struct tep_handle *pevent, const void *ptr, int size);
int tep_read_number_field(struct format_field *field, const void *data,
unsigned long long *value);
struct event_format *pevent_find_event(struct pevent *pevent, int id);
struct event_format *tep_find_event(struct tep_handle *pevent, int id);
struct event_format *
pevent_find_event_by_name(struct pevent *pevent, const char *sys, const char *name);
tep_find_event_by_name(struct tep_handle *pevent, const char *sys, const char *name);
struct event_format *
pevent_find_event_by_record(struct pevent *pevent, struct pevent_record *record);
tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record);
void pevent_data_lat_fmt(struct pevent *pevent,
struct trace_seq *s, struct pevent_record *record);
int pevent_data_type(struct pevent *pevent, struct pevent_record *rec);
struct event_format *pevent_data_event_from_type(struct pevent *pevent, int type);
int pevent_data_pid(struct pevent *pevent, struct pevent_record *rec);
int pevent_data_preempt_count(struct pevent *pevent, struct pevent_record *rec);
int pevent_data_flags(struct pevent *pevent, struct pevent_record *rec);
const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid);
void tep_data_lat_fmt(struct tep_handle *pevent,
struct trace_seq *s, struct tep_record *record);
int tep_data_type(struct tep_handle *pevent, struct tep_record *rec);
struct event_format *tep_data_event_from_type(struct tep_handle *pevent, int type);
int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec);
int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec);
int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec);
const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid);
struct cmdline;
struct cmdline *pevent_data_pid_from_comm(struct pevent *pevent, const char *comm,
struct cmdline *next);
int pevent_cmdline_pid(struct pevent *pevent, struct cmdline *cmdline);
struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm,
struct cmdline *next);
int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline);
void pevent_print_field(struct trace_seq *s, void *data,
struct format_field *field);
void pevent_print_fields(struct trace_seq *s, void *data,
int size __maybe_unused, struct event_format *event);
void pevent_event_info(struct trace_seq *s, struct event_format *event,
struct pevent_record *record);
int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum,
void tep_print_field(struct trace_seq *s, void *data,
struct format_field *field);
void tep_print_fields(struct trace_seq *s, void *data,
int size __maybe_unused, struct event_format *event);
void tep_event_info(struct trace_seq *s, struct event_format *event,
struct tep_record *record);
int tep_strerror(struct tep_handle *pevent, enum tep_errno errnum,
char *buf, size_t buflen);
struct event_format **pevent_list_events(struct pevent *pevent, enum event_sort_type);
struct format_field **pevent_event_common_fields(struct event_format *event);
struct format_field **pevent_event_fields(struct event_format *event);
struct event_format **tep_list_events(struct tep_handle *pevent, enum event_sort_type);
struct format_field **tep_event_common_fields(struct event_format *event);
struct format_field **tep_event_fields(struct event_format *event);
static inline int pevent_get_cpus(struct pevent *pevent)
static inline int tep_get_cpus(struct tep_handle *pevent)
{
return pevent->cpus;
}
static inline void pevent_set_cpus(struct pevent *pevent, int cpus)
static inline void tep_set_cpus(struct tep_handle *pevent, int cpus)
{
pevent->cpus = cpus;
}
static inline int pevent_get_long_size(struct pevent *pevent)
static inline int tep_get_long_size(struct tep_handle *pevent)
{
return pevent->long_size;
}
static inline void pevent_set_long_size(struct pevent *pevent, int long_size)
static inline void tep_set_long_size(struct tep_handle *pevent, int long_size)
{
pevent->long_size = long_size;
}
static inline int pevent_get_page_size(struct pevent *pevent)
static inline int tep_get_page_size(struct tep_handle *pevent)
{
return pevent->page_size;
}
static inline void pevent_set_page_size(struct pevent *pevent, int _page_size)
static inline void tep_set_page_size(struct tep_handle *pevent, int _page_size)
{
pevent->page_size = _page_size;
}
static inline int pevent_is_file_bigendian(struct pevent *pevent)
static inline int tep_is_file_bigendian(struct tep_handle *pevent)
{
return pevent->file_bigendian;
}
static inline void pevent_set_file_bigendian(struct pevent *pevent, int endian)
static inline void tep_set_file_bigendian(struct tep_handle *pevent, int endian)
{
pevent->file_bigendian = endian;
}
static inline int pevent_is_host_bigendian(struct pevent *pevent)
static inline int tep_is_host_bigendian(struct tep_handle *pevent)
{
return pevent->host_bigendian;
}
static inline void pevent_set_host_bigendian(struct pevent *pevent, int endian)
static inline void tep_set_host_bigendian(struct tep_handle *pevent, int endian)
{
pevent->host_bigendian = endian;
}
static inline int pevent_is_latency_format(struct pevent *pevent)
static inline int tep_is_latency_format(struct tep_handle *pevent)
{
return pevent->latency_format;
}
static inline void pevent_set_latency_format(struct pevent *pevent, int lat)
static inline void tep_set_latency_format(struct tep_handle *pevent, int lat)
{
pevent->latency_format = lat;
}
struct pevent *pevent_alloc(void);
void pevent_free(struct pevent *pevent);
void pevent_ref(struct pevent *pevent);
void pevent_unref(struct pevent *pevent);
struct tep_handle *tep_alloc(void);
void tep_free(struct tep_handle *pevent);
void tep_ref(struct tep_handle *pevent);
void tep_unref(struct tep_handle *pevent);
/* access to the internal parser */
void pevent_buffer_init(const char *buf, unsigned long long size);
enum event_type pevent_read_token(char **tok);
void pevent_free_token(char *token);
int pevent_peek_char(void);
const char *pevent_get_input_buf(void);
unsigned long long pevent_get_input_buf_ptr(void);
void tep_buffer_init(const char *buf, unsigned long long size);
enum event_type tep_read_token(char **tok);
void tep_free_token(char *token);
int tep_peek_char(void);
const char *tep_get_input_buf(void);
unsigned long long tep_get_input_buf_ptr(void);
/* for debugging */
void pevent_print_funcs(struct pevent *pevent);
void pevent_print_printk(struct pevent *pevent);
void tep_print_funcs(struct tep_handle *pevent);
void tep_print_printk(struct tep_handle *pevent);
/* ----------------------- filtering ----------------------- */
@ -930,22 +930,22 @@ struct filter_type {
struct filter_arg *filter;
};
#define PEVENT_FILTER_ERROR_BUFSZ 1024
#define TEP_FILTER_ERROR_BUFSZ 1024
struct event_filter {
struct pevent *pevent;
struct tep_handle *pevent;
int filters;
struct filter_type *event_filters;
char error_buffer[PEVENT_FILTER_ERROR_BUFSZ];
char error_buffer[TEP_FILTER_ERROR_BUFSZ];
};
struct event_filter *pevent_filter_alloc(struct pevent *pevent);
struct event_filter *tep_filter_alloc(struct tep_handle *pevent);
/* for backward compatibility */
#define FILTER_NONE PEVENT_ERRNO__NO_FILTER
#define FILTER_NOEXIST PEVENT_ERRNO__FILTER_NOT_FOUND
#define FILTER_MISS PEVENT_ERRNO__FILTER_MISS
#define FILTER_MATCH PEVENT_ERRNO__FILTER_MATCH
#define FILTER_NONE TEP_ERRNO__NO_FILTER
#define FILTER_NOEXIST TEP_ERRNO__FILTER_NOT_FOUND
#define FILTER_MISS TEP_ERRNO__FILTER_MISS
#define FILTER_MATCH TEP_ERRNO__FILTER_MATCH
enum filter_trivial_type {
FILTER_TRIVIAL_FALSE,
@ -953,39 +953,39 @@ enum filter_trivial_type {
FILTER_TRIVIAL_BOTH,
};
enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter,
const char *filter_str);
enum tep_errno tep_filter_add_filter_str(struct event_filter *filter,
const char *filter_str);
enum pevent_errno pevent_filter_match(struct event_filter *filter,
struct pevent_record *record);
enum tep_errno tep_filter_match(struct event_filter *filter,
struct tep_record *record);
int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err,
char *buf, size_t buflen);
int tep_filter_strerror(struct event_filter *filter, enum tep_errno err,
char *buf, size_t buflen);
int pevent_event_filtered(struct event_filter *filter,
int event_id);
int tep_event_filtered(struct event_filter *filter,
int event_id);
void pevent_filter_reset(struct event_filter *filter);
void tep_filter_reset(struct event_filter *filter);
int pevent_filter_clear_trivial(struct event_filter *filter,
int tep_filter_clear_trivial(struct event_filter *filter,
enum filter_trivial_type type);
void tep_filter_free(struct event_filter *filter);
char *tep_filter_make_string(struct event_filter *filter, int event_id);
int tep_filter_remove_event(struct event_filter *filter,
int event_id);
int tep_filter_event_has_trivial(struct event_filter *filter,
int event_id,
enum filter_trivial_type type);
void pevent_filter_free(struct event_filter *filter);
int tep_filter_copy(struct event_filter *dest, struct event_filter *source);
char *pevent_filter_make_string(struct event_filter *filter, int event_id);
int tep_update_trivial(struct event_filter *dest, struct event_filter *source,
enum filter_trivial_type type);
int pevent_filter_remove_event(struct event_filter *filter,
int event_id);
int pevent_filter_event_has_trivial(struct event_filter *filter,
int event_id,
enum filter_trivial_type type);
int pevent_filter_copy(struct event_filter *dest, struct event_filter *source);
int pevent_update_trivial(struct event_filter *dest, struct event_filter *source,
enum filter_trivial_type type);
int pevent_filter_compare(struct event_filter *filter1, struct event_filter *filter2);
int tep_filter_compare(struct event_filter *filter1, struct event_filter *filter2);
#endif /* _PARSE_EVENTS_H */

View File

@ -1,21 +1,7 @@
// SPDX-License-Identifier: LGPL-2.1
/*
* Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License (not later!)
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see <http://www.gnu.org/licenses>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#include <ctype.h>
@ -34,7 +20,7 @@
static struct registered_plugin_options {
struct registered_plugin_options *next;
struct pevent_plugin_option *options;
struct tep_plugin_option *options;
} *registered_options;
static struct trace_plugin_options {
@ -58,7 +44,7 @@ static void lower_case(char *str)
*str = tolower(*str);
}
static int update_option_value(struct pevent_plugin_option *op, const char *val)
static int update_option_value(struct tep_plugin_option *op, const char *val)
{
char *op_val;
@ -97,7 +83,7 @@ static int update_option_value(struct pevent_plugin_option *op, const char *val)
}
/**
* traceevent_plugin_list_options - get list of plugin options
* tep_plugin_list_options - get list of plugin options
*
* Returns an array of char strings that list the currently registered
* plugin options in the format of <plugin>:<option>. This list can be
@ -106,12 +92,12 @@ static int update_option_value(struct pevent_plugin_option *op, const char *val)
* Returns NULL if there's no options registered. On error it returns
* INVALID_PLUGIN_LIST_OPTION
*
* Must be freed with traceevent_plugin_free_options_list().
* Must be freed with tep_plugin_free_options_list().
*/
char **traceevent_plugin_list_options(void)
char **tep_plugin_list_options(void)
{
struct registered_plugin_options *reg;
struct pevent_plugin_option *op;
struct tep_plugin_option *op;
char **list = NULL;
char *name;
int count = 0;
@ -146,7 +132,7 @@ char **traceevent_plugin_list_options(void)
return INVALID_PLUGIN_LIST_OPTION;
}
void traceevent_plugin_free_options_list(char **list)
void tep_plugin_free_options_list(char **list)
{
int i;
@ -163,7 +149,7 @@ void traceevent_plugin_free_options_list(char **list)
}
static int
update_option(const char *file, struct pevent_plugin_option *option)
update_option(const char *file, struct tep_plugin_option *option)
{
struct trace_plugin_options *op;
char *plugin;
@ -215,14 +201,14 @@ update_option(const char *file, struct pevent_plugin_option *option)
}
/**
* traceevent_plugin_add_options - Add a set of options by a plugin
* tep_plugin_add_options - Add a set of options by a plugin
* @name: The name of the plugin adding the options
* @options: The set of options being loaded
*
* Sets the options with the values that have been added by user.
*/
int traceevent_plugin_add_options(const char *name,
struct pevent_plugin_option *options)
int tep_plugin_add_options(const char *name,
struct tep_plugin_option *options)
{
struct registered_plugin_options *reg;
@ -241,10 +227,10 @@ int traceevent_plugin_add_options(const char *name,
}
/**
* traceevent_plugin_remove_options - remove plugin options that were registered
* @options: Options to removed that were registered with traceevent_plugin_add_options
* tep_plugin_remove_options - remove plugin options that were registered
* @options: Options to removed that were registered with tep_plugin_add_options
*/
void traceevent_plugin_remove_options(struct pevent_plugin_option *options)
void tep_plugin_remove_options(struct tep_plugin_option *options)
{
struct registered_plugin_options **last;
struct registered_plugin_options *reg;
@ -260,19 +246,19 @@ void traceevent_plugin_remove_options(struct pevent_plugin_option *options)
}
/**
* traceevent_print_plugins - print out the list of plugins loaded
* tep_print_plugins - print out the list of plugins loaded
* @s: the trace_seq descripter to write to
* @prefix: The prefix string to add before listing the option name
* @suffix: The suffix string ot append after the option name
* @list: The list of plugins (usually returned by traceevent_load_plugins()
* @list: The list of plugins (usually returned by tep_load_plugins()
*
* Writes to the trace_seq @s the list of plugins (files) that is
* returned by traceevent_load_plugins(). Use @prefix and @suffix for formating:
* returned by tep_load_plugins(). Use @prefix and @suffix for formating:
* @prefix = " ", @suffix = "\n".
*/
void traceevent_print_plugins(struct trace_seq *s,
const char *prefix, const char *suffix,
const struct plugin_list *list)
void tep_print_plugins(struct trace_seq *s,
const char *prefix, const char *suffix,
const struct plugin_list *list)
{
while (list) {
trace_seq_printf(s, "%s%s%s", prefix, list->name, suffix);
@ -281,11 +267,11 @@ void traceevent_print_plugins(struct trace_seq *s,
}
static void
load_plugin(struct pevent *pevent, const char *path,
load_plugin(struct tep_handle *pevent, const char *path,
const char *file, void *data)
{
struct plugin_list **plugin_list = data;
pevent_plugin_load_func func;
tep_plugin_load_func func;
struct plugin_list *list;
const char *alias;
char *plugin;
@ -305,14 +291,14 @@ load_plugin(struct pevent *pevent, const char *path,
goto out_free;
}
alias = dlsym(handle, PEVENT_PLUGIN_ALIAS_NAME);
alias = dlsym(handle, TEP_PLUGIN_ALIAS_NAME);
if (!alias)
alias = file;
func = dlsym(handle, PEVENT_PLUGIN_LOADER_NAME);
func = dlsym(handle, TEP_PLUGIN_LOADER_NAME);
if (!func) {
warning("could not find func '%s' in plugin '%s'\n%s\n",
PEVENT_PLUGIN_LOADER_NAME, plugin, dlerror());
TEP_PLUGIN_LOADER_NAME, plugin, dlerror());
goto out_free;
}
@ -336,9 +322,9 @@ load_plugin(struct pevent *pevent, const char *path,
}
static void
load_plugins_dir(struct pevent *pevent, const char *suffix,
load_plugins_dir(struct tep_handle *pevent, const char *suffix,
const char *path,
void (*load_plugin)(struct pevent *pevent,
void (*load_plugin)(struct tep_handle *pevent,
const char *path,
const char *name,
void *data),
@ -378,8 +364,8 @@ load_plugins_dir(struct pevent *pevent, const char *suffix,
}
static void
load_plugins(struct pevent *pevent, const char *suffix,
void (*load_plugin)(struct pevent *pevent,
load_plugins(struct tep_handle *pevent, const char *suffix,
void (*load_plugin)(struct tep_handle *pevent,
const char *path,
const char *name,
void *data),
@ -390,7 +376,7 @@ load_plugins(struct pevent *pevent, const char *suffix,
char *envdir;
int ret;
if (pevent->flags & PEVENT_DISABLE_PLUGINS)
if (pevent->flags & TEP_DISABLE_PLUGINS)
return;
/*
@ -398,7 +384,7 @@ load_plugins(struct pevent *pevent, const char *suffix,
* check that first.
*/
#ifdef PLUGIN_DIR
if (!(pevent->flags & PEVENT_DISABLE_SYS_PLUGINS))
if (!(pevent->flags & TEP_DISABLE_SYS_PLUGINS))
load_plugins_dir(pevent, suffix, PLUGIN_DIR,
load_plugin, data);
#endif
@ -431,7 +417,7 @@ load_plugins(struct pevent *pevent, const char *suffix,
}
struct plugin_list*
traceevent_load_plugins(struct pevent *pevent)
tep_load_plugins(struct tep_handle *pevent)
{
struct plugin_list *list = NULL;
@ -440,15 +426,15 @@ traceevent_load_plugins(struct pevent *pevent)
}
void
traceevent_unload_plugins(struct plugin_list *plugin_list, struct pevent *pevent)
tep_unload_plugins(struct plugin_list *plugin_list, struct tep_handle *pevent)
{
pevent_plugin_unload_func func;
tep_plugin_unload_func func;
struct plugin_list *list;
while (plugin_list) {
list = plugin_list;
plugin_list = list->next;
func = dlsym(list->handle, PEVENT_PLUGIN_UNLOADER_NAME);
func = dlsym(list->handle, TEP_PLUGIN_UNLOADER_NAME);
if (func)
func(pevent);
dlclose(list->handle);

View File

@ -1,21 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1 */
/*
* Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License (not later!)
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see <http://www.gnu.org/licenses>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#ifndef __UTIL_H
#define __UTIL_H

View File

@ -1,22 +1,7 @@
// SPDX-License-Identifier: LGPL-2.1
/*
* Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License (not later!)
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#include <stdio.h>
#include <stdlib.h>

View File

@ -1,21 +1,7 @@
// SPDX-License-Identifier: LGPL-2.1
/*
* Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License (not later!)
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see <http://www.gnu.org/licenses>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#include <stdio.h>
#include <stdlib.h>
@ -51,8 +37,8 @@ static void show_error(char *error_buf, const char *fmt, ...)
int len;
int i;
input = pevent_get_input_buf();
index = pevent_get_input_buf_ptr();
input = tep_get_input_buf();
index = tep_get_input_buf_ptr();
len = input ? strlen(input) : 0;
if (len) {
@ -66,13 +52,13 @@ static void show_error(char *error_buf, const char *fmt, ...)
}
va_start(ap, fmt);
vsnprintf(error_buf + len, PEVENT_FILTER_ERROR_BUFSZ - len, fmt, ap);
vsnprintf(error_buf + len, TEP_FILTER_ERROR_BUFSZ - len, fmt, ap);
va_end(ap);
}
static void free_token(char *token)
{
pevent_free_token(token);
tep_free_token(token);
}
static enum event_type read_token(char **tok)
@ -82,13 +68,13 @@ static enum event_type read_token(char **tok)
do {
free_token(token);
type = pevent_read_token(&token);
type = tep_read_token(&token);
} while (type == EVENT_NEWLINE || type == EVENT_SPACE);
/* If token is = or ! check to see if the next char is ~ */
if (token &&
(strcmp(token, "=") == 0 || strcmp(token, "!") == 0) &&
pevent_peek_char() == '~') {
tep_peek_char() == '~') {
/* append it */
*tok = malloc(3);
if (*tok == NULL) {
@ -98,7 +84,7 @@ static enum event_type read_token(char **tok)
sprintf(*tok, "%c%c", *token, '~');
free_token(token);
/* Now remove the '~' from the buffer */
pevent_read_token(&token);
tep_read_token(&token);
free_token(token);
} else
*tok = token;
@ -167,7 +153,7 @@ add_filter_type(struct event_filter *filter, int id)
filter_type = &filter->event_filters[i];
filter_type->event_id = id;
filter_type->event = pevent_find_event(filter->pevent, id);
filter_type->event = tep_find_event(filter->pevent, id);
filter_type->filter = NULL;
filter->filters++;
@ -176,10 +162,10 @@ add_filter_type(struct event_filter *filter, int id)
}
/**
* pevent_filter_alloc - create a new event filter
* tep_filter_alloc - create a new event filter
* @pevent: The pevent that this filter is associated with
*/
struct event_filter *pevent_filter_alloc(struct pevent *pevent)
struct event_filter *tep_filter_alloc(struct tep_handle *pevent)
{
struct event_filter *filter;
@ -189,7 +175,7 @@ struct event_filter *pevent_filter_alloc(struct pevent *pevent)
memset(filter, 0, sizeof(*filter));
filter->pevent = pevent;
pevent_ref(pevent);
tep_ref(pevent);
return filter;
}
@ -268,8 +254,8 @@ static int event_match(struct event_format *event,
!regexec(ereg, event->name, 0, NULL, 0);
}
static enum pevent_errno
find_event(struct pevent *pevent, struct event_list **events,
static enum tep_errno
find_event(struct tep_handle *pevent, struct event_list **events,
char *sys_name, char *event_name)
{
struct event_format *event;
@ -289,26 +275,26 @@ find_event(struct pevent *pevent, struct event_list **events,
ret = asprintf(&reg, "^%s$", event_name);
if (ret < 0)
return PEVENT_ERRNO__MEM_ALLOC_FAILED;
return TEP_ERRNO__MEM_ALLOC_FAILED;
ret = regcomp(&ereg, reg, REG_ICASE|REG_NOSUB);
free(reg);
if (ret)
return PEVENT_ERRNO__INVALID_EVENT_NAME;
return TEP_ERRNO__INVALID_EVENT_NAME;
if (sys_name) {
ret = asprintf(&reg, "^%s$", sys_name);
if (ret < 0) {
regfree(&ereg);
return PEVENT_ERRNO__MEM_ALLOC_FAILED;
return TEP_ERRNO__MEM_ALLOC_FAILED;
}
ret = regcomp(&sreg, reg, REG_ICASE|REG_NOSUB);
free(reg);
if (ret) {
regfree(&ereg);
return PEVENT_ERRNO__INVALID_EVENT_NAME;
return TEP_ERRNO__INVALID_EVENT_NAME;
}
}
@ -328,9 +314,9 @@ find_event(struct pevent *pevent, struct event_list **events,
regfree(&sreg);
if (!match)
return PEVENT_ERRNO__EVENT_NOT_FOUND;
return TEP_ERRNO__EVENT_NOT_FOUND;
if (fail)
return PEVENT_ERRNO__MEM_ALLOC_FAILED;
return TEP_ERRNO__MEM_ALLOC_FAILED;
return 0;
}
@ -346,7 +332,7 @@ static void free_events(struct event_list *events)
}
}
static enum pevent_errno
static enum tep_errno
create_arg_item(struct event_format *event, const char *token,
enum event_type type, struct filter_arg **parg, char *error_str)
{
@ -356,7 +342,7 @@ create_arg_item(struct event_format *event, const char *token,
arg = allocate_arg();
if (arg == NULL) {
show_error(error_str, "failed to allocate filter arg");
return PEVENT_ERRNO__MEM_ALLOC_FAILED;
return TEP_ERRNO__MEM_ALLOC_FAILED;
}
switch (type) {
@ -370,7 +356,7 @@ create_arg_item(struct event_format *event, const char *token,
if (!arg->value.str) {
free_arg(arg);
show_error(error_str, "failed to allocate string filter arg");
return PEVENT_ERRNO__MEM_ALLOC_FAILED;
return TEP_ERRNO__MEM_ALLOC_FAILED;
}
break;
case EVENT_ITEM:
@ -382,7 +368,7 @@ create_arg_item(struct event_format *event, const char *token,
break;
}
/* Consider this a field */
field = pevent_find_any_field(event, token);
field = tep_find_any_field(event, token);
if (!field) {
/* If token is 'COMM' or 'CPU' then it is special */
if (strcmp(token, COMM) == 0) {
@ -402,7 +388,7 @@ create_arg_item(struct event_format *event, const char *token,
default:
free_arg(arg);
show_error(error_str, "expected a value but found %s", token);
return PEVENT_ERRNO__UNEXPECTED_TYPE;
return TEP_ERRNO__UNEXPECTED_TYPE;
}
*parg = arg;
return 0;
@ -454,7 +440,7 @@ create_arg_cmp(enum filter_cmp_type ctype)
return arg;
}
static enum pevent_errno
static enum tep_errno
add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str)
{
struct filter_arg *left;
@ -487,7 +473,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str)
break;
default:
show_error(error_str, "Illegal rvalue");
return PEVENT_ERRNO__ILLEGAL_RVALUE;
return TEP_ERRNO__ILLEGAL_RVALUE;
}
/*
@ -534,7 +520,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str)
if (left->type != FILTER_ARG_FIELD) {
show_error(error_str,
"Illegal lvalue for string comparison");
return PEVENT_ERRNO__ILLEGAL_LVALUE;
return TEP_ERRNO__ILLEGAL_LVALUE;
}
/* Make sure this is a valid string compare */
@ -553,13 +539,13 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str)
show_error(error_str,
"RegEx '%s' did not compute",
str);
return PEVENT_ERRNO__INVALID_REGEX;
return TEP_ERRNO__INVALID_REGEX;
}
break;
default:
show_error(error_str,
"Illegal comparison for string");
return PEVENT_ERRNO__ILLEGAL_STRING_CMP;
return TEP_ERRNO__ILLEGAL_STRING_CMP;
}
op->type = FILTER_ARG_STR;
@ -568,7 +554,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str)
op->str.val = strdup(str);
if (!op->str.val) {
show_error(error_str, "Failed to allocate string filter");
return PEVENT_ERRNO__MEM_ALLOC_FAILED;
return TEP_ERRNO__MEM_ALLOC_FAILED;
}
/*
* Need a buffer to copy data for tests
@ -576,7 +562,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str)
op->str.buffer = malloc(op->str.field->size + 1);
if (!op->str.buffer) {
show_error(error_str, "Failed to allocate string filter");
return PEVENT_ERRNO__MEM_ALLOC_FAILED;
return TEP_ERRNO__MEM_ALLOC_FAILED;
}
/* Null terminate this buffer */
op->str.buffer[op->str.field->size] = 0;
@ -595,7 +581,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str)
case FILTER_CMP_NOT_REGEX:
show_error(error_str,
"Op not allowed with integers");
return PEVENT_ERRNO__ILLEGAL_INTEGER_CMP;
return TEP_ERRNO__ILLEGAL_INTEGER_CMP;
default:
break;
@ -616,7 +602,7 @@ add_right(struct filter_arg *op, struct filter_arg *arg, char *error_str)
out_fail:
show_error(error_str, "Syntax error");
return PEVENT_ERRNO__SYNTAX_ERROR;
return TEP_ERRNO__SYNTAX_ERROR;
}
static struct filter_arg *
@ -629,7 +615,7 @@ rotate_op_right(struct filter_arg *a, struct filter_arg *b)
return arg;
}
static enum pevent_errno add_left(struct filter_arg *op, struct filter_arg *arg)
static enum tep_errno add_left(struct filter_arg *op, struct filter_arg *arg)
{
switch (op->type) {
case FILTER_ARG_EXP:
@ -648,11 +634,11 @@ static enum pevent_errno add_left(struct filter_arg *op, struct filter_arg *arg)
/* left arg of compares must be a field */
if (arg->type != FILTER_ARG_FIELD &&
arg->type != FILTER_ARG_BOOLEAN)
return PEVENT_ERRNO__INVALID_ARG_TYPE;
return TEP_ERRNO__INVALID_ARG_TYPE;
op->num.left = arg;
break;
default:
return PEVENT_ERRNO__INVALID_ARG_TYPE;
return TEP_ERRNO__INVALID_ARG_TYPE;
}
return 0;
}
@ -765,7 +751,7 @@ enum filter_vals {
FILTER_VAL_TRUE,
};
static enum pevent_errno
static enum tep_errno
reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child,
struct filter_arg *arg, char *error_str)
{
@ -775,7 +761,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child,
if (parent->type != FILTER_ARG_OP &&
arg->type != FILTER_ARG_OP) {
show_error(error_str, "can not reparent other than OP");
return PEVENT_ERRNO__REPARENT_NOT_OP;
return TEP_ERRNO__REPARENT_NOT_OP;
}
/* Get the sibling */
@ -787,7 +773,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child,
other_child = old_child->op.right;
} else {
show_error(error_str, "Error in reparent op, find other child");
return PEVENT_ERRNO__REPARENT_FAILED;
return TEP_ERRNO__REPARENT_FAILED;
}
/* Detach arg from old_child */
@ -808,7 +794,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child,
ptr = &parent->op.left;
else {
show_error(error_str, "Error in reparent op");
return PEVENT_ERRNO__REPARENT_FAILED;
return TEP_ERRNO__REPARENT_FAILED;
}
*ptr = arg;
@ -817,7 +803,7 @@ reparent_op_arg(struct filter_arg *parent, struct filter_arg *old_child,
return 0;
}
/* Returns either filter_vals (success) or pevent_errno (failfure) */
/* Returns either filter_vals (success) or tep_errno (failfure) */
static int test_arg(struct filter_arg *parent, struct filter_arg *arg,
char *error_str)
{
@ -912,7 +898,7 @@ static int test_arg(struct filter_arg *parent, struct filter_arg *arg,
return rval;
default:
show_error(error_str, "bad arg in filter tree");
return PEVENT_ERRNO__BAD_FILTER_ARG;
return TEP_ERRNO__BAD_FILTER_ARG;
}
return FILTER_VAL_NORM;
}
@ -937,7 +923,7 @@ static int collapse_tree(struct filter_arg *arg,
arg->boolean.value = ret == FILTER_VAL_TRUE;
} else {
show_error(error_str, "Failed to allocate filter arg");
ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
ret = TEP_ERRNO__MEM_ALLOC_FAILED;
}
break;
@ -952,7 +938,7 @@ static int collapse_tree(struct filter_arg *arg,
return ret;
}
static enum pevent_errno
static enum tep_errno
process_filter(struct event_format *event, struct filter_arg **parg,
char *error_str, int not)
{
@ -966,7 +952,7 @@ process_filter(struct event_format *event, struct filter_arg **parg,
enum filter_op_type btype;
enum filter_exp_type etype;
enum filter_cmp_type ctype;
enum pevent_errno ret;
enum tep_errno ret;
*parg = NULL;
@ -1004,7 +990,7 @@ process_filter(struct event_format *event, struct filter_arg **parg,
case EVENT_DELIM:
if (*token == ',') {
show_error(error_str, "Illegal token ','");
ret = PEVENT_ERRNO__ILLEGAL_TOKEN;
ret = TEP_ERRNO__ILLEGAL_TOKEN;
goto fail;
}
@ -1012,22 +998,22 @@ process_filter(struct event_format *event, struct filter_arg **parg,
if (left_item) {
show_error(error_str,
"Open paren can not come after item");
ret = PEVENT_ERRNO__INVALID_PAREN;
ret = TEP_ERRNO__INVALID_PAREN;
goto fail;
}
if (current_exp) {
show_error(error_str,
"Open paren can not come after expression");
ret = PEVENT_ERRNO__INVALID_PAREN;
ret = TEP_ERRNO__INVALID_PAREN;
goto fail;
}
ret = process_filter(event, &arg, error_str, 0);
if (ret != PEVENT_ERRNO__UNBALANCED_PAREN) {
if (ret != TEP_ERRNO__UNBALANCED_PAREN) {
if (ret == 0) {
show_error(error_str,
"Unbalanced number of '('");
ret = PEVENT_ERRNO__UNBALANCED_PAREN;
ret = TEP_ERRNO__UNBALANCED_PAREN;
}
goto fail;
}
@ -1064,7 +1050,7 @@ process_filter(struct event_format *event, struct filter_arg **parg,
else
*parg = current_exp;
free(token);
return PEVENT_ERRNO__UNBALANCED_PAREN;
return TEP_ERRNO__UNBALANCED_PAREN;
}
break;
@ -1091,7 +1077,7 @@ process_filter(struct event_format *event, struct filter_arg **parg,
case OP_NONE:
show_error(error_str,
"Unknown op token %s", token);
ret = PEVENT_ERRNO__UNKNOWN_TOKEN;
ret = TEP_ERRNO__UNKNOWN_TOKEN;
goto fail;
}
@ -1179,11 +1165,11 @@ process_filter(struct event_format *event, struct filter_arg **parg,
fail_alloc:
show_error(error_str, "failed to allocate filter arg");
ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
ret = TEP_ERRNO__MEM_ALLOC_FAILED;
goto fail;
fail_syntax:
show_error(error_str, "Syntax error");
ret = PEVENT_ERRNO__SYNTAX_ERROR;
ret = TEP_ERRNO__SYNTAX_ERROR;
fail:
free_arg(current_op);
free_arg(current_exp);
@ -1192,13 +1178,13 @@ process_filter(struct event_format *event, struct filter_arg **parg,
return ret;
}
static enum pevent_errno
static enum tep_errno
process_event(struct event_format *event, const char *filter_str,
struct filter_arg **parg, char *error_str)
{
int ret;
pevent_buffer_init(filter_str, strlen(filter_str));
tep_buffer_init(filter_str, strlen(filter_str));
ret = process_filter(event, parg, error_str, 0);
if (ret < 0)
@ -1208,7 +1194,7 @@ process_event(struct event_format *event, const char *filter_str,
if (!*parg) {
*parg = allocate_arg();
if (*parg == NULL)
return PEVENT_ERRNO__MEM_ALLOC_FAILED;
return TEP_ERRNO__MEM_ALLOC_FAILED;
(*parg)->type = FILTER_ARG_BOOLEAN;
(*parg)->boolean.value = FILTER_FALSE;
@ -1217,13 +1203,13 @@ process_event(struct event_format *event, const char *filter_str,
return 0;
}
static enum pevent_errno
static enum tep_errno
filter_event(struct event_filter *filter, struct event_format *event,
const char *filter_str, char *error_str)
{
struct filter_type *filter_type;
struct filter_arg *arg;
enum pevent_errno ret;
enum tep_errno ret;
if (filter_str) {
ret = process_event(event, filter_str, &arg, error_str);
@ -1234,7 +1220,7 @@ filter_event(struct event_filter *filter, struct event_format *event,
/* just add a TRUE arg */
arg = allocate_arg();
if (arg == NULL)
return PEVENT_ERRNO__MEM_ALLOC_FAILED;
return TEP_ERRNO__MEM_ALLOC_FAILED;
arg->type = FILTER_ARG_BOOLEAN;
arg->boolean.value = FILTER_TRUE;
@ -1242,7 +1228,7 @@ filter_event(struct event_filter *filter, struct event_format *event,
filter_type = add_filter_type(filter, event->id);
if (filter_type == NULL)
return PEVENT_ERRNO__MEM_ALLOC_FAILED;
return TEP_ERRNO__MEM_ALLOC_FAILED;
if (filter_type->filter)
free_arg(filter_type->filter);
@ -1254,23 +1240,23 @@ filter_event(struct event_filter *filter, struct event_format *event,
static void filter_init_error_buf(struct event_filter *filter)
{
/* clear buffer to reset show error */
pevent_buffer_init("", 0);
tep_buffer_init("", 0);
filter->error_buffer[0] = '\0';
}
/**
* pevent_filter_add_filter_str - add a new filter
* tep_filter_add_filter_str - add a new filter
* @filter: the event filter to add to
* @filter_str: the filter string that contains the filter
*
* Returns 0 if the filter was successfully added or a
* negative error code. Use pevent_filter_strerror() to see
* negative error code. Use tep_filter_strerror() to see
* actual error message in case of error.
*/
enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter,
const char *filter_str)
enum tep_errno tep_filter_add_filter_str(struct event_filter *filter,
const char *filter_str)
{
struct pevent *pevent = filter->pevent;
struct tep_handle *pevent = filter->pevent;
struct event_list *event;
struct event_list *events = NULL;
const char *filter_start;
@ -1279,7 +1265,7 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter,
char *event_name = NULL;
char *sys_name = NULL;
char *sp;
enum pevent_errno rtn = 0; /* PEVENT_ERRNO__SUCCESS */
enum tep_errno rtn = 0; /* TEP_ERRNO__SUCCESS */
int len;
int ret;
@ -1305,7 +1291,7 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter,
if (this_event == NULL) {
/* This can only happen when events is NULL, but still */
free_events(events);
return PEVENT_ERRNO__MEM_ALLOC_FAILED;
return TEP_ERRNO__MEM_ALLOC_FAILED;
}
memcpy(this_event, filter_str, len);
this_event[len] = 0;
@ -1322,7 +1308,7 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter,
/* This can only happen when events is NULL, but still */
free_events(events);
free(this_event);
return PEVENT_ERRNO__FILTER_NOT_FOUND;
return TEP_ERRNO__FILTER_NOT_FOUND;
}
/* Find this event */
@ -1349,7 +1335,7 @@ enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter,
if (ret >= 0 && pevent->test_filters) {
char *test;
test = pevent_filter_make_string(filter, event->event->id);
test = tep_filter_make_string(filter, event->event->id);
if (test) {
printf(" '%s: %s'\n", event->event->name, test);
free(test);
@ -1371,7 +1357,7 @@ static void free_filter_type(struct filter_type *filter_type)
}
/**
* pevent_filter_strerror - fill error message in a buffer
* tep_filter_strerror - fill error message in a buffer
* @filter: the event filter contains error
* @err: the error code
* @buf: the buffer to be filled in
@ -1379,10 +1365,10 @@ static void free_filter_type(struct filter_type *filter_type)
*
* Returns 0 if message was filled successfully, -1 if error
*/
int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err,
char *buf, size_t buflen)
int tep_filter_strerror(struct event_filter *filter, enum tep_errno err,
char *buf, size_t buflen)
{
if (err <= __PEVENT_ERRNO__START || err >= __PEVENT_ERRNO__END)
if (err <= __TEP_ERRNO__START || err >= __TEP_ERRNO__END)
return -1;
if (strlen(filter->error_buffer) > 0) {
@ -1393,11 +1379,11 @@ int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err,
return 0;
}
return pevent_strerror(filter->pevent, err, buf, buflen);
return tep_strerror(filter->pevent, err, buf, buflen);
}
/**
* pevent_filter_remove_event - remove a filter for an event
* tep_filter_remove_event - remove a filter for an event
* @filter: the event filter to remove from
* @event_id: the event to remove a filter for
*
@ -1407,8 +1393,8 @@ int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err,
* Returns 1: if an event was removed
* 0: if the event was not found
*/
int pevent_filter_remove_event(struct event_filter *filter,
int event_id)
int tep_filter_remove_event(struct event_filter *filter,
int event_id)
{
struct filter_type *filter_type;
unsigned long len;
@ -1437,12 +1423,12 @@ int pevent_filter_remove_event(struct event_filter *filter,
}
/**
* pevent_filter_reset - clear all filters in a filter
* tep_filter_reset - clear all filters in a filter
* @filter: the event filter to reset
*
* Removes all filters from a filter and resets it.
*/
void pevent_filter_reset(struct event_filter *filter)
void tep_filter_reset(struct event_filter *filter)
{
int i;
@ -1454,11 +1440,11 @@ void pevent_filter_reset(struct event_filter *filter)
filter->event_filters = NULL;
}
void pevent_filter_free(struct event_filter *filter)
void tep_filter_free(struct event_filter *filter)
{
pevent_unref(filter->pevent);
tep_unref(filter->pevent);
pevent_filter_reset(filter);
tep_filter_reset(filter);
free(filter);
}
@ -1478,7 +1464,7 @@ static int copy_filter_type(struct event_filter *filter,
/* Can't assume that the pevent's are the same */
sys = filter_type->event->system;
name = filter_type->event->name;
event = pevent_find_event_by_name(filter->pevent, sys, name);
event = tep_find_event_by_name(filter->pevent, sys, name);
if (!event)
return -1;
@ -1515,18 +1501,18 @@ static int copy_filter_type(struct event_filter *filter,
}
/**
* pevent_filter_copy - copy a filter using another filter
* tep_filter_copy - copy a filter using another filter
* @dest - the filter to copy to
* @source - the filter to copy from
*
* Returns 0 on success and -1 if not all filters were copied
*/
int pevent_filter_copy(struct event_filter *dest, struct event_filter *source)
int tep_filter_copy(struct event_filter *dest, struct event_filter *source)
{
int ret = 0;
int i;
pevent_filter_reset(dest);
tep_filter_reset(dest);
for (i = 0; i < source->filters; i++) {
if (copy_filter_type(dest, source, &source->event_filters[i]))
@ -1537,7 +1523,7 @@ int pevent_filter_copy(struct event_filter *dest, struct event_filter *source)
/**
* pevent_update_trivial - update the trivial filters with the given filter
* tep_update_trivial - update the trivial filters with the given filter
* @dest - the filter to update
* @source - the filter as the source of the update
* @type - the type of trivial filter to update.
@ -1547,11 +1533,11 @@ int pevent_filter_copy(struct event_filter *dest, struct event_filter *source)
* Returns 0 on success and -1 if there was a problem updating, but
* events may have still been updated on error.
*/
int pevent_update_trivial(struct event_filter *dest, struct event_filter *source,
enum filter_trivial_type type)
int tep_update_trivial(struct event_filter *dest, struct event_filter *source,
enum filter_trivial_type type)
{
struct pevent *src_pevent;
struct pevent *dest_pevent;
struct tep_handle *src_pevent;
struct tep_handle *dest_pevent;
struct event_format *event;
struct filter_type *filter_type;
struct filter_arg *arg;
@ -1578,14 +1564,14 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source
if (src_pevent != dest_pevent) {
/* do a look up */
event = pevent_find_event_by_name(src_pevent,
event->system,
event->name);
event = tep_find_event_by_name(src_pevent,
event->system,
event->name);
if (!event)
return -1;
}
str = pevent_filter_make_string(source, event->id);
str = tep_filter_make_string(source, event->id);
if (!str)
continue;
@ -1598,7 +1584,7 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source
}
/**
* pevent_filter_clear_trivial - clear TRUE and FALSE filters
* tep_filter_clear_trivial - clear TRUE and FALSE filters
* @filter: the filter to remove trivial filters from
* @type: remove only true, false, or both
*
@ -1606,8 +1592,8 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source
*
* Returns 0 on success and -1 if there was a problem.
*/
int pevent_filter_clear_trivial(struct event_filter *filter,
enum filter_trivial_type type)
int tep_filter_clear_trivial(struct event_filter *filter,
enum filter_trivial_type type)
{
struct filter_type *filter_type;
int count = 0;
@ -1653,14 +1639,14 @@ int pevent_filter_clear_trivial(struct event_filter *filter,
return 0;
for (i = 0; i < count; i++)
pevent_filter_remove_event(filter, ids[i]);
tep_filter_remove_event(filter, ids[i]);
free(ids);
return 0;
}
/**
* pevent_filter_event_has_trivial - return true event contains trivial filter
* tep_filter_event_has_trivial - return true event contains trivial filter
* @filter: the filter with the information
* @event_id: the id of the event to test
* @type: trivial type to test for (TRUE, FALSE, EITHER)
@ -1668,9 +1654,9 @@ int pevent_filter_clear_trivial(struct event_filter *filter,
* Returns 1 if the event contains a matching trivial type
* otherwise 0.
*/
int pevent_filter_event_has_trivial(struct event_filter *filter,
int event_id,
enum filter_trivial_type type)
int tep_filter_event_has_trivial(struct event_filter *filter,
int event_id,
enum filter_trivial_type type)
{
struct filter_type *filter_type;
@ -1697,22 +1683,22 @@ int pevent_filter_event_has_trivial(struct event_filter *filter,
}
static int test_filter(struct event_format *event, struct filter_arg *arg,
struct pevent_record *record, enum pevent_errno *err);
struct tep_record *record, enum tep_errno *err);
static const char *
get_comm(struct event_format *event, struct pevent_record *record)
get_comm(struct event_format *event, struct tep_record *record)
{
const char *comm;
int pid;
pid = pevent_data_pid(event->pevent, record);
comm = pevent_data_comm_from_pid(event->pevent, pid);
pid = tep_data_pid(event->pevent, record);
comm = tep_data_comm_from_pid(event->pevent, pid);
return comm;
}
static unsigned long long
get_value(struct event_format *event,
struct format_field *field, struct pevent_record *record)
struct format_field *field, struct tep_record *record)
{
unsigned long long val;
@ -1728,7 +1714,7 @@ get_value(struct event_format *event,
if (field == &cpu)
return record->cpu;
pevent_read_number_field(field, record->data, &val);
tep_read_number_field(field, record->data, &val);
if (!(field->flags & FIELD_IS_SIGNED))
return val;
@ -1748,11 +1734,11 @@ get_value(struct event_format *event,
static unsigned long long
get_arg_value(struct event_format *event, struct filter_arg *arg,
struct pevent_record *record, enum pevent_errno *err);
struct tep_record *record, enum tep_errno *err);
static unsigned long long
get_exp_value(struct event_format *event, struct filter_arg *arg,
struct pevent_record *record, enum pevent_errno *err)
struct tep_record *record, enum tep_errno *err)
{
unsigned long long lval, rval;
@ -1800,14 +1786,14 @@ get_exp_value(struct event_format *event, struct filter_arg *arg,
case FILTER_EXP_NOT:
default:
if (!*err)
*err = PEVENT_ERRNO__INVALID_EXP_TYPE;
*err = TEP_ERRNO__INVALID_EXP_TYPE;
}
return 0;
}
static unsigned long long
get_arg_value(struct event_format *event, struct filter_arg *arg,
struct pevent_record *record, enum pevent_errno *err)
struct tep_record *record, enum tep_errno *err)
{
switch (arg->type) {
case FILTER_ARG_FIELD:
@ -1816,7 +1802,7 @@ get_arg_value(struct event_format *event, struct filter_arg *arg,
case FILTER_ARG_VALUE:
if (arg->value.type != FILTER_NUMBER) {
if (!*err)
*err = PEVENT_ERRNO__NOT_A_NUMBER;
*err = TEP_ERRNO__NOT_A_NUMBER;
}
return arg->value.val;
@ -1825,13 +1811,13 @@ get_arg_value(struct event_format *event, struct filter_arg *arg,
default:
if (!*err)
*err = PEVENT_ERRNO__INVALID_ARG_TYPE;
*err = TEP_ERRNO__INVALID_ARG_TYPE;
}
return 0;
}
static int test_num(struct event_format *event, struct filter_arg *arg,
struct pevent_record *record, enum pevent_errno *err)
struct tep_record *record, enum tep_errno *err)
{
unsigned long long lval, rval;
@ -1866,15 +1852,15 @@ static int test_num(struct event_format *event, struct filter_arg *arg,
default:
if (!*err)
*err = PEVENT_ERRNO__ILLEGAL_INTEGER_CMP;
*err = TEP_ERRNO__ILLEGAL_INTEGER_CMP;
return 0;
}
}
static const char *get_field_str(struct filter_arg *arg, struct pevent_record *record)
static const char *get_field_str(struct filter_arg *arg, struct tep_record *record)
{
struct event_format *event;
struct pevent *pevent;
struct tep_handle *pevent;
unsigned long long addr;
const char *val = NULL;
unsigned int size;
@ -1909,7 +1895,7 @@ static const char *get_field_str(struct filter_arg *arg, struct pevent_record *r
if (arg->str.field->flags & (FIELD_IS_POINTER | FIELD_IS_LONG))
/* convert to a kernel symbol */
val = pevent_find_function(pevent, addr);
val = tep_find_function(pevent, addr);
if (val == NULL) {
/* just use the hex of the string name */
@ -1922,7 +1908,7 @@ static const char *get_field_str(struct filter_arg *arg, struct pevent_record *r
}
static int test_str(struct event_format *event, struct filter_arg *arg,
struct pevent_record *record, enum pevent_errno *err)
struct tep_record *record, enum tep_errno *err)
{
const char *val;
@ -1947,13 +1933,13 @@ static int test_str(struct event_format *event, struct filter_arg *arg,
default:
if (!*err)
*err = PEVENT_ERRNO__ILLEGAL_STRING_CMP;
*err = TEP_ERRNO__ILLEGAL_STRING_CMP;
return 0;
}
}
static int test_op(struct event_format *event, struct filter_arg *arg,
struct pevent_record *record, enum pevent_errno *err)
struct tep_record *record, enum tep_errno *err)
{
switch (arg->op.type) {
case FILTER_OP_AND:
@ -1969,13 +1955,13 @@ static int test_op(struct event_format *event, struct filter_arg *arg,
default:
if (!*err)
*err = PEVENT_ERRNO__INVALID_OP_TYPE;
*err = TEP_ERRNO__INVALID_OP_TYPE;
return 0;
}
}
static int test_filter(struct event_format *event, struct filter_arg *arg,
struct pevent_record *record, enum pevent_errno *err)
struct tep_record *record, enum tep_errno *err)
{
if (*err) {
/*
@ -2009,20 +1995,20 @@ static int test_filter(struct event_format *event, struct filter_arg *arg,
default:
if (!*err)
*err = PEVENT_ERRNO__INVALID_ARG_TYPE;
*err = TEP_ERRNO__INVALID_ARG_TYPE;
return 0;
}
}
/**
* pevent_event_filtered - return true if event has filter
* tep_event_filtered - return true if event has filter
* @filter: filter struct with filter information
* @event_id: event id to test if filter exists
*
* Returns 1 if filter found for @event_id
* otherwise 0;
*/
int pevent_event_filtered(struct event_filter *filter, int event_id)
int tep_event_filtered(struct event_filter *filter, int event_id)
{
struct filter_type *filter_type;
@ -2035,42 +2021,42 @@ int pevent_event_filtered(struct event_filter *filter, int event_id)
}
/**
* pevent_filter_match - test if a record matches a filter
* tep_filter_match - test if a record matches a filter
* @filter: filter struct with filter information
* @record: the record to test against the filter
*
* Returns: match result or error code (prefixed with PEVENT_ERRNO__)
* Returns: match result or error code (prefixed with TEP_ERRNO__)
* FILTER_MATCH - filter found for event and @record matches
* FILTER_MISS - filter found for event and @record does not match
* FILTER_NOT_FOUND - no filter found for @record's event
* NO_FILTER - if no filters exist
* otherwise - error occurred during test
*/
enum pevent_errno pevent_filter_match(struct event_filter *filter,
struct pevent_record *record)
enum tep_errno tep_filter_match(struct event_filter *filter,
struct tep_record *record)
{
struct pevent *pevent = filter->pevent;
struct tep_handle *pevent = filter->pevent;
struct filter_type *filter_type;
int event_id;
int ret;
enum pevent_errno err = 0;
enum tep_errno err = 0;
filter_init_error_buf(filter);
if (!filter->filters)
return PEVENT_ERRNO__NO_FILTER;
return TEP_ERRNO__NO_FILTER;
event_id = pevent_data_type(pevent, record);
event_id = tep_data_type(pevent, record);
filter_type = find_filter_type(filter, event_id);
if (!filter_type)
return PEVENT_ERRNO__FILTER_NOT_FOUND;
return TEP_ERRNO__FILTER_NOT_FOUND;
ret = test_filter(filter_type->event, filter_type->filter, record, &err);
if (err)
return err;
return ret ? PEVENT_ERRNO__FILTER_MATCH : PEVENT_ERRNO__FILTER_MISS;
return ret ? TEP_ERRNO__FILTER_MATCH : TEP_ERRNO__FILTER_MISS;
}
static char *op_to_str(struct event_filter *filter, struct filter_arg *arg)
@ -2364,7 +2350,7 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg)
}
/**
* pevent_filter_make_string - return a string showing the filter
* tep_filter_make_string - return a string showing the filter
* @filter: filter struct with filter information
* @event_id: the event id to return the filter string with
*
@ -2373,7 +2359,7 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg)
* NULL is returned if no filter is found or allocation failed.
*/
char *
pevent_filter_make_string(struct event_filter *filter, int event_id)
tep_filter_make_string(struct event_filter *filter, int event_id)
{
struct filter_type *filter_type;
@ -2389,7 +2375,7 @@ pevent_filter_make_string(struct event_filter *filter, int event_id)
}
/**
* pevent_filter_compare - compare two filters and return if they are the same
* tep_filter_compare - compare two filters and return if they are the same
* @filter1: Filter to compare with @filter2
* @filter2: Filter to compare with @filter1
*
@ -2397,7 +2383,7 @@ pevent_filter_make_string(struct event_filter *filter, int event_id)
* 1 if the two filters hold the same content.
* 0 if they do not.
*/
int pevent_filter_compare(struct event_filter *filter1, struct event_filter *filter2)
int tep_filter_compare(struct event_filter *filter1, struct event_filter *filter2)
{
struct filter_type *filter_type1;
struct filter_type *filter_type2;

View File

@ -1,21 +1,7 @@
// SPDX-License-Identifier: LGPL-2.1
/*
* Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License (not later!)
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see <http://www.gnu.org/licenses>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#include <stdio.h>
#include <stdlib.h>

View File

@ -25,19 +25,19 @@ process___le16_to_cpup(struct trace_seq *s, unsigned long long *args)
return val ? (long long) le16toh(*val) : 0;
}
int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
{
pevent_register_print_function(pevent,
process___le16_to_cpup,
PEVENT_FUNC_ARG_INT,
"__le16_to_cpup",
PEVENT_FUNC_ARG_PTR,
PEVENT_FUNC_ARG_VOID);
tep_register_print_function(pevent,
process___le16_to_cpup,
TEP_FUNC_ARG_INT,
"__le16_to_cpup",
TEP_FUNC_ARG_PTR,
TEP_FUNC_ARG_VOID);
return 0;
}
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
{
pevent_unregister_print_function(pevent, process___le16_to_cpup,
"__le16_to_cpup");
tep_unregister_print_function(pevent, process___le16_to_cpup,
"__le16_to_cpup");
}

View File

@ -33,7 +33,7 @@ static int cpus = -1;
#define STK_BLK 10
struct pevent_plugin_option plugin_options[] =
struct tep_plugin_option plugin_options[] =
{
{
.name = "parent",
@ -53,8 +53,8 @@ struct pevent_plugin_option plugin_options[] =
}
};
static struct pevent_plugin_option *ftrace_parent = &plugin_options[0];
static struct pevent_plugin_option *ftrace_indent = &plugin_options[1];
static struct tep_plugin_option *ftrace_parent = &plugin_options[0];
static struct tep_plugin_option *ftrace_indent = &plugin_options[1];
static void add_child(struct func_stack *stack, const char *child, int pos)
{
@ -122,25 +122,25 @@ static int add_and_get_index(const char *parent, const char *child, int cpu)
return 0;
}
static int function_handler(struct trace_seq *s, struct pevent_record *record,
static int function_handler(struct trace_seq *s, struct tep_record *record,
struct event_format *event, void *context)
{
struct pevent *pevent = event->pevent;
struct tep_handle *pevent = event->pevent;
unsigned long long function;
unsigned long long pfunction;
const char *func;
const char *parent;
int index = 0;
if (pevent_get_field_val(s, event, "ip", record, &function, 1))
if (tep_get_field_val(s, event, "ip", record, &function, 1))
return trace_seq_putc(s, '!');
func = pevent_find_function(pevent, function);
func = tep_find_function(pevent, function);
if (pevent_get_field_val(s, event, "parent_ip", record, &pfunction, 1))
if (tep_get_field_val(s, event, "parent_ip", record, &pfunction, 1))
return trace_seq_putc(s, '!');
parent = pevent_find_function(pevent, pfunction);
parent = tep_find_function(pevent, pfunction);
if (parent && ftrace_indent->set)
index = add_and_get_index(parent, func, record->cpu);
@ -163,22 +163,22 @@ static int function_handler(struct trace_seq *s, struct pevent_record *record,
return 0;
}
int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
{
pevent_register_event_handler(pevent, -1, "ftrace", "function",
function_handler, NULL);
tep_register_event_handler(pevent, -1, "ftrace", "function",
function_handler, NULL);
traceevent_plugin_add_options("ftrace", plugin_options);
tep_plugin_add_options("ftrace", plugin_options);
return 0;
}
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
{
int i, x;
pevent_unregister_event_handler(pevent, -1, "ftrace", "function",
function_handler, NULL);
tep_unregister_event_handler(pevent, -1, "ftrace", "function",
function_handler, NULL);
for (i = 0; i <= cpus; i++) {
for (x = 0; x < fstack[i].size && fstack[i].stack[x]; x++)
@ -186,7 +186,7 @@ void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
free(fstack[i].stack);
}
traceevent_plugin_remove_options(plugin_options);
tep_plugin_remove_options(plugin_options);
free(fstack);
fstack = NULL;

View File

@ -25,64 +25,64 @@
#include "event-parse.h"
static int timer_expire_handler(struct trace_seq *s,
struct pevent_record *record,
struct tep_record *record,
struct event_format *event, void *context)
{
trace_seq_printf(s, "hrtimer=");
if (pevent_print_num_field(s, "0x%llx", event, "timer",
record, 0) == -1)
pevent_print_num_field(s, "0x%llx", event, "hrtimer",
record, 1);
if (tep_print_num_field(s, "0x%llx", event, "timer",
record, 0) == -1)
tep_print_num_field(s, "0x%llx", event, "hrtimer",
record, 1);
trace_seq_printf(s, " now=");
pevent_print_num_field(s, "%llu", event, "now", record, 1);
tep_print_num_field(s, "%llu", event, "now", record, 1);
pevent_print_func_field(s, " function=%s", event, "function",
tep_print_func_field(s, " function=%s", event, "function",
record, 0);
return 0;
}
static int timer_start_handler(struct trace_seq *s,
struct pevent_record *record,
struct tep_record *record,
struct event_format *event, void *context)
{
trace_seq_printf(s, "hrtimer=");
if (pevent_print_num_field(s, "0x%llx", event, "timer",
record, 0) == -1)
pevent_print_num_field(s, "0x%llx", event, "hrtimer",
record, 1);
if (tep_print_num_field(s, "0x%llx", event, "timer",
record, 0) == -1)
tep_print_num_field(s, "0x%llx", event, "hrtimer",
record, 1);
pevent_print_func_field(s, " function=%s", event, "function",
record, 0);
tep_print_func_field(s, " function=%s", event, "function",
record, 0);
trace_seq_printf(s, " expires=");
pevent_print_num_field(s, "%llu", event, "expires", record, 1);
tep_print_num_field(s, "%llu", event, "expires", record, 1);
trace_seq_printf(s, " softexpires=");
pevent_print_num_field(s, "%llu", event, "softexpires", record, 1);
tep_print_num_field(s, "%llu", event, "softexpires", record, 1);
return 0;
}
int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
{
pevent_register_event_handler(pevent, -1,
"timer", "hrtimer_expire_entry",
timer_expire_handler, NULL);
tep_register_event_handler(pevent, -1,
"timer", "hrtimer_expire_entry",
timer_expire_handler, NULL);
pevent_register_event_handler(pevent, -1, "timer", "hrtimer_start",
timer_start_handler, NULL);
tep_register_event_handler(pevent, -1, "timer", "hrtimer_start",
timer_start_handler, NULL);
return 0;
}
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
{
pevent_unregister_event_handler(pevent, -1,
"timer", "hrtimer_expire_entry",
timer_expire_handler, NULL);
tep_unregister_event_handler(pevent, -1,
"timer", "hrtimer_expire_entry",
timer_expire_handler, NULL);
pevent_unregister_event_handler(pevent, -1, "timer", "hrtimer_start",
timer_start_handler, NULL);
tep_unregister_event_handler(pevent, -1, "timer", "hrtimer_start",
timer_start_handler, NULL);
}

View File

@ -47,29 +47,29 @@ process_jiffies_to_msecs(struct trace_seq *s, unsigned long long *args)
return jiffies;
}
int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
{
pevent_register_print_function(pevent,
process_jbd2_dev_to_name,
PEVENT_FUNC_ARG_STRING,
"jbd2_dev_to_name",
PEVENT_FUNC_ARG_INT,
PEVENT_FUNC_ARG_VOID);
tep_register_print_function(pevent,
process_jbd2_dev_to_name,
TEP_FUNC_ARG_STRING,
"jbd2_dev_to_name",
TEP_FUNC_ARG_INT,
TEP_FUNC_ARG_VOID);
pevent_register_print_function(pevent,
process_jiffies_to_msecs,
PEVENT_FUNC_ARG_LONG,
"jiffies_to_msecs",
PEVENT_FUNC_ARG_LONG,
PEVENT_FUNC_ARG_VOID);
tep_register_print_function(pevent,
process_jiffies_to_msecs,
TEP_FUNC_ARG_LONG,
"jiffies_to_msecs",
TEP_FUNC_ARG_LONG,
TEP_FUNC_ARG_VOID);
return 0;
}
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
{
pevent_unregister_print_function(pevent, process_jbd2_dev_to_name,
"jbd2_dev_to_name");
tep_unregister_print_function(pevent, process_jbd2_dev_to_name,
"jbd2_dev_to_name");
pevent_unregister_print_function(pevent, process_jiffies_to_msecs,
"jiffies_to_msecs");
tep_unregister_print_function(pevent, process_jiffies_to_msecs,
"jiffies_to_msecs");
}

View File

@ -23,7 +23,7 @@
#include "event-parse.h"
static int call_site_handler(struct trace_seq *s, struct pevent_record *record,
static int call_site_handler(struct trace_seq *s, struct tep_record *record,
struct event_format *event, void *context)
{
struct format_field *field;
@ -31,64 +31,64 @@ static int call_site_handler(struct trace_seq *s, struct pevent_record *record,
void *data = record->data;
const char *func;
field = pevent_find_field(event, "call_site");
field = tep_find_field(event, "call_site");
if (!field)
return 1;
if (pevent_read_number_field(field, data, &val))
if (tep_read_number_field(field, data, &val))
return 1;
func = pevent_find_function(event->pevent, val);
func = tep_find_function(event->pevent, val);
if (!func)
return 1;
addr = pevent_find_function_address(event->pevent, val);
addr = tep_find_function_address(event->pevent, val);
trace_seq_printf(s, "(%s+0x%x) ", func, (int)(val - addr));
return 1;
}
int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
{
pevent_register_event_handler(pevent, -1, "kmem", "kfree",
call_site_handler, NULL);
tep_register_event_handler(pevent, -1, "kmem", "kfree",
call_site_handler, NULL);
pevent_register_event_handler(pevent, -1, "kmem", "kmalloc",
call_site_handler, NULL);
tep_register_event_handler(pevent, -1, "kmem", "kmalloc",
call_site_handler, NULL);
pevent_register_event_handler(pevent, -1, "kmem", "kmalloc_node",
call_site_handler, NULL);
tep_register_event_handler(pevent, -1, "kmem", "kmalloc_node",
call_site_handler, NULL);
pevent_register_event_handler(pevent, -1, "kmem", "kmem_cache_alloc",
call_site_handler, NULL);
tep_register_event_handler(pevent, -1, "kmem", "kmem_cache_alloc",
call_site_handler, NULL);
pevent_register_event_handler(pevent, -1, "kmem",
"kmem_cache_alloc_node",
call_site_handler, NULL);
tep_register_event_handler(pevent, -1, "kmem",
"kmem_cache_alloc_node",
call_site_handler, NULL);
pevent_register_event_handler(pevent, -1, "kmem", "kmem_cache_free",
call_site_handler, NULL);
tep_register_event_handler(pevent, -1, "kmem", "kmem_cache_free",
call_site_handler, NULL);
return 0;
}
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
{
pevent_unregister_event_handler(pevent, -1, "kmem", "kfree",
call_site_handler, NULL);
tep_unregister_event_handler(pevent, -1, "kmem", "kfree",
call_site_handler, NULL);
pevent_unregister_event_handler(pevent, -1, "kmem", "kmalloc",
call_site_handler, NULL);
tep_unregister_event_handler(pevent, -1, "kmem", "kmalloc",
call_site_handler, NULL);
pevent_unregister_event_handler(pevent, -1, "kmem", "kmalloc_node",
call_site_handler, NULL);
tep_unregister_event_handler(pevent, -1, "kmem", "kmalloc_node",
call_site_handler, NULL);
pevent_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_alloc",
call_site_handler, NULL);
tep_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_alloc",
call_site_handler, NULL);
pevent_unregister_event_handler(pevent, -1, "kmem",
"kmem_cache_alloc_node",
call_site_handler, NULL);
tep_unregister_event_handler(pevent, -1, "kmem",
"kmem_cache_alloc_node",
call_site_handler, NULL);
pevent_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_free",
call_site_handler, NULL);
tep_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_free",
call_site_handler, NULL);
}

View File

@ -247,17 +247,17 @@ static const char *find_exit_reason(unsigned isa, int val)
return strings[i].str;
}
static int print_exit_reason(struct trace_seq *s, struct pevent_record *record,
static int print_exit_reason(struct trace_seq *s, struct tep_record *record,
struct event_format *event, const char *field)
{
unsigned long long isa;
unsigned long long val;
const char *reason;
if (pevent_get_field_val(s, event, field, record, &val, 1) < 0)
if (tep_get_field_val(s, event, field, record, &val, 1) < 0)
return -1;
if (pevent_get_field_val(s, event, "isa", record, &isa, 0) < 0)
if (tep_get_field_val(s, event, "isa", record, &isa, 0) < 0)
isa = 1;
reason = find_exit_reason(isa, val);
@ -268,7 +268,7 @@ static int print_exit_reason(struct trace_seq *s, struct pevent_record *record,
return 0;
}
static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record,
static int kvm_exit_handler(struct trace_seq *s, struct tep_record *record,
struct event_format *event, void *context)
{
unsigned long long info1 = 0, info2 = 0;
@ -276,10 +276,10 @@ static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record,
if (print_exit_reason(s, record, event, "exit_reason") < 0)
return -1;
pevent_print_num_field(s, " rip 0x%lx", event, "guest_rip", record, 1);
tep_print_num_field(s, " rip 0x%lx", event, "guest_rip", record, 1);
if (pevent_get_field_val(s, event, "info1", record, &info1, 0) >= 0
&& pevent_get_field_val(s, event, "info2", record, &info2, 0) >= 0)
if (tep_get_field_val(s, event, "info1", record, &info1, 0) >= 0
&& tep_get_field_val(s, event, "info2", record, &info2, 0) >= 0)
trace_seq_printf(s, " info %llx %llx", info1, info2);
return 0;
@ -291,7 +291,7 @@ static int kvm_exit_handler(struct trace_seq *s, struct pevent_record *record,
#define KVM_EMUL_INSN_F_CS_L (1 << 3)
static int kvm_emulate_insn_handler(struct trace_seq *s,
struct pevent_record *record,
struct tep_record *record,
struct event_format *event, void *context)
{
unsigned long long rip, csbase, len, flags, failed;
@ -299,22 +299,22 @@ static int kvm_emulate_insn_handler(struct trace_seq *s,
uint8_t *insn;
const char *disasm;
if (pevent_get_field_val(s, event, "rip", record, &rip, 1) < 0)
if (tep_get_field_val(s, event, "rip", record, &rip, 1) < 0)
return -1;
if (pevent_get_field_val(s, event, "csbase", record, &csbase, 1) < 0)
if (tep_get_field_val(s, event, "csbase", record, &csbase, 1) < 0)
return -1;
if (pevent_get_field_val(s, event, "len", record, &len, 1) < 0)
if (tep_get_field_val(s, event, "len", record, &len, 1) < 0)
return -1;
if (pevent_get_field_val(s, event, "flags", record, &flags, 1) < 0)
if (tep_get_field_val(s, event, "flags", record, &flags, 1) < 0)
return -1;
if (pevent_get_field_val(s, event, "failed", record, &failed, 1) < 0)
if (tep_get_field_val(s, event, "failed", record, &failed, 1) < 0)
return -1;
insn = pevent_get_field_raw(s, event, "insn", record, &llen, 1);
insn = tep_get_field_raw(s, event, "insn", record, &llen, 1);
if (!insn)
return -1;
@ -330,24 +330,24 @@ static int kvm_emulate_insn_handler(struct trace_seq *s,
}
static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct pevent_record *record,
static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct tep_record *record,
struct event_format *event, void *context)
{
if (print_exit_reason(s, record, event, "exit_code") < 0)
return -1;
pevent_print_num_field(s, " info1 %llx", event, "exit_info1", record, 1);
pevent_print_num_field(s, " info2 %llx", event, "exit_info2", record, 1);
pevent_print_num_field(s, " int_info %llx", event, "exit_int_info", record, 1);
pevent_print_num_field(s, " int_info_err %llx", event, "exit_int_info_err", record, 1);
tep_print_num_field(s, " info1 %llx", event, "exit_info1", record, 1);
tep_print_num_field(s, " info2 %llx", event, "exit_info2", record, 1);
tep_print_num_field(s, " int_info %llx", event, "exit_int_info", record, 1);
tep_print_num_field(s, " int_info_err %llx", event, "exit_int_info_err", record, 1);
return 0;
}
static int kvm_nested_vmexit_handler(struct trace_seq *s, struct pevent_record *record,
static int kvm_nested_vmexit_handler(struct trace_seq *s, struct tep_record *record,
struct event_format *event, void *context)
{
pevent_print_num_field(s, "rip %llx ", event, "rip", record, 1);
tep_print_num_field(s, "rip %llx ", event, "rip", record, 1);
return kvm_nested_vmexit_inject_handler(s, record, event, context);
}
@ -370,7 +370,7 @@ union kvm_mmu_page_role {
};
};
static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record,
static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record,
struct event_format *event, void *context)
{
unsigned long long val;
@ -379,7 +379,7 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record,
};
union kvm_mmu_page_role role;
if (pevent_get_field_val(s, event, "role", record, &val, 1) < 0)
if (tep_get_field_val(s, event, "role", record, &val, 1) < 0)
return -1;
role.word = (int)val;
@ -388,8 +388,8 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record,
* We can only use the structure if file is of the same
* endianess.
*/
if (pevent_is_file_bigendian(event->pevent) ==
pevent_is_host_bigendian(event->pevent)) {
if (tep_is_file_bigendian(event->pevent) ==
tep_is_host_bigendian(event->pevent)) {
trace_seq_printf(s, "%u q%u%s %s%s %spae %snxe %swp%s%s%s",
role.level,
@ -406,10 +406,10 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record,
} else
trace_seq_printf(s, "WORD: %08x", role.word);
pevent_print_num_field(s, " root %u ", event,
"root_count", record, 1);
tep_print_num_field(s, " root %u ", event,
"root_count", record, 1);
if (pevent_get_field_val(s, event, "unsync", record, &val, 1) < 0)
if (tep_get_field_val(s, event, "unsync", record, &val, 1) < 0)
return -1;
trace_seq_printf(s, "%s%c", val ? "unsync" : "sync", 0);
@ -417,17 +417,17 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record,
}
static int kvm_mmu_get_page_handler(struct trace_seq *s,
struct pevent_record *record,
struct tep_record *record,
struct event_format *event, void *context)
{
unsigned long long val;
if (pevent_get_field_val(s, event, "created", record, &val, 1) < 0)
if (tep_get_field_val(s, event, "created", record, &val, 1) < 0)
return -1;
trace_seq_printf(s, "%s ", val ? "new" : "existing");
if (pevent_get_field_val(s, event, "gfn", record, &val, 1) < 0)
if (tep_get_field_val(s, event, "gfn", record, &val, 1) < 0)
return -1;
trace_seq_printf(s, "sp gfn %llx ", val);
@ -444,79 +444,79 @@ process_is_writable_pte(struct trace_seq *s, unsigned long long *args)
return pte & PT_WRITABLE_MASK;
}
int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
{
init_disassembler();
pevent_register_event_handler(pevent, -1, "kvm", "kvm_exit",
kvm_exit_handler, NULL);
tep_register_event_handler(pevent, -1, "kvm", "kvm_exit",
kvm_exit_handler, NULL);
pevent_register_event_handler(pevent, -1, "kvm", "kvm_emulate_insn",
kvm_emulate_insn_handler, NULL);
tep_register_event_handler(pevent, -1, "kvm", "kvm_emulate_insn",
kvm_emulate_insn_handler, NULL);
pevent_register_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit",
kvm_nested_vmexit_handler, NULL);
tep_register_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit",
kvm_nested_vmexit_handler, NULL);
pevent_register_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit_inject",
kvm_nested_vmexit_inject_handler, NULL);
tep_register_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit_inject",
kvm_nested_vmexit_inject_handler, NULL);
pevent_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page",
kvm_mmu_get_page_handler, NULL);
tep_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page",
kvm_mmu_get_page_handler, NULL);
pevent_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_sync_page",
kvm_mmu_print_role, NULL);
tep_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_sync_page",
kvm_mmu_print_role, NULL);
pevent_register_event_handler(pevent, -1,
"kvmmmu", "kvm_mmu_unsync_page",
kvm_mmu_print_role, NULL);
tep_register_event_handler(pevent, -1,
"kvmmmu", "kvm_mmu_unsync_page",
kvm_mmu_print_role, NULL);
pevent_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page",
kvm_mmu_print_role, NULL);
tep_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page",
kvm_mmu_print_role, NULL);
pevent_register_event_handler(pevent, -1, "kvmmmu",
tep_register_event_handler(pevent, -1, "kvmmmu",
"kvm_mmu_prepare_zap_page", kvm_mmu_print_role,
NULL);
pevent_register_print_function(pevent,
process_is_writable_pte,
PEVENT_FUNC_ARG_INT,
"is_writable_pte",
PEVENT_FUNC_ARG_LONG,
PEVENT_FUNC_ARG_VOID);
tep_register_print_function(pevent,
process_is_writable_pte,
TEP_FUNC_ARG_INT,
"is_writable_pte",
TEP_FUNC_ARG_LONG,
TEP_FUNC_ARG_VOID);
return 0;
}
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
{
pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_exit",
kvm_exit_handler, NULL);
tep_unregister_event_handler(pevent, -1, "kvm", "kvm_exit",
kvm_exit_handler, NULL);
pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_emulate_insn",
kvm_emulate_insn_handler, NULL);
tep_unregister_event_handler(pevent, -1, "kvm", "kvm_emulate_insn",
kvm_emulate_insn_handler, NULL);
pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit",
kvm_nested_vmexit_handler, NULL);
tep_unregister_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit",
kvm_nested_vmexit_handler, NULL);
pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit_inject",
kvm_nested_vmexit_inject_handler, NULL);
tep_unregister_event_handler(pevent, -1, "kvm", "kvm_nested_vmexit_inject",
kvm_nested_vmexit_inject_handler, NULL);
pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page",
kvm_mmu_get_page_handler, NULL);
tep_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page",
kvm_mmu_get_page_handler, NULL);
pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_sync_page",
kvm_mmu_print_role, NULL);
tep_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_sync_page",
kvm_mmu_print_role, NULL);
pevent_unregister_event_handler(pevent, -1,
"kvmmmu", "kvm_mmu_unsync_page",
kvm_mmu_print_role, NULL);
tep_unregister_event_handler(pevent, -1,
"kvmmmu", "kvm_mmu_unsync_page",
kvm_mmu_print_role, NULL);
pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page",
kvm_mmu_print_role, NULL);
tep_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page",
kvm_mmu_print_role, NULL);
pevent_unregister_event_handler(pevent, -1, "kvmmmu",
tep_unregister_event_handler(pevent, -1, "kvmmmu",
"kvm_mmu_prepare_zap_page", kvm_mmu_print_role,
NULL);
pevent_unregister_print_function(pevent, process_is_writable_pte,
"is_writable_pte");
tep_unregister_print_function(pevent, process_is_writable_pte,
"is_writable_pte");
}

View File

@ -28,7 +28,7 @@
static void print_string(struct trace_seq *s, struct event_format *event,
const char *name, const void *data)
{
struct format_field *f = pevent_find_field(event, name);
struct format_field *f = tep_find_field(event, name);
int offset;
int length;
@ -42,7 +42,7 @@ static void print_string(struct trace_seq *s, struct event_format *event,
if (!strncmp(f->type, "__data_loc", 10)) {
unsigned long long v;
if (pevent_read_number_field(f, data, &v)) {
if (tep_read_number_field(f, data, &v)) {
trace_seq_printf(s, "invalid_data_loc");
return;
}
@ -53,12 +53,12 @@ static void print_string(struct trace_seq *s, struct event_format *event,
trace_seq_printf(s, "%.*s", length, (char *)data + offset);
}
#define SF(fn) pevent_print_num_field(s, fn ":%d", event, fn, record, 0)
#define SFX(fn) pevent_print_num_field(s, fn ":%#x", event, fn, record, 0)
#define SF(fn) tep_print_num_field(s, fn ":%d", event, fn, record, 0)
#define SFX(fn) tep_print_num_field(s, fn ":%#x", event, fn, record, 0)
#define SP() trace_seq_putc(s, ' ')
static int drv_bss_info_changed(struct trace_seq *s,
struct pevent_record *record,
struct tep_record *record,
struct event_format *event, void *context)
{
void *data = record->data;
@ -66,7 +66,7 @@ static int drv_bss_info_changed(struct trace_seq *s,
print_string(s, event, "wiphy_name", data);
trace_seq_printf(s, " vif:");
print_string(s, event, "vif_name", data);
pevent_print_num_field(s, "(%d)", event, "vif_type", record, 1);
tep_print_num_field(s, "(%d)", event, "vif_type", record, 1);
trace_seq_printf(s, "\n%*s", INDENT, "");
SF("assoc"); SP();
@ -86,17 +86,17 @@ static int drv_bss_info_changed(struct trace_seq *s,
return 0;
}
int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
{
pevent_register_event_handler(pevent, -1, "mac80211",
"drv_bss_info_changed",
drv_bss_info_changed, NULL);
tep_register_event_handler(pevent, -1, "mac80211",
"drv_bss_info_changed",
drv_bss_info_changed, NULL);
return 0;
}
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
{
pevent_unregister_event_handler(pevent, -1, "mac80211",
"drv_bss_info_changed",
drv_bss_info_changed, NULL);
tep_unregister_event_handler(pevent, -1, "mac80211",
"drv_bss_info_changed",
drv_bss_info_changed, NULL);
}

View File

@ -45,7 +45,7 @@ static void write_state(struct trace_seq *s, int val)
}
static void write_and_save_comm(struct format_field *field,
struct pevent_record *record,
struct tep_record *record,
struct trace_seq *s, int pid)
{
const char *comm;
@ -61,100 +61,100 @@ static void write_and_save_comm(struct format_field *field,
comm = &s->buffer[len];
/* Help out the comm to ids. This will handle dups */
pevent_register_comm(field->event->pevent, comm, pid);
tep_register_comm(field->event->pevent, comm, pid);
}
static int sched_wakeup_handler(struct trace_seq *s,
struct pevent_record *record,
struct tep_record *record,
struct event_format *event, void *context)
{
struct format_field *field;
unsigned long long val;
if (pevent_get_field_val(s, event, "pid", record, &val, 1))
if (tep_get_field_val(s, event, "pid", record, &val, 1))
return trace_seq_putc(s, '!');
field = pevent_find_any_field(event, "comm");
field = tep_find_any_field(event, "comm");
if (field) {
write_and_save_comm(field, record, s, val);
trace_seq_putc(s, ':');
}
trace_seq_printf(s, "%lld", val);
if (pevent_get_field_val(s, event, "prio", record, &val, 0) == 0)
if (tep_get_field_val(s, event, "prio", record, &val, 0) == 0)
trace_seq_printf(s, " [%lld]", val);
if (pevent_get_field_val(s, event, "success", record, &val, 1) == 0)
if (tep_get_field_val(s, event, "success", record, &val, 1) == 0)
trace_seq_printf(s, " success=%lld", val);
if (pevent_get_field_val(s, event, "target_cpu", record, &val, 0) == 0)
if (tep_get_field_val(s, event, "target_cpu", record, &val, 0) == 0)
trace_seq_printf(s, " CPU:%03llu", val);
return 0;
}
static int sched_switch_handler(struct trace_seq *s,
struct pevent_record *record,
struct tep_record *record,
struct event_format *event, void *context)
{
struct format_field *field;
unsigned long long val;
if (pevent_get_field_val(s, event, "prev_pid", record, &val, 1))
if (tep_get_field_val(s, event, "prev_pid", record, &val, 1))
return trace_seq_putc(s, '!');
field = pevent_find_any_field(event, "prev_comm");
field = tep_find_any_field(event, "prev_comm");
if (field) {
write_and_save_comm(field, record, s, val);
trace_seq_putc(s, ':');
}
trace_seq_printf(s, "%lld ", val);
if (pevent_get_field_val(s, event, "prev_prio", record, &val, 0) == 0)
if (tep_get_field_val(s, event, "prev_prio", record, &val, 0) == 0)
trace_seq_printf(s, "[%d] ", (int) val);
if (pevent_get_field_val(s, event, "prev_state", record, &val, 0) == 0)
if (tep_get_field_val(s, event, "prev_state", record, &val, 0) == 0)
write_state(s, val);
trace_seq_puts(s, " ==> ");
if (pevent_get_field_val(s, event, "next_pid", record, &val, 1))
if (tep_get_field_val(s, event, "next_pid", record, &val, 1))
return trace_seq_putc(s, '!');
field = pevent_find_any_field(event, "next_comm");
field = tep_find_any_field(event, "next_comm");
if (field) {
write_and_save_comm(field, record, s, val);
trace_seq_putc(s, ':');
}
trace_seq_printf(s, "%lld", val);
if (pevent_get_field_val(s, event, "next_prio", record, &val, 0) == 0)
if (tep_get_field_val(s, event, "next_prio", record, &val, 0) == 0)
trace_seq_printf(s, " [%d]", (int) val);
return 0;
}
int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
{
pevent_register_event_handler(pevent, -1, "sched", "sched_switch",
sched_switch_handler, NULL);
tep_register_event_handler(pevent, -1, "sched", "sched_switch",
sched_switch_handler, NULL);
pevent_register_event_handler(pevent, -1, "sched", "sched_wakeup",
sched_wakeup_handler, NULL);
tep_register_event_handler(pevent, -1, "sched", "sched_wakeup",
sched_wakeup_handler, NULL);
pevent_register_event_handler(pevent, -1, "sched", "sched_wakeup_new",
sched_wakeup_handler, NULL);
tep_register_event_handler(pevent, -1, "sched", "sched_wakeup_new",
sched_wakeup_handler, NULL);
return 0;
}
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
{
pevent_unregister_event_handler(pevent, -1, "sched", "sched_switch",
sched_switch_handler, NULL);
tep_unregister_event_handler(pevent, -1, "sched", "sched_switch",
sched_switch_handler, NULL);
pevent_unregister_event_handler(pevent, -1, "sched", "sched_wakeup",
sched_wakeup_handler, NULL);
tep_unregister_event_handler(pevent, -1, "sched", "sched_wakeup",
sched_wakeup_handler, NULL);
pevent_unregister_event_handler(pevent, -1, "sched", "sched_wakeup_new",
sched_wakeup_handler, NULL);
tep_unregister_event_handler(pevent, -1, "sched", "sched_wakeup_new",
sched_wakeup_handler, NULL);
}

View File

@ -413,21 +413,21 @@ unsigned long long process_scsi_trace_parse_cdb(struct trace_seq *s,
return 0;
}
int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
{
pevent_register_print_function(pevent,
process_scsi_trace_parse_cdb,
PEVENT_FUNC_ARG_STRING,
"scsi_trace_parse_cdb",
PEVENT_FUNC_ARG_PTR,
PEVENT_FUNC_ARG_PTR,
PEVENT_FUNC_ARG_INT,
PEVENT_FUNC_ARG_VOID);
tep_register_print_function(pevent,
process_scsi_trace_parse_cdb,
TEP_FUNC_ARG_STRING,
"scsi_trace_parse_cdb",
TEP_FUNC_ARG_PTR,
TEP_FUNC_ARG_PTR,
TEP_FUNC_ARG_INT,
TEP_FUNC_ARG_VOID);
return 0;
}
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
{
pevent_unregister_print_function(pevent, process_scsi_trace_parse_cdb,
"scsi_trace_parse_cdb");
tep_unregister_print_function(pevent, process_scsi_trace_parse_cdb,
"scsi_trace_parse_cdb");
}

View File

@ -119,19 +119,19 @@ unsigned long long process_xen_hypercall_name(struct trace_seq *s,
return 0;
}
int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
{
pevent_register_print_function(pevent,
process_xen_hypercall_name,
PEVENT_FUNC_ARG_STRING,
"xen_hypercall_name",
PEVENT_FUNC_ARG_INT,
PEVENT_FUNC_ARG_VOID);
tep_register_print_function(pevent,
process_xen_hypercall_name,
TEP_FUNC_ARG_STRING,
"xen_hypercall_name",
TEP_FUNC_ARG_INT,
TEP_FUNC_ARG_VOID);
return 0;
}
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
{
pevent_unregister_print_function(pevent, process_xen_hypercall_name,
"xen_hypercall_name");
tep_unregister_print_function(pevent, process_xen_hypercall_name,
"xen_hypercall_name");
}

View File

@ -1,21 +1,7 @@
// SPDX-License-Identifier: LGPL-2.1
/*
* Copyright (C) 2009 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License (not later!)
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see <http://www.gnu.org/licenses>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#include <stdio.h>
#include <stdlib.h>

View File

@ -118,6 +118,15 @@ OPTIONS
--group::
Show event group information together
--percent-type::
Set annotation percent type from following choices:
global-period, local-period, global-hits, local-hits
The local/global keywords set if the percentage is computed
in the scope of the function (local) or the whole data (global).
The period/hits keywords set the base the percentage is computed
on - the samples period or the number of samples (hits).
SEE ALSO
--------
linkperf:perf-record[1], linkperf:perf-report[1]

View File

@ -477,6 +477,15 @@ include::itrace.txt[]
Display monitored tasks stored in perf data. Displaying pid/tid/ppid
plus the command string aligned to distinguish parent and child tasks.
--percent-type::
Set annotation percent type from following choices:
global-period, local-period, global-hits, local-hits
The local/global keywords set if the percentage is computed
in the scope of the function (local) or the whole data (global).
The period/hits keywords set the base the percentage is computed
on - the samples period or the number of samples (hits).
include::callchain-overhead-calculation.txt[]
SEE ALSO

View File

@ -84,10 +84,10 @@ endif # has_clean
endif # MAKECMDGOALS
#
# The clean target is not really parallel, don't print the jobs info:
# Explicitly disable parallelism for the clean target.
#
clean:
$(make)
$(make) -j1
#
# The build-test target is not really parallel, don't print the jobs info,

View File

@ -194,6 +194,7 @@ struct auxtrace_record *arm_spe_recording_init(int *err,
sper->itr.read_finish = arm_spe_read_finish;
sper->itr.alignment = 0;
*err = 0;
return &sper->itr;
}

View File

@ -141,8 +141,10 @@ void arch__post_process_probe_trace_events(struct perf_probe_event *pev,
for (i = 0; i < ntevs; i++) {
tev = &pev->tevs[i];
map__for_each_symbol(map, sym, tmp) {
if (map->unmap_ip(map, sym->start) == tev->point.address)
if (map->unmap_ip(map, sym->start) == tev->point.address) {
arch__fix_tev_from_maps(pev, tev, map, sym);
break;
}
}
}
}

View File

@ -30,6 +30,7 @@ cpumsf_info_fill(struct auxtrace_record *itr __maybe_unused,
struct auxtrace_info_event *auxtrace_info __maybe_unused,
size_t priv_size __maybe_unused)
{
auxtrace_info->type = PERF_AUXTRACE_S390_CPUMSF;
return 0;
}

View File

@ -19,9 +19,6 @@ systbl := $(sys)/syscalltbl.sh
_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
$(header): $(sys)/syscall_64.tbl $(systbl)
@(test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
(diff -B arch/x86/entry/syscalls/syscall_64.tbl ../../arch/x86/entry/syscalls/syscall_64.tbl >/dev/null) \
|| echo "Warning: Kernel ABI header at 'tools/perf/arch/x86/entry/syscalls/syscall_64.tbl' differs from latest version at 'arch/x86/entry/syscalls/syscall_64.tbl'" >&2 )) || true
$(Q)$(SHELL) '$(systbl)' $(sys)/syscall_64.tbl 'x86_64' > $@
clean::

View File

@ -542,6 +542,10 @@ int cmd_annotate(int argc, const char **argv)
OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
"'always' (default), 'never' or 'auto' only applicable to --stdio mode",
stdio__config_color, "always"),
OPT_CALLBACK(0, "percent-type", &annotate.opts, "local-period",
"Set percent type local/global-period/hits",
annotate_parse_percent_type),
OPT_END()
};
int ret;

View File

@ -729,7 +729,7 @@ static char *compact_gfp_string(unsigned long gfp_flags)
static int parse_gfp_flags(struct perf_evsel *evsel, struct perf_sample *sample,
unsigned int gfp_flags)
{
struct pevent_record record = {
struct tep_record record = {
.cpu = sample->cpu,
.data = sample->raw_data,
.size = sample->raw_size,
@ -747,7 +747,7 @@ static int parse_gfp_flags(struct perf_evsel *evsel, struct perf_sample *sample,
}
trace_seq_init(&seq);
pevent_event_info(&seq, evsel->tp_format, &record);
tep_event_info(&seq, evsel->tp_format, &record);
str = strtok_r(seq.buffer, " ", &pos);
while (str) {
@ -1974,7 +1974,7 @@ int cmd_kmem(int argc, const char **argv)
goto out_delete;
}
kmem_page_size = pevent_get_page_size(evsel->tp_format->pevent);
kmem_page_size = tep_get_page_size(evsel->tp_format->pevent);
symbol_conf.use_callchain = true;
}

View File

@ -1124,6 +1124,9 @@ int cmd_report(int argc, const char **argv)
"Time span of interest (start,stop)"),
OPT_BOOLEAN(0, "inline", &symbol_conf.inline_name,
"Show inline function"),
OPT_CALLBACK(0, "percent-type", &report.annotation_opts, "local-period",
"Set percent type local/global-period/hits",
annotate_parse_percent_type),
OPT_END()
};
struct perf_data data = {
@ -1366,9 +1369,9 @@ int cmd_report(int argc, const char **argv)
}
if (session->tevent.pevent &&
pevent_set_function_resolver(session->tevent.pevent,
machine__resolve_kernel_addr,
&session->machines.host) < 0) {
tep_set_function_resolver(session->tevent.pevent,
machine__resolve_kernel_addr,
&session->machines.host) < 0) {
pr_err("%s: failed to set libtraceevent function resolver\n",
__func__);
return -1;

View File

@ -3429,9 +3429,9 @@ int cmd_script(int argc, const char **argv)
symbol_conf.use_callchain = false;
if (session->tevent.pevent &&
pevent_set_function_resolver(session->tevent.pevent,
machine__resolve_kernel_addr,
&session->machines.host) < 0) {
tep_set_function_resolver(session->tevent.pevent,
machine__resolve_kernel_addr,
&session->machines.host) < 0) {
pr_err("%s: failed to set libtraceevent function resolver\n", __func__);
err = -1;
goto out_delete;

View File

@ -77,7 +77,8 @@ struct trace {
struct syscall *table;
struct {
struct perf_evsel *sys_enter,
*sys_exit;
*sys_exit,
*augmented;
} events;
} syscalls;
struct record_opts opts;
@ -121,7 +122,6 @@ struct trace {
bool force;
bool vfs_getname;
int trace_pgfaults;
int open_id;
};
struct tp_field {
@ -157,13 +157,11 @@ TP_UINT_FIELD__SWAPPED(16);
TP_UINT_FIELD__SWAPPED(32);
TP_UINT_FIELD__SWAPPED(64);
static int tp_field__init_uint(struct tp_field *field,
struct format_field *format_field,
bool needs_swap)
static int __tp_field__init_uint(struct tp_field *field, int size, int offset, bool needs_swap)
{
field->offset = format_field->offset;
field->offset = offset;
switch (format_field->size) {
switch (size) {
case 1:
field->integer = tp_field__u8;
break;
@ -183,18 +181,28 @@ static int tp_field__init_uint(struct tp_field *field,
return 0;
}
static int tp_field__init_uint(struct tp_field *field, struct format_field *format_field, bool needs_swap)
{
return __tp_field__init_uint(field, format_field->size, format_field->offset, needs_swap);
}
static void *tp_field__ptr(struct tp_field *field, struct perf_sample *sample)
{
return sample->raw_data + field->offset;
}
static int tp_field__init_ptr(struct tp_field *field, struct format_field *format_field)
static int __tp_field__init_ptr(struct tp_field *field, int offset)
{
field->offset = format_field->offset;
field->offset = offset;
field->pointer = tp_field__ptr;
return 0;
}
static int tp_field__init_ptr(struct tp_field *field, struct format_field *format_field)
{
return __tp_field__init_ptr(field, format_field->offset);
}
struct syscall_tp {
struct tp_field id;
union {
@ -240,7 +248,47 @@ static void perf_evsel__delete_priv(struct perf_evsel *evsel)
perf_evsel__delete(evsel);
}
static int perf_evsel__init_syscall_tp(struct perf_evsel *evsel, void *handler)
static int perf_evsel__init_syscall_tp(struct perf_evsel *evsel)
{
struct syscall_tp *sc = evsel->priv = malloc(sizeof(struct syscall_tp));
if (evsel->priv != NULL) {
if (perf_evsel__init_tp_uint_field(evsel, &sc->id, "__syscall_nr"))
goto out_delete;
return 0;
}
return -ENOMEM;
out_delete:
zfree(&evsel->priv);
return -ENOENT;
}
static int perf_evsel__init_augmented_syscall_tp(struct perf_evsel *evsel)
{
struct syscall_tp *sc = evsel->priv = malloc(sizeof(struct syscall_tp));
if (evsel->priv != NULL) { /* field, sizeof_field, offsetof_field */
if (__tp_field__init_uint(&sc->id, sizeof(long), sizeof(long long), evsel->needs_swap))
goto out_delete;
return 0;
}
return -ENOMEM;
out_delete:
zfree(&evsel->priv);
return -EINVAL;
}
static int perf_evsel__init_augmented_syscall_tp_args(struct perf_evsel *evsel)
{
struct syscall_tp *sc = evsel->priv;
return __tp_field__init_ptr(&sc->args, sc->id.offset + sizeof(u64));
}
static int perf_evsel__init_raw_syscall_tp(struct perf_evsel *evsel, void *handler)
{
evsel->priv = malloc(sizeof(struct syscall_tp));
if (evsel->priv != NULL) {
@ -258,7 +306,7 @@ static int perf_evsel__init_syscall_tp(struct perf_evsel *evsel, void *handler)
return -ENOENT;
}
static struct perf_evsel *perf_evsel__syscall_newtp(const char *direction, void *handler)
static struct perf_evsel *perf_evsel__raw_syscall_newtp(const char *direction, void *handler)
{
struct perf_evsel *evsel = perf_evsel__newtp("raw_syscalls", direction);
@ -269,7 +317,7 @@ static struct perf_evsel *perf_evsel__syscall_newtp(const char *direction, void
if (IS_ERR(evsel))
return NULL;
if (perf_evsel__init_syscall_tp(evsel, handler))
if (perf_evsel__init_raw_syscall_tp(evsel, handler))
goto out_delete;
return evsel;
@ -805,12 +853,17 @@ static struct syscall_fmt *syscall_fmt__find(const char *name)
return bsearch(name, syscall_fmts, nmemb, sizeof(struct syscall_fmt), syscall_fmt__cmp);
}
/*
* is_exit: is this "exit" or "exit_group"?
* is_open: is this "open" or "openat"? To associate the fd returned in sys_exit with the pathname in sys_enter.
*/
struct syscall {
struct event_format *tp_format;
int nr_args;
bool is_exit;
bool is_open;
struct format_field *args;
const char *name;
bool is_exit;
struct syscall_fmt *fmt;
struct syscall_arg_fmt *arg_fmt;
};
@ -1299,6 +1352,7 @@ static int trace__read_syscall_info(struct trace *trace, int id)
}
sc->is_exit = !strcmp(name, "exit_group") || !strcmp(name, "exit");
sc->is_open = !strcmp(name, "open") || !strcmp(name, "openat");
return syscall__set_arg_fmts(sc);
}
@ -1661,6 +1715,37 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
return err;
}
static int trace__fprintf_sys_enter(struct trace *trace, struct perf_evsel *evsel,
struct perf_sample *sample)
{
struct thread_trace *ttrace;
struct thread *thread;
int id = perf_evsel__sc_tp_uint(evsel, id, sample), err = -1;
struct syscall *sc = trace__syscall_info(trace, evsel, id);
char msg[1024];
void *args;
if (sc == NULL)
return -1;
thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
ttrace = thread__trace(thread, trace->output);
/*
* We need to get ttrace just to make sure it is there when syscall__scnprintf_args()
* and the rest of the beautifiers accessing it via struct syscall_arg touches it.
*/
if (ttrace == NULL)
goto out_put;
args = perf_evsel__sc_tp_ptr(evsel, args, sample);
syscall__scnprintf_args(sc, msg, sizeof(msg), args, trace, thread);
fprintf(trace->output, "%s", msg);
err = 0;
out_put:
thread__put(thread);
return err;
}
static int trace__resolve_callchain(struct trace *trace, struct perf_evsel *evsel,
struct perf_sample *sample,
struct callchain_cursor *cursor)
@ -1722,7 +1807,7 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
ret = perf_evsel__sc_tp_uint(evsel, ret, sample);
if (id == trace->open_id && ret >= 0 && ttrace->filename.pending_open) {
if (sc->is_open && ret >= 0 && ttrace->filename.pending_open) {
trace__set_fd_pathname(thread, ret, ttrace->filename.name);
ttrace->filename.pending_open = false;
++trace->stats.vfs_getname;
@ -1957,11 +2042,17 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel,
fprintf(trace->output, "%s:", evsel->name);
if (perf_evsel__is_bpf_output(evsel)) {
bpf_output__fprintf(trace, sample);
if (evsel == trace->syscalls.events.augmented)
trace__fprintf_sys_enter(trace, evsel, sample);
else
bpf_output__fprintf(trace, sample);
} else if (evsel->tp_format) {
event_format__fprintf(evsel->tp_format, sample->cpu,
sample->raw_data, sample->raw_size,
trace->output);
if (strncmp(evsel->tp_format->name, "sys_enter_", 10) ||
trace__fprintf_sys_enter(trace, evsel, sample)) {
event_format__fprintf(evsel->tp_format, sample->cpu,
sample->raw_data, sample->raw_size,
trace->output);
}
}
fprintf(trace->output, "\n");
@ -2242,14 +2333,14 @@ static int trace__add_syscall_newtp(struct trace *trace)
struct perf_evlist *evlist = trace->evlist;
struct perf_evsel *sys_enter, *sys_exit;
sys_enter = perf_evsel__syscall_newtp("sys_enter", trace__sys_enter);
sys_enter = perf_evsel__raw_syscall_newtp("sys_enter", trace__sys_enter);
if (sys_enter == NULL)
goto out;
if (perf_evsel__init_sc_tp_ptr_field(sys_enter, args))
goto out_delete_sys_enter;
sys_exit = perf_evsel__syscall_newtp("sys_exit", trace__sys_exit);
sys_exit = perf_evsel__raw_syscall_newtp("sys_exit", trace__sys_exit);
if (sys_exit == NULL)
goto out_delete_sys_enter;
@ -2671,7 +2762,7 @@ static int trace__replay(struct trace *trace)
"syscalls:sys_enter");
if (evsel &&
(perf_evsel__init_syscall_tp(evsel, trace__sys_enter) < 0 ||
(perf_evsel__init_raw_syscall_tp(evsel, trace__sys_enter) < 0 ||
perf_evsel__init_sc_tp_ptr_field(evsel, args))) {
pr_err("Error during initialize raw_syscalls:sys_enter event\n");
goto out;
@ -2683,7 +2774,7 @@ static int trace__replay(struct trace *trace)
evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
"syscalls:sys_exit");
if (evsel &&
(perf_evsel__init_syscall_tp(evsel, trace__sys_exit) < 0 ||
(perf_evsel__init_raw_syscall_tp(evsel, trace__sys_exit) < 0 ||
perf_evsel__init_sc_tp_uint_field(evsel, ret))) {
pr_err("Error during initialize raw_syscalls:sys_exit event\n");
goto out;
@ -2923,6 +3014,36 @@ static void evlist__set_evsel_handler(struct perf_evlist *evlist, void *handler)
evsel->handler = handler;
}
static int evlist__set_syscall_tp_fields(struct perf_evlist *evlist)
{
struct perf_evsel *evsel;
evlist__for_each_entry(evlist, evsel) {
if (evsel->priv || !evsel->tp_format)
continue;
if (strcmp(evsel->tp_format->system, "syscalls"))
continue;
if (perf_evsel__init_syscall_tp(evsel))
return -1;
if (!strncmp(evsel->tp_format->name, "sys_enter_", 10)) {
struct syscall_tp *sc = evsel->priv;
if (__tp_field__init_ptr(&sc->args, sc->id.offset + sizeof(u64)))
return -1;
} else if (!strncmp(evsel->tp_format->name, "sys_exit_", 9)) {
struct syscall_tp *sc = evsel->priv;
if (__tp_field__init_uint(&sc->ret, sizeof(u64), sc->id.offset + sizeof(u64), evsel->needs_swap))
return -1;
}
}
return 0;
}
/*
* XXX: Hackish, just splitting the combined -e+--event (syscalls
* (raw_syscalls:{sys_{enter,exit}} + events (tracepoints, HW, SW, etc) to use
@ -3123,8 +3244,9 @@ int cmd_trace(int argc, const char **argv)
};
bool __maybe_unused max_stack_user_set = true;
bool mmap_pages_user_set = true;
struct perf_evsel *evsel;
const char * const trace_subcommands[] = { "record", NULL };
int err;
int err = -1;
char bf[BUFSIZ];
signal(SIGSEGV, sighandler_dump_stack);
@ -3147,6 +3269,20 @@ int cmd_trace(int argc, const char **argv)
"cgroup monitoring only available in system-wide mode");
}
evsel = bpf__setup_output_event(trace.evlist, "__augmented_syscalls__");
if (IS_ERR(evsel)) {
bpf__strerror_setup_output_event(trace.evlist, PTR_ERR(evsel), bf, sizeof(bf));
pr_err("ERROR: Setup trace syscalls enter failed: %s\n", bf);
goto out;
}
if (evsel) {
if (perf_evsel__init_augmented_syscall_tp(evsel) ||
perf_evsel__init_augmented_syscall_tp_args(evsel))
goto out;
trace.syscalls.events.augmented = evsel;
}
err = bpf__setup_stdout(trace.evlist);
if (err) {
bpf__strerror_setup_stdout(trace.evlist, err, bf, sizeof(bf));
@ -3182,8 +3318,13 @@ int cmd_trace(int argc, const char **argv)
symbol_conf.use_callchain = true;
}
if (trace.evlist->nr_entries > 0)
if (trace.evlist->nr_entries > 0) {
evlist__set_evsel_handler(trace.evlist, trace__event_handler);
if (evlist__set_syscall_tp_fields(trace.evlist)) {
perror("failed to set syscalls:* tracepoint fields");
goto out;
}
}
if ((argc >= 1) && (strcmp(argv[0], "record") == 0))
return trace__record(&trace, argc-1, &argv[1]);
@ -3205,8 +3346,6 @@ int cmd_trace(int argc, const char **argv)
}
}
trace.open_id = syscalltbl__id(trace.sctbl, "open");
err = target__validate(&trace.opts.target);
if (err) {
target__strerror(&trace.opts.target, err, bf, sizeof(bf));

View File

@ -67,8 +67,12 @@ check_2 () {
cmd="diff $* $file1 $file2 > /dev/null"
test -f $file2 &&
eval $cmd || echo "Warning: Kernel ABI header at 'tools/$file' differs from latest version at '$file'" >&2
test -f $file2 && {
eval $cmd || {
echo "Warning: Kernel ABI header at '$file1' differs from latest version at '$file2'" >&2
echo diff -u $file1 $file2
}
}
}
check () {
@ -76,7 +80,7 @@ check () {
shift
check_2 ../$file ../../$file $*
check_2 tools/$file $file $*
}
# Check if we have the kernel headers (tools/perf/../../include), else
@ -84,6 +88,8 @@ check () {
# differences.
test -d ../../include || exit 0
cd ../..
# simple diff check
for i in $HEADERS; do
check $i -B
@ -94,3 +100,8 @@ check arch/x86/lib/memcpy_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/ex
check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"'
check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common.h>"'
check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"'
# diff non-symmetric files
check_2 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl
cd tools/perf

View File

@ -0,0 +1,55 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Augment the openat syscall with the contents of the filename pointer argument.
*
* Test it with:
*
* perf trace -e tools/perf/examples/bpf/augmented_syscalls.c cat /etc/passwd > /dev/null
*
* It'll catch some openat syscalls related to the dynamic linked and
* the last one should be the one for '/etc/passwd'.
*
* This matches what is marshalled into the raw_syscall:sys_enter payload
* expected by the 'perf trace' beautifiers, and can be used by them unmodified,
* which will be done as that feature is implemented in the next csets, for now
* it will appear in a dump done by the default tracepoint handler in 'perf trace',
* that uses bpf_output__fprintf() to just dump those contents, as done with
* the bpf-output event associated with the __bpf_output__ map declared in
* tools/perf/include/bpf/stdio.h.
*/
#include <stdio.h>
struct bpf_map SEC("maps") __augmented_syscalls__ = {
.type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
.key_size = sizeof(int),
.value_size = sizeof(u32),
.max_entries = __NR_CPUS__,
};
struct syscall_enter_openat_args {
unsigned long long common_tp_fields;
long syscall_nr;
long dfd;
char *filename_ptr;
long flags;
long mode;
};
struct augmented_enter_openat_args {
struct syscall_enter_openat_args args;
char filename[64];
};
int syscall_enter(openat)(struct syscall_enter_openat_args *args)
{
struct augmented_enter_openat_args augmented_args;
probe_read(&augmented_args.args, sizeof(augmented_args.args), args);
probe_read_str(&augmented_args.filename, sizeof(augmented_args.filename), args->filename_ptr);
perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU,
&augmented_args, sizeof(augmented_args));
return 1;
}
license(GPL);

View File

@ -0,0 +1,9 @@
#include <stdio.h>
int syscall_enter(openat)(void *args)
{
puts("Hello, world\n");
return 0;
}
license(GPL);

View File

@ -0,0 +1,33 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Hook into 'openat' syscall entry tracepoint
*
* Test it with:
*
* perf trace -e tools/perf/examples/bpf/sys_enter_openat.c cat /etc/passwd > /dev/null
*
* It'll catch some openat syscalls related to the dynamic linked and
* the last one should be the one for '/etc/passwd'.
*
* The syscall_enter_openat_args can be used to get the syscall fields
* and use them for filtering calls, i.e. use in expressions for
* the return value.
*/
#include <bpf.h>
struct syscall_enter_openat_args {
unsigned long long unused;
long syscall_nr;
long dfd;
char *filename_ptr;
long flags;
long mode;
};
int syscall_enter(openat)(struct syscall_enter_openat_args *args)
{
return 1;
}
license(GPL);

View File

@ -4,13 +4,33 @@
#include <uapi/linux/bpf.h>
/*
* A helper structure used by eBPF C program to describe map attributes to
* elf_bpf loader, taken from tools/testing/selftests/bpf/bpf_helpers.h:
*/
struct bpf_map {
unsigned int type;
unsigned int key_size;
unsigned int value_size;
unsigned int max_entries;
unsigned int map_flags;
unsigned int inner_map_idx;
unsigned int numa_node;
};
#define SEC(NAME) __attribute__((section(NAME), used))
#define probe(function, vars) \
SEC(#function "=" #function " " #vars) function
#define syscall_enter(name) \
SEC("syscalls:sys_enter_" #name) syscall_enter_ ## name
#define license(name) \
char _license[] SEC("license") = #name; \
int _version SEC("version") = LINUX_VERSION_CODE;
static int (*probe_read)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read;
static int (*probe_read_str)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read_str;
#endif /* _PERF_BPF_H */

View File

@ -0,0 +1,19 @@
// SPDX-License-Identifier: GPL-2.0
#include <bpf.h>
struct bpf_map SEC("maps") __bpf_stdout__ = {
.type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
.key_size = sizeof(int),
.value_size = sizeof(u32),
.max_entries = __NR_CPUS__,
};
static int (*perf_event_output)(void *, struct bpf_map *, int, void *, unsigned long) =
(void *)BPF_FUNC_perf_event_output;
#define puts(from) \
({ const int __len = sizeof(from); \
char __from[__len] = from; \
perf_event_output(args, &__bpf_stdout__, BPF_F_CURRENT_CPU, \
&__from, __len & (sizeof(from) - 1)); })

View File

@ -0,0 +1,32 @@
[
{
"ArchStdEvent": "L1D_CACHE_RD",
},
{
"ArchStdEvent": "L1D_CACHE_WR",
},
{
"ArchStdEvent": "L1D_CACHE_REFILL_RD",
},
{
"ArchStdEvent": "L1D_CACHE_REFILL_WR",
},
{
"ArchStdEvent": "L1D_TLB_REFILL_RD",
},
{
"ArchStdEvent": "L1D_TLB_REFILL_WR",
},
{
"ArchStdEvent": "L1D_TLB_RD",
},
{
"ArchStdEvent": "L1D_TLB_WR",
},
{
"ArchStdEvent": "BUS_ACCESS_RD",
},
{
"ArchStdEvent": "BUS_ACCESS_WR",
}
]

View File

@ -16,3 +16,4 @@
0x00000000420f5160,v1,cavium/thunderx2,core
0x00000000430f0af0,v1,cavium/thunderx2,core
0x00000000480fd010,v1,hisilicon/hip08,core
0x00000000500f0000,v1,ampere/emag,core

Internal Server Error - Gitea: Git with a cup of tea

Internal Server Error

Gitea Version: 1.22.0