Commit Graph

146 Commits

Author SHA1 Message Date
Daniel DeGrasse 66577a9d23 tracing: add named event trace
Add support for a "named event" trace. This trace is intentionally not
used by the system. The purpose of this trace is to allow driver or
application developers to quickly add tracing for events for debug
purposes, and to provide an example of how tracing subsystems can be
extended with additional trace identifiers.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-10-17 10:46:52 -04:00
Jukka Rissanen 8134673309 tracing: segger-sysview: Fix compilation issues with networking
The networking tracing function definitions were missing for sysview.

Fixes #79805

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-10-17 09:43:33 +02:00
Bruce Rosier 24414e3c39 subsystem: tracing: test: fix k_pipe_put_* functions
k_pipe_put_* functions should take const void* data
    instead of void* data. This can lead to warnings at the
    the -Werror=discarded-qualifiers compiler flag, because the
    the input will be const void* and the parameter will be void*.
    Fix it by replacing void* data with “const void* data”.

Signed-off-by: Bruce Rosier <brucerosier9@gmail.com>
2024-10-16 16:36:11 +01:00
Chris Friedt 881dc1fa7a net: sockets: move poll implementation to zvfs
Move the implementation of zsock_poll to zvfs_poll. This allows
other types of file descriptors to also make use of poll()
functionality even when the network subsystem is not enabled.

Additionally, it partially removes a dependency cycle between
posix and networking by moving functionality into a mutual
dependency.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-10-14 13:01:51 +02:00
Maureen Helm d022d315d2 tracing: Fix sysview for soc families not subdivided into series
Fixes the systemview tracing backend for soc families, such as max32,
that don't subdivide into soc series and therefore don't define
CONFIG_SOC_SERIES. Use CONFIG_SOC_FAMILY instead in the system
description since it should always be defined.

Signed-off-by: Maureen Helm <maureen.helm@analog.com>
2024-10-06 20:51:27 +01:00
Yong Cong Sin 52a202309b zephyr: bulk update to DT_NODE_HAS_STATUS_OKAY
Change instances of:

DT_NODE_HAS_STATUS(<node_id>, okay)

to

DT_NODE_HAS_STATUS_OKAY(<node_id>)

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-10-03 17:06:52 +01:00
Pisit Sawangvonganan 8f197c955d style: subsys: comply with MISRA C:2012 Rule 15.6
Add missing braces to comply with MISRA C:2012 Rule 15.6 and
also following Zephyr's style guideline.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-08-20 10:33:51 +02:00
Jukka Rissanen 0b985acbd7 net: tracing: Add TX time tracing
TX time tracing tells how long it took from network packet
creation to when the stack got rid of it.
So the network stack allocates net packet, this is the
start time. The end time is when the packet is fully processed (sent)
by the network device driver.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-08-19 21:50:21 -04:00
Jukka Rissanen a679dd9578 net: tracing: Add RX time tracing
RX time tracing tells how long it took from network packet
creation to when the stack got rid of it.
So the network device driver allocates net packet, this is the
start time. The end time is when the packet is fully processed.
Currently the limitation is that the RX time duration is used
for network packets that are tied to an open socket.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-08-19 21:50:21 -04:00
Jukka Rissanen 4911a4f8de net: tracing: Add net_send_data function tracing
Trace when a network packet is sent.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-08-19 21:50:21 -04:00
Jukka Rissanen ea2ff40558 net: tracing: Add net_recv_data function tracing
Trace when a network packet has been received.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-08-19 21:50:21 -04:00
Jukka Rissanen 491e12be2b net: tracing: Have a separate Kconfig option for socket API tracing
This is done for preparation to adding more network code tracing
to the system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-08-19 21:50:21 -04:00
Alberto Escolar Piedras 1df86af309 Revert "net: sockets: move poll implementation to zvfs"
This reverts commit 93973e2ead.

PR #73978 introduced a regression.
Unfortunately this PR cannot be reverted without reverting also
Let's revert both PRs to stabilize main again towards the 3.7 release.

For more details on the issue see
https://github.com/zephyrproject-rtos/zephyr/issues/75205

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-07-03 15:03:05 -04:00
Chris Friedt 93973e2ead net: sockets: move poll implementation to zvfs
Move the implementation of zsock_poll to zvfs_poll. This allows
other types of file descriptors to also make use of poll()
functionality even when the network subsystem is not enabled.

Additionally, it partially removes a dependency cycle between
posix and networking by moving functionality into a mutual
dependency.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-27 09:01:23 -04:00
Jordan Yates 07870934e3 everywhere: replace double words
Treewide search and replace on a range of double word combinations:
    * `the the`
    * `to to`
    * `if if`
    * `that that`
    * `on on`
    * `is is`
    * `from from`

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-22 05:40:22 -04:00
Yong Cong Sin 15dc87d172 tracing: trace sys_init calls
Created tracing APIs to trace the enter and (exit + result) of
SYS_INIT and DEVICE_DT_DEFINE (and friends).

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-18 14:39:05 -04:00
frei tycho ac8620c791 tracing: change controlling expressions in while to Boolean
Use `do { ... } while (false)` instead of `do { ... } while (0)`.

Signed-off-by: frei tycho <tfrei@baumer.com>
2024-06-11 20:02:40 +03:00
Jukka Rissanen 7bb4013d8e net: tracing: Add socket tracing support
If network socket tracing is enabled, then the system will track
various socket API calls for usage.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-10 15:03:20 -05:00
Fin Maaß 54cb89b8d7 tracing: fix k_realloc trace functions
fix wrong amount of arguments for
k_realloc trace functions.

fixes #73996

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-06-10 14:54:49 -05:00
Anas Nashif 584a99f6ab tracing: add missing calls for k_wakeup/k_thread_user_mode_enter
Add missing hooks for k_wakeup/k_thread_user_mode_enter to CTF backend.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-06-05 17:38:22 -05:00
Fin Maaß 8c37f14b98 tracing: add k_realloc trace
For `k_realloc` add tracing feature.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-28 17:55:12 +02:00
Galen Krulce 1cfe90d825 tracing: full reset during init
I am using the tracing module using the RAM backend on a system with
limited RAM & a buffer that can only store 300ms of tracing data. Current
tracing module starts recording during boot-up & we run out of memory prior
to executing code we actually want to trace.

By reseting buffer metadata here, I can call init() at an arbitrary point
of program execution & the tracing module will reset & start tracing.

I tested on E2E on an ARM M-class MCU by calling init & then reading
buffered tracing data via GDB

Signed-off-by: Galen Krulce <gkrulce@meta.com>
2024-04-24 17:08:24 -04:00
Marcin Szkudlinski 3fde2c50c6 tracing: add intel ADSP memory window backend
This commits adds a tracing backend based on
Intel ADSP debug memory window

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2024-03-25 09:33:41 +01:00
Daniel Leung 58ef5fb78e tracing: segger-sysview: add missing thread abort enter/exit
Tracing with sysview is missing both
sys_port_trace_k_thread_abort_enter()/_exit() which exist on
other tracing backends. So add them.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-03-19 13:37:41 -05:00
Joakim Andersson 43bce7e125 tracing: sysview: Remove redundant depends on
Remove redundant depends on statements for SEGGER_SYSTEMVIEW.
This is already inside an if SEGGER_SYSTEMVIEW so depends on are
already added.

Signed-off-by: Joakim Andersson <joakim.andersson@heimdallpower.com>
2024-03-11 09:09:07 -05:00
Wojciech Slenska d079701885 tracing: segger-sysview: fix compilation error
SEGGER_SYSVIEW_RecordU32 function takes only two parameters,
SEGGER_SYSVIEW_RecordU32x2 should be used instead.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2024-03-05 07:49:05 -05:00
Flavio Ceolin d2be3c05dc tracing: sysview: Fix API name
s/k_thread_usermode_enter/k_thread_user_mode_enter/

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-01-15 13:53:44 -05:00
Flavio Ceolin b5ca7a06b4 pm: device_runtime: Add delay to async put
Add a delay parameter to asynchronous device runtim put. This allows
to delay the put operation what is useful to avoid multiple states
transitions.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-12-12 10:57:34 +01:00
Daniel Leung 0a50ff366e kernel: rename z_current_get() to k_sched_current_thread_query()
The original idea of z_current_get() was to be the counterpart
of k_current_get() when thread local variable for current has
not been initialized if TLS is enabled, otherwise they are
the same function. Now since z_current_get() is being used
outside of core kernel, rename it under kernel namespace so
other subsystem can conceptually use them too.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-09-28 16:15:46 +02:00
Anas Nashif a04a1d8991 tracing: remove references to deprecated k_pipe_block_put
k_pipe_block_put was deprecated some time ago.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-09-18 19:20:02 -04:00
Aron Lander 89c866ab68 modules: Add DFM and move Tracerecorder into percepio module
This commit adds the DFM (DevAlert target side code) module and
moves the TraceRecorder module into the percepio module, which
results in the TraceRecorder module definition being removed
from the west manufest and module definition within zephyr.

Signed-off-by: Aron Lander <aron.lander@percepio.com>
2023-09-12 10:19:37 -04:00
Florian Grandel d218b20643 tracing: make API tracing configurable
So far only object tracing/tracking could be individually disabled (e.g.
CONFIG_TRACING_SEMAPHORE=n). Now tracing of any API may be disabled
(e.g. CONFIG_TRACING_PM=n).

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-08 06:10:14 -04:00
Carles Cufi 8c748fd005 kernel: Modify the signature of k_mem_slab_free()
Modify the signature of the k_mem_slab_free() function with a new one,
replacing the old void **mem with void *mem as a parameter.

The following function:
void k_mem_slab_free(struct k_mem_slab *slab, void **mem);

has the wrong signature. mem is only used as a regular pointer, so there
is no need to use a double-pointer. The correct signature should be:
void k_mem_slab_free(struct k_mem_slab *slab, void *mem);

The issue with the current signature, although functional, is that it is
extremely confusing. I myself, a veteran Zephyr developer, was confused
by this parameter when looking at it recently.

All in-tree uses of the function have been adapted.

Fixes #61888.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-09-03 18:20:59 -04:00
Yong Cong Sin 3337c15707 tracing_user: let user implementation to do everything
Let's just let the user implementation to its things, like
checking, locking and stuff.
The tracing_user.c now just acts as a glue.

Moved previous implementation to its sample, and cleaned up
headers.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-08-17 15:13:17 +02:00
Florian Grandel 01ba923bb2 tracing: segger-sysview: fix display formatting
Fixes several minor display errors in the Segger SystemView output:
* Off-by-one error in some trace ids.
* Add missing syscall trace id.
* Displays easier to read syscall function names.
* Fixes syntax error in k_timer_start output.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-08-06 07:44:06 -04:00
Alberto Escolar Piedras 9be7b59b4a ctf tracing: native/host backend: Refactor to support embedded C libraries
Split this tracing backend in a top and bottom to enable
building it with embedded libCs with the native simulator.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-13 05:47:08 -04:00
Nathan Olff 685476d7e0 tracing: sysview: implement SEGGER_SYSVIEW_APP_NAME
Implement APP_NAME define in Kconfig for Segger SystemView module.
Use APP_NAME in Systemview initialization function

Signed-off-by: Nathan Olff <nathan@kickmaker.net>
2023-06-08 06:51:03 -04:00
Nathan Olff 833a228db4 tracing: sysview: implement RTT channel selection through KConfig
Implement Kconfig value for selecting the RTT channel to be used
by Segger SystemView

Signed-off-by: Nathan Olff <nathan@kickmaker.net>
2023-06-08 06:51:03 -04:00
Gerard Marull-Paretas dacb3dbfeb iterable_sections: move to specific header
Until now iterable sections APIs have been part of the toolchain
(common) headers. They are not strictly related to a toolchain, they
just rely on linker providing support for sections. Most files relied on
indirect includes to access the API, now, it is included as needed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-22 10:42:30 +02:00
Gerard Marull-Paretas a5fd0d184a init: remove the need for a dummy device pointer in SYS_INIT functions
The init infrastructure, found in `init.h`, is currently used by:

- `SYS_INIT`: to call functions before `main`
- `DEVICE_*`: to initialize devices

They are all sorted according to an initialization level + a priority.
`SYS_INIT` calls are really orthogonal to devices, however, the required
function signature requires a `const struct device *dev` as a first
argument. The only reason for that is because the same init machinery is
used by devices, so we have something like:

```c
struct init_entry {
	int (*init)(const struct device *dev);
	/* only set by DEVICE_*, otherwise NULL */
	const struct device *dev;
}
```

As a result, we end up with such weird/ugly pattern:

```c
static int my_init(const struct device *dev)
{
	/* always NULL! add ARG_UNUSED to avoid compiler warning */
	ARG_UNUSED(dev);
	...
}
```

This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:

```c
static int my_init(void)
{
	...
}
```

This is achieved using a union:

```c
union init_function {
	/* for SYS_INIT, used when init_entry.dev == NULL */
	int (*sys)(void);
	/* for DEVICE*, used when init_entry.dev != NULL */
	int (*dev)(const struct device *dev);
};

struct init_entry {
	/* stores init function (either for SYS_INIT or DEVICE*)
	union init_function init_fn;
	/* stores device pointer for DEVICE*, NULL for SYS_INIT. Allows
	 * to know which union entry to call.
	 */
	const struct device *dev;
}
```

This solution **does not increase ROM usage**, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.

**NOTE**: This is a breaking change! All `SYS_INIT` functions will need
to be converted to the new signature. See the script offered in the
following commit.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

init: convert SYS_INIT functions to the new signature

Conversion scripted using scripts/utils/migrate_sys_init.py.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

manifest: update projects for SYS_INIT changes

Update modules with updated SYS_INIT calls:

- hal_ti
- lvgl
- sof
- TraceRecorderSource

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: devicetree: devices: adjust test

Adjust test according to the recently introduced SYS_INIT
infrastructure.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: kernel: threads: adjust SYS_INIT call

Adjust to the new signature: int (*init_fn)(void);

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 14:28:07 +00:00
Kumar Gala 831bd2f841 armclang: fix compiler warnings with isprint()
We get compile warnings of the form:

drivers/console/uart_console.c:508:8: error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint returns an int, change check to an explicit test against
the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-03-17 09:30:01 +01:00
Peter Mitsis cbc3e5c999 tracing: Add event tracing to sysview
Adds event tracing to sysview. This will allow the event related
tracing symbols to be found when CONFIG_SEGGER_SYSTEMVIEW is
enabled.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-02-02 20:21:12 +09:00
Peter Mitsis bdb49f21ad tracing: Resolve undefined event symbols
Fixes various unresolved symbols when kernel event object tracking
is enabled via CONFIG_TRACING=y.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-02-02 20:21:12 +09:00
Tom Burdick 3d6f3a52cf tracing: Fix systemview tracing ids
Fixes the overlapping tracing id for thread name set and pm system suspend

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-01-16 10:05:01 +01:00
Flavio Ceolin a2a2c62abd tracing: none: Remove unnecessary headers
This file does not need any header, remove all of them.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-01-09 12:07:28 -05:00
Keith Packard ced5053e6c subsys/tracing: Use z_current_get in switch_{in,out}
The thread switching tracing hooks are called in the middle of swapping,
before z_thread_entry has a chance to set the z_tls_current value, so they
cannot use k_current_get. Switch them to z_current_get instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-10-26 12:00:04 +02:00
Kumar Gala c778eb2a56 smp: Move arrays to use CONFIG_MP_MAX_NUM_CPUS
Move to use CONFIG_MP_MAX_NUM_CPUS for array size declarations instead
of CONFIG_MP_NUM_CPUS.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2022-10-17 14:40:12 +09:00
Florian Grandel 0956647aaf pm: device_runtime.c: compile error
Enabling device power management together with tracing caused a compile
error.

Fixes: #50107

Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
2022-09-10 17:04:20 -04:00
Gerard Marull-Paretas 79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
Anas Nashif 838f581300 tracing: ctf: change timer values to us instead of ms
Be consistent with timeout values and use micro seconds.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-08-31 16:04:01 -04:00