diff --git a/include/trace/events/mq.h b/include/trace/events/mq.h new file mode 100644 index 000000000000..954cb343c915 --- /dev/null +++ b/include/trace/events/mq.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM mq + +#if !defined(_TRACE_MQ_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_MQ_H + +#include + +DECLARE_EVENT_CLASS(mq, + + TP_PROTO(struct msg_msg *msg, size_t mlen), + + TP_ARGS(msg, mlen), + + TP_STRUCT__entry( + __field(struct msg_msg *, msg) + __field(size_t, mlen) + ), + + TP_fast_assign( + __entry->msg = msg; + __entry->mlen = mlen; + ), + + TP_printk("msg=%p len=%zu", __entry->msg, __entry->mlen) +); + +DEFINE_EVENT(mq, load_msg, + + TP_PROTO(struct msg_msg *msg, size_t mlen), + + TP_ARGS(msg, mlen) +); + +DEFINE_EVENT(mq, store_msg, + + TP_PROTO(struct msg_msg *msg, size_t mlen), + + TP_ARGS(msg, mlen) +); + +#endif /* _TRACE_MQ_H */ + +/* This part must be outside protection */ +#include diff --git a/ipc/msgutil.c b/ipc/msgutil.c index 5b52d1dc7a8d..6a954b155f16 100644 --- a/ipc/msgutil.c +++ b/ipc/msgutil.c @@ -18,6 +18,9 @@ #include "util.h" +#define CREATE_TRACE_POINTS +#include + DEFINE_SPINLOCK(mq_lock); /* @@ -83,11 +86,12 @@ out_err: return NULL; } -struct msg_msg *load_msg(const void __user *src, size_t len) +struct msg_msg *load_msg(const void __user *src, size_t mlen) { struct msg_msg *msg; struct msg_msgseg *seg; int err = -EFAULT; + size_t len = mlen; size_t alen; msg = alloc_msg(len); @@ -110,6 +114,7 @@ struct msg_msg *load_msg(const void __user *src, size_t len) if (err) goto out_err; + trace_load_msg(msg, mlen); return msg; out_err: @@ -149,11 +154,13 @@ struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst) return ERR_PTR(-ENOSYS); } #endif -int store_msg(void __user *dest, struct msg_msg *msg, size_t len) +int store_msg(void __user *dest, struct msg_msg *msg, size_t mlen) { size_t alen; + size_t len = mlen; struct msg_msgseg *seg; + trace_store_msg(msg, mlen); alen = min(len, DATALEN_MSG); if (copy_to_user(dest, msg + 1, alen)) return -1;