Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: Apache-2.0

Check warning on line 1 in .clang-format

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

Copyright missing

.clang-format:1 File has no SPDX-FileCopyrightText header, consider adding one.
#
# Note: The list of ForEachMacros can be obtained using:
#
Expand Down Expand Up @@ -42,6 +42,7 @@
- 'FOR_EACH_FIXED_ARG_NONEMPTY_TERM'
- 'RB_FOR_EACH'
- 'RB_FOR_EACH_CONTAINER'
- 'SYS_PORT_TRACK_FOR_EACH'
- 'SYS_DLIST_FOR_EACH_CONTAINER'
- 'SYS_DLIST_FOR_EACH_CONTAINER_SAFE'
- 'SYS_DLIST_FOR_EACH_NODE'
Expand Down
14 changes: 14 additions & 0 deletions doc/releases/release-notes-4.3.rst
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to 4.4

Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,20 @@ New APIs and options

* :c:macro:`__deprecated_version`

* Tracing

* :c:macro:`SYS_PORT_TRACK_FOR_EACH`
* :c:macro:`SYS_PORT_TRACK_K_TIMER_NEXT`
* :c:macro:`SYS_PORT_TRACK_K_MEM_SLAB_NEXT`
* :c:macro:`SYS_PORT_TRACK_K_SEM_NEXT`
* :c:macro:`SYS_PORT_TRACK_K_MUTEX_NEXT`
* :c:macro:`SYS_PORT_TRACK_K_STACK_NEXT`
* :c:macro:`SYS_PORT_TRACK_K_MSGQ_NEXT`
* :c:macro:`SYS_PORT_TRACK_K_MBOX_NEXT`
* :c:macro:`SYS_PORT_TRACK_K_PIPE_NEXT`
* :c:macro:`SYS_PORT_TRACK_K_QUEUE_NEXT`
* :c:macro:`SYS_PORT_TRACK_K_EVENT_NEXT`

* USB

* Video
Expand Down
96 changes: 96 additions & 0 deletions include/zephyr/tracing/tracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,105 @@
* @brief Gets node's next element in a object tracking list.
*
* @param list Node to get next element from.
* @return The next item under @p list.
*/
#define SYS_PORT_TRACK_NEXT(list)((list)->_obj_track_next)

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see macros being added, but I do not see them being used, can you please elaborate on the usage of thos macros and why we need them?

Copy link
Contributor Author

@rruuaanng rruuaanng Oct 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A large number of global variables with names like _track_list_k_xxx are exported to tracking.h. It seems that in Zephyr they're only used in tracing_tracking.c. If this kind of export is really necessary, I think we should add a wrapper macro to hide the implementation details of these variables.
(and provide a convenient way to operate on them.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the point being missed here - I don't think that _track_list_k_xxx are necessarily expected to be accessed from inside Zephyr. As I mentioned in my previous comment, external tools will be looking for these symbols, and macros won't be helpful to them, anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if you really need to access them internally, directly referencing the symbols doesn't seem like a sensible approach (although the purpose of accessing the symbols is merely to iterate over them).
If we have these macros, we can handle all the objects in the _track_list_ more effectively.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the discussion above it really feels like these macros should not be added and would probably be more confusing than anything? It feels like you should maybe consider closing this PR?

* @brief Gets node's next element in a object tracking list.
*
* Example:
* SYS_PORT_TRACK_FOREACH(k_mutex, m) {
* ...
* }
*
* @param object Type of tracking object to iterate over.
* @param var Temporary variable used during iteration.
*/
#define SYS_PORT_TRACK_FOR_EACH(object, var) \
for (struct object *var = _track_list_##object \
; var != NULL; var++)

Check warning on line 91 in include/zephyr/tracing/tracking.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

include/zephyr/tracing/tracking.h:91 please, no spaces at the start of a line

Check failure on line 91 in include/zephyr/tracing/tracking.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

TRAILING_WHITESPACE

include/zephyr/tracing/tracking.h:91 trailing whitespace
/**
* @brief Gets node's next element in a k_timer tracking list.
*
* @return The next item under list @ref _track_list_k_timer
*/
#define SYS_PORT_TRACK_K_TIMER_NEXT() \
SYS_PORT_TRACK_NEXT(_track_list_k_timer)

/**
* @brief Gets node's next element in a k_mem_slab tracking list.
*
* @return The next item under list @ref _track_list_k_mem_slab
*/
#define SYS_PORT_TRACK_K_MEM_SLAB_NEXT() \
SYS_PORT_TRACK_NEXT(_track_list_k_mem_slab)

/**
* @brief Gets node's next element in a k_sem tracking list.
*
* @return The next item under list @ref _track_list_k_sem
*/
#define SYS_PORT_TRACK_K_SEM_NEXT() \
SYS_PORT_TRACK_NEXT(_track_list_k_sem)

/**
* @brief Gets node's next element in a k_mutex tracking list.
*
* @return The next item under list @ref _track_list_k_mutex
*/
#define SYS_PORT_TRACK_K_MUTEX_NEXT() \
SYS_PORT_TRACK_NEXT(_track_list_k_mutex)

/**
* @brief Gets node's next element in a k_stack tracking list.
*
* @return The next item under list @ref _track_list_k_stack
*/
#define SYS_PORT_TRACK_K_STACK_NEXT() \
SYS_PORT_TRACK_NEXT(_track_list_k_stack)

/**
* @brief Gets node's next element in a k_msgq tracking list.
*
* @return The next item under list @ref _track_list_k_msgq
*/
#define SYS_PORT_TRACK_K_MSGQ_NEXT() \
SYS_PORT_TRACK_NEXT(_track_list_k_msgq)

/**
* @brief Gets node's next element in a k_mbox tracking list.
*
* @return The next item under list @ref _track_list_k_mbox
*/
#define SYS_PORT_TRACK_K_MBOX_NEXT() \
SYS_PORT_TRACK_NEXT(_track_list_k_mbox)

/**
* @brief Gets node's next element in a k_pipe tracking list.
*
* @return The next item under list @ref _track_list_k_pipe
*/
#define SYS_PORT_TRACK_K_PIPE_NEXT() \
SYS_PORT_TRACK_NEXT(_track_list_k_pipe)

/**
* @brief Gets node's next element in a k_queue tracking list.
*
* @return The next item under list @ref _track_list_k_queue
*/
#define SYS_PORT_TRACK_K_QUEUE_NEXT() \
SYS_PORT_TRACK_NEXT(_track_list_k_queue)

/**
* @brief Gets node's next element in a k_event tracking list.
*
* @return The next item under list @ref _track_list_k_event
*/
#define SYS_PORT_TRACK_K_EVENT_NEXT() \
SYS_PORT_TRACK_NEXT(_track_list_k_event)

/** @cond INTERNAL_HIDDEN */

#define sys_port_track_k_thread_start(thread)
Expand Down
Loading