18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#undef TRACE_SYSTEM
38c2ecf20Sopenharmony_ci#define TRACE_SYSTEM workqueue
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#if !defined(_TRACE_WORKQUEUE_H) || defined(TRACE_HEADER_MULTI_READ)
68c2ecf20Sopenharmony_ci#define _TRACE_WORKQUEUE_H
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include <linux/tracepoint.h>
98c2ecf20Sopenharmony_ci#include <linux/workqueue.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_cistruct pool_workqueue;
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/**
148c2ecf20Sopenharmony_ci * workqueue_queue_work - called when a work gets queued
158c2ecf20Sopenharmony_ci * @req_cpu:	the requested cpu
168c2ecf20Sopenharmony_ci * @pwq:	pointer to struct pool_workqueue
178c2ecf20Sopenharmony_ci * @work:	pointer to struct work_struct
188c2ecf20Sopenharmony_ci *
198c2ecf20Sopenharmony_ci * This event occurs when a work is queued immediately or once a
208c2ecf20Sopenharmony_ci * delayed work is actually queued on a workqueue (ie: once the delay
218c2ecf20Sopenharmony_ci * has been reached).
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ciTRACE_EVENT(workqueue_queue_work,
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci	TP_PROTO(unsigned int req_cpu, struct pool_workqueue *pwq,
268c2ecf20Sopenharmony_ci		 struct work_struct *work),
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci	TP_ARGS(req_cpu, pwq, work),
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci	TP_STRUCT__entry(
318c2ecf20Sopenharmony_ci		__field( void *,	work	)
328c2ecf20Sopenharmony_ci		__field( void *,	function)
338c2ecf20Sopenharmony_ci		__field( void *,	workqueue)
348c2ecf20Sopenharmony_ci		__field( unsigned int,	req_cpu	)
358c2ecf20Sopenharmony_ci		__field( unsigned int,	cpu	)
368c2ecf20Sopenharmony_ci	),
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci	TP_fast_assign(
398c2ecf20Sopenharmony_ci		__entry->work		= work;
408c2ecf20Sopenharmony_ci		__entry->function	= work->func;
418c2ecf20Sopenharmony_ci		__entry->workqueue	= pwq->wq;
428c2ecf20Sopenharmony_ci		__entry->req_cpu	= req_cpu;
438c2ecf20Sopenharmony_ci		__entry->cpu		= pwq->pool->cpu;
448c2ecf20Sopenharmony_ci	),
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci	TP_printk("work struct=%p function=%ps workqueue=%p req_cpu=%u cpu=%u",
478c2ecf20Sopenharmony_ci		  __entry->work, __entry->function, __entry->workqueue,
488c2ecf20Sopenharmony_ci		  __entry->req_cpu, __entry->cpu)
498c2ecf20Sopenharmony_ci);
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci/**
528c2ecf20Sopenharmony_ci * workqueue_activate_work - called when a work gets activated
538c2ecf20Sopenharmony_ci * @work:	pointer to struct work_struct
548c2ecf20Sopenharmony_ci *
558c2ecf20Sopenharmony_ci * This event occurs when a queued work is put on the active queue,
568c2ecf20Sopenharmony_ci * which happens immediately after queueing unless @max_active limit
578c2ecf20Sopenharmony_ci * is reached.
588c2ecf20Sopenharmony_ci */
598c2ecf20Sopenharmony_ciTRACE_EVENT(workqueue_activate_work,
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci	TP_PROTO(struct work_struct *work),
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	TP_ARGS(work),
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci	TP_STRUCT__entry(
668c2ecf20Sopenharmony_ci		__field( void *,	work	)
678c2ecf20Sopenharmony_ci	),
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci	TP_fast_assign(
708c2ecf20Sopenharmony_ci		__entry->work		= work;
718c2ecf20Sopenharmony_ci	),
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci	TP_printk("work struct %p", __entry->work)
748c2ecf20Sopenharmony_ci);
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci/**
778c2ecf20Sopenharmony_ci * workqueue_execute_start - called immediately before the workqueue callback
788c2ecf20Sopenharmony_ci * @work:	pointer to struct work_struct
798c2ecf20Sopenharmony_ci *
808c2ecf20Sopenharmony_ci * Allows to track workqueue execution.
818c2ecf20Sopenharmony_ci */
828c2ecf20Sopenharmony_ciTRACE_EVENT(workqueue_execute_start,
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci	TP_PROTO(struct work_struct *work),
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	TP_ARGS(work),
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci	TP_STRUCT__entry(
898c2ecf20Sopenharmony_ci		__field( void *,	work	)
908c2ecf20Sopenharmony_ci		__field( void *,	function)
918c2ecf20Sopenharmony_ci	),
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci	TP_fast_assign(
948c2ecf20Sopenharmony_ci		__entry->work		= work;
958c2ecf20Sopenharmony_ci		__entry->function	= work->func;
968c2ecf20Sopenharmony_ci	),
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci	TP_printk("work struct %p: function %ps", __entry->work, __entry->function)
998c2ecf20Sopenharmony_ci);
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci/**
1028c2ecf20Sopenharmony_ci * workqueue_execute_end - called immediately after the workqueue callback
1038c2ecf20Sopenharmony_ci * @work:	pointer to struct work_struct
1048c2ecf20Sopenharmony_ci * @function:   pointer to worker function
1058c2ecf20Sopenharmony_ci *
1068c2ecf20Sopenharmony_ci * Allows to track workqueue execution.
1078c2ecf20Sopenharmony_ci */
1088c2ecf20Sopenharmony_ciTRACE_EVENT(workqueue_execute_end,
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci	TP_PROTO(struct work_struct *work, work_func_t function),
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci	TP_ARGS(work, function),
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci	TP_STRUCT__entry(
1158c2ecf20Sopenharmony_ci		__field( void *,	work	)
1168c2ecf20Sopenharmony_ci		__field( void *,	function)
1178c2ecf20Sopenharmony_ci	),
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci	TP_fast_assign(
1208c2ecf20Sopenharmony_ci		__entry->work		= work;
1218c2ecf20Sopenharmony_ci		__entry->function	= function;
1228c2ecf20Sopenharmony_ci	),
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci	TP_printk("work struct %p: function %ps", __entry->work, __entry->function)
1258c2ecf20Sopenharmony_ci);
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci#endif /*  _TRACE_WORKQUEUE_H */
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci/* This part must be outside protection */
1308c2ecf20Sopenharmony_ci#include <trace/define_trace.h>
131