X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=include%2Finstrumentation%2Fevents%2Fmodule.h;fp=include%2Finstrumentation%2Fevents%2Fmodule.h;h=5831650b6f987b2a10b58db0bcef52b36b22f5bd;hb=4f47ccf08dfac3d5db7553eb8b40bdab19764727;hp=0000000000000000000000000000000000000000;hpb=2bc89292c6ac6030a7498a798671cca921ae61df;p=lttng-modules.git diff --git a/include/instrumentation/events/module.h b/include/instrumentation/events/module.h new file mode 100644 index 00000000..5831650b --- /dev/null +++ b/include/instrumentation/events/module.h @@ -0,0 +1,105 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Because linux/module.h has tracepoints in the header, and ftrace.h + * eventually includes this file, define_trace.h includes linux/module.h + * But we do not want the module.h to override the TRACE_SYSTEM macro + * variable that define_trace.h is processing, so we only set it + * when module events are being processed, which would happen when + * CREATE_TRACE_POINTS is defined. + */ +#ifdef CREATE_TRACE_POINTS +#undef TRACE_SYSTEM +#define TRACE_SYSTEM module +#endif + +#if !defined(LTTNG_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ) +#define LTTNG_TRACE_MODULE_H + +#include +#include + +#ifdef CONFIG_MODULES + +#ifndef _TRACE_MODULE_DEF +#define _TRACE_MODULE_DEF +struct module; + +#endif + +LTTNG_TRACEPOINT_EVENT(module_load, + + TP_PROTO(struct module *mod), + + TP_ARGS(mod), + + TP_FIELDS( + ctf_integer(unsigned int, taints, mod->taints) + ctf_string(name, mod->name) + ) +) + +LTTNG_TRACEPOINT_EVENT(module_free, + + TP_PROTO(struct module *mod), + + TP_ARGS(mod), + + TP_FIELDS( + ctf_string(name, mod->name) + ) +) + +#ifdef CONFIG_MODULE_UNLOAD +/* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */ + +LTTNG_TRACEPOINT_EVENT_CLASS(module_refcnt, + + TP_PROTO(struct module *mod, unsigned long ip), + + TP_ARGS(mod, ip), + + TP_FIELDS( + ctf_integer_hex(unsigned long, ip, ip) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)) + ctf_integer(int, refcnt, atomic_read(&mod->refcnt)) +#else + ctf_integer(int, refcnt, __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs)) +#endif + ctf_string(name, mod->name) + ) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE(module_refcnt, module_get, + + TP_PROTO(struct module *mod, unsigned long ip), + + TP_ARGS(mod, ip) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE(module_refcnt, module_put, + + TP_PROTO(struct module *mod, unsigned long ip), + + TP_ARGS(mod, ip) +) +#endif /* CONFIG_MODULE_UNLOAD */ + +LTTNG_TRACEPOINT_EVENT(module_request, + + TP_PROTO(char *name, bool wait, unsigned long ip), + + TP_ARGS(name, wait, ip), + + TP_FIELDS( + ctf_integer_hex(unsigned long, ip, ip) + ctf_integer(bool, wait, wait) + ctf_string(name, name) + ) +) + +#endif /* CONFIG_MODULES */ + +#endif /* LTTNG_TRACE_MODULE_H */ + +/* This part must be outside protection */ +#include