Skip to content

Commit 8c03410

Browse files
alexpaschoalettocfriedt
authored andcommitted
tracing: msgq: adding dedicated tracing for k_msgq_put_front
This commit adds the tracing macros and functions related specifically to the k_msgq_put_front API. Signed-off-by: Alexander Paschoaletto <[email protected]>
1 parent 34efba2 commit 8c03410

File tree

6 files changed

+66
-4
lines changed

6 files changed

+66
-4
lines changed

include/zephyr/tracing/tracing.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,28 @@
14191419
*/
14201420
#define sys_port_trace_k_msgq_put_exit(msgq, timeout, ret)
14211421

1422+
/**
1423+
* @brief Trace Message Queue put at front attempt entry
1424+
* @param msgq Message Queue object
1425+
* @param timeout Timeout period
1426+
*/
1427+
#define sys_port_trace_k_msgq_put_front_enter(msgq, timeout)
1428+
1429+
/**
1430+
* @brief Trace Message Queue put at front attempt blocking
1431+
* @param msgq Message Queue object
1432+
* @param timeout Timeout period
1433+
*/
1434+
#define sys_port_trace_k_msgq_put_front_blocking(msgq, timeout)
1435+
1436+
/**
1437+
* @brief Trace Message Queue put at front attempt outcome
1438+
* @param msgq Message Queue object
1439+
* @param timeout Timeout period
1440+
* @param ret Return value
1441+
*/
1442+
#define sys_port_trace_k_msgq_put_front_exit(msgq, timeout, ret)
1443+
14221444
/**
14231445
* @brief Trace Message Queue get attempt entry
14241446
* @param msgq Message Queue object

kernel/msg_q.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ static inline int put_msg_in_queue(struct k_msgq *msgq, const void *data,
136136

137137
key = k_spin_lock(&msgq->lock);
138138

139-
SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_msgq, put, msgq, timeout);
139+
if (put_at_back) {
140+
SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_msgq, put, msgq, timeout);
141+
} else {
142+
SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_msgq, put_front, msgq, timeout);
143+
}
140144

141145
if (msgq->used_msgs < msgq->max_msgs) {
142146
/* message queue isn't full */
@@ -183,17 +187,31 @@ static inline int put_msg_in_queue(struct k_msgq *msgq, const void *data,
183187
/* don't wait for message space to become available */
184188
result = -ENOMSG;
185189
} else {
186-
SYS_PORT_TRACING_OBJ_FUNC_BLOCKING(k_msgq, put, msgq, timeout);
190+
if (put_at_back) {
191+
SYS_PORT_TRACING_OBJ_FUNC_BLOCKING(k_msgq, put, msgq, timeout);
192+
} else {
193+
SYS_PORT_TRACING_OBJ_FUNC_BLOCKING(k_msgq, put_front, msgq, timeout);
194+
}
187195

188196
/* wait for put message success, failure, or timeout */
189197
_current->base.swap_data = (void *) data;
190198

191199
result = z_pend_curr(&msgq->lock, key, &msgq->wait_q, timeout);
192-
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_msgq, put, msgq, timeout, result);
200+
201+
if (put_at_back) {
202+
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_msgq, put, msgq, timeout, result);
203+
} else {
204+
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_msgq, put_front, msgq, timeout, result);
205+
}
206+
193207
return result;
194208
}
195209

196-
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_msgq, put, msgq, timeout, result);
210+
if (put_at_back) {
211+
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_msgq, put, msgq, timeout, result);
212+
} else {
213+
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_msgq, put_front, msgq, timeout, result);
214+
}
197215

198216
if (resched) {
199217
z_reschedule(&msgq->lock, key);

subsys/tracing/ctf/tracing_ctf.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ extern "C" {
263263
#define sys_port_trace_k_msgq_put_enter(msgq, timeout)
264264
#define sys_port_trace_k_msgq_put_blocking(msgq, timeout)
265265
#define sys_port_trace_k_msgq_put_exit(msgq, timeout, ret)
266+
#define sys_port_trace_k_msgq_put_front_enter(msgq, timeout)
267+
#define sys_port_trace_k_msgq_put_front_blocking(msgq, timeout)
268+
#define sys_port_trace_k_msgq_put_front_exit(msgq, timeout, ret)
266269
#define sys_port_trace_k_msgq_get_enter(msgq, timeout)
267270
#define sys_port_trace_k_msgq_get_blocking(msgq, timeout)
268271
#define sys_port_trace_k_msgq_get_exit(msgq, timeout, ret)

subsys/tracing/sysview/tracing_sysview.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,9 @@ void sys_trace_thread_info(struct k_thread *thread);
513513
#define sys_port_trace_k_msgq_put_enter(msgq, timeout)
514514
#define sys_port_trace_k_msgq_put_blocking(msgq, timeout)
515515
#define sys_port_trace_k_msgq_put_exit(msgq, timeout, ret)
516+
#define sys_port_trace_k_msgq_put_front_enter(msgq, timeout)
517+
#define sys_port_trace_k_msgq_put_front_blocking(msgq, timeout)
518+
#define sys_port_trace_k_msgq_put_front_exit(msgq, timeout, ret)
516519
#define sys_port_trace_k_msgq_get_enter(msgq, timeout)
517520
#define sys_port_trace_k_msgq_get_blocking(msgq, timeout)
518521
#define sys_port_trace_k_msgq_get_exit(msgq, timeout, ret)

subsys/tracing/test/tracing_test.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,14 @@
312312
sys_trace_k_msgq_put_blocking(msgq, data, timeout)
313313
#define sys_port_trace_k_msgq_put_exit(msgq, timeout, ret) \
314314
sys_trace_k_msgq_put_exit(msgq, data, timeout, ret)
315+
316+
#define sys_port_trace_k_msgq_put_front_enter(msgq, timeout) \
317+
sys_trace_k_msgq_put_front_enter(msgq, data, timeout)
318+
#define sys_port_trace_k_msgq_put_front_blocking(msgq, timeout) \
319+
sys_trace_k_msgq_put_front_blocking(msgq, data, timeout)
320+
#define sys_port_trace_k_msgq_put_front_exit(msgq, timeout, ret) \
321+
sys_trace_k_msgq_put_front_exit(msgq, data, timeout, ret)
322+
315323
#define sys_port_trace_k_msgq_get_enter(msgq, timeout) \
316324
sys_trace_k_msgq_get_enter(msgq, data, timeout)
317325
#define sys_port_trace_k_msgq_get_blocking(msgq, timeout) \
@@ -684,6 +692,11 @@ void sys_trace_k_msgq_cleanup_exit(struct k_msgq *msgq, int ret);
684692
void sys_trace_k_msgq_put_enter(struct k_msgq *msgq, const void *data, k_timeout_t timeout);
685693
void sys_trace_k_msgq_put_blocking(struct k_msgq *msgq, const void *data, k_timeout_t timeout);
686694
void sys_trace_k_msgq_put_exit(struct k_msgq *msgq, const void *data, k_timeout_t timeout, int ret);
695+
void sys_trace_k_msgq_put_front_enter(struct k_msgq *msgq, const void *data, k_timeout_t timeout);
696+
void sys_trace_k_msgq_put_front_blocking(struct k_msgq *msgq, const void *data,
697+
k_timeout_t timeout);
698+
void sys_trace_k_msgq_put_front_exit(struct k_msgq *msgq, const void *data, k_timeout_t timeout,
699+
int ret);
687700
void sys_trace_k_msgq_get_enter(struct k_msgq *msgq, const void *data, k_timeout_t timeout);
688701
void sys_trace_k_msgq_get_blocking(struct k_msgq *msgq, const void *data, k_timeout_t timeout);
689702
void sys_trace_k_msgq_get_exit(struct k_msgq *msgq, const void *data, k_timeout_t timeout, int ret);

subsys/tracing/user/tracing_user.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ void sys_trace_gpio_fire_callback_user(const struct device *port, struct gpio_ca
304304
#define sys_port_trace_k_msgq_put_enter(msgq, timeout)
305305
#define sys_port_trace_k_msgq_put_blocking(msgq, timeout)
306306
#define sys_port_trace_k_msgq_put_exit(msgq, timeout, ret)
307+
#define sys_port_trace_k_msgq_put_front_enter(msgq, timeout)
308+
#define sys_port_trace_k_msgq_put_front_blocking(msgq, timeout)
309+
#define sys_port_trace_k_msgq_put_front_exit(msgq, timeout, ret)
307310
#define sys_port_trace_k_msgq_get_enter(msgq, timeout)
308311
#define sys_port_trace_k_msgq_get_blocking(msgq, timeout)
309312
#define sys_port_trace_k_msgq_get_exit(msgq, timeout, ret)

0 commit comments

Comments
 (0)