Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions doc/services/tracing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ all initialized mutexes, one can write::

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, but there are no trackers (or tracing) for zync :(

Isn't this downgrading Zephyr debug capabilities?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good catch. Yeah, I'd removed these intending to add new ones for the new primitives and never got back to it. Will wire it up; is that a -1 or are you OK adding that after the initial merge?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have strong feelings, but I kinda think it's important to have tracing/tracking available from the get-go, as this is new stuff that may cause mysterious and subtle bugs on certain workloads, and having a nice way to debug zync behaviour would be really handy. Don't you think?
But I maybe overestimating tracing/tracking importance here...

Copy link
Member

Choose a reason for hiding this comment

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

This needs to be reenabled as part of this PR or whatever removes it. We can't be dropping features with the promise to add them later.

To enable object tracking, enable :kconfig:option:`CONFIG_TRACING_OBJECT_TRACKING`.
Note that each list can be enabled or disabled via their tracing
configuration. For example, to disable tracking of semaphores, one can
disable :kconfig:option:`CONFIG_TRACING_SEMAPHORE`.
configuration. For example, to disable tracking of FIFOs, one can
disable :kconfig:option:`CONFIG_TRACING_FIFO`.

Object tracking is behind tracing configuration as it currently leverages
tracing infrastructure to perform the tracking.
Expand Down
1 change: 1 addition & 0 deletions drivers/counter/counter_mchp_xec.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
LOG_MODULE_REGISTER(counter_mchp_xec, CONFIG_COUNTER_LOG_LEVEL);

#include <zephyr/drivers/counter.h>
#include <zephyr/irq.h>
#include <soc.h>
#include <errno.h>
#include <stdbool.h>
Expand Down
1 change: 1 addition & 0 deletions drivers/watchdog/wdt_mchp_xec.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
LOG_MODULE_REGISTER(wdt_mchp_xec);

#include <zephyr/drivers/watchdog.h>
#include <zephyr/irq.h>
#include <soc.h>
#include <errno.h>

Expand Down
1 change: 1 addition & 0 deletions include/zephyr/drivers/kscan.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <zephyr/types.h>
#include <stddef.h>
#include <zephyr/device.h>
#include <errno.h>

#ifdef __cplusplus
extern "C" {
Expand Down
10 changes: 10 additions & 0 deletions include/zephyr/kernel_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ extern bool z_priq_rb_lessthan(struct rbnode *a, struct rbnode *b);

#define Z_WAIT_Q_INIT(wait_q) { { { .lessthan_fn = z_priq_rb_lessthan } } }

#define Z_WAIT_Q_LAZY_INIT(wq) do { \
if ((wq)->waitq.tree.lessthan_fn == NULL) { \
(wq)->waitq.tree.lessthan_fn = z_priq_rb_lessthan; \
} } while (false)


#else

typedef struct {
Expand All @@ -234,6 +240,10 @@ typedef struct {

#define Z_WAIT_Q_INIT(wait_q) { SYS_DLIST_STATIC_INIT(&(wait_q)->waitq) }

#define Z_WAIT_Q_LAZY_INIT(wq) do { \
if ((wq)->waitq.head == NULL) { \
sys_dlist_init(&(wq)->waitq); } \
} while (false)
#endif

/* kernel timeout record */
Expand Down
16 changes: 14 additions & 2 deletions include/zephyr/toolchain/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,20 @@
* The section name is the struct type prepended with an underscore.
* The subsection is "static" and the subsubsection is the variable name.
*
* In the linker script, create output sections for these using
* ITERABLE_SECTION_ROM() or ITERABLE_SECTION_RAM().
* Note that this is only the C syntax side of this feature. The
* linker script also needs to be made aware of the output sections.
* Traditionally this is done by inserting expansions of
* ITERABLE_SECTION_*() macros into
* include/zephyr/linker/common-ram/rom.ld.
*
* But now there is a variant linker script generation scheme when
* CONFIG_CMAKE_LINKER_GENERATOR=y. That is a different framework,
* where you have to use zephyr_iterable_section() commands in
* cmake/linker_script/common/common-ram.cmake
*
* (Really both of those are problematic: the build should be able to
* detect iterable sections in the build artifacts automatically from
* nothing more than what we have here).
*
* @note In order to store the element in ROM, a const specifier has to
* be added to the declaration: const STRUCT_SECTION_ITERABLE(...);
Expand Down
18 changes: 0 additions & 18 deletions include/zephyr/tracing/tracing_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,6 @@
#define sys_port_trace_type_mask_k_work_poll(trace_call)
#endif

#if defined(CONFIG_TRACING_SEMAPHORE)
#define sys_port_trace_type_mask_k_sem(trace_call) trace_call
#else
#define sys_port_trace_type_mask_k_sem(trace_call)
#endif

#if defined(CONFIG_TRACING_MUTEX)
#define sys_port_trace_type_mask_k_mutex(trace_call) trace_call
#else
#define sys_port_trace_type_mask_k_mutex(trace_call)
#endif

#if defined(CONFIG_TRACING_CONDVAR)
#define sys_port_trace_type_mask_k_condvar(trace_call) trace_call
#else
#define sys_port_trace_type_mask_k_condvar(trace_call)
#endif

#if defined(CONFIG_TRACING_QUEUE)
#define sys_port_trace_type_mask_k_queue(trace_call) trace_call
#else
Expand Down
2 changes: 0 additions & 2 deletions include/zephyr/tracing/tracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@

extern struct k_timer *_track_list_k_timer;
extern struct k_mem_slab *_track_list_k_mem_slab;
extern struct k_sem *_track_list_k_sem;
extern struct k_mutex *_track_list_k_mutex;
extern struct k_stack *_track_list_k_stack;
extern struct k_msgq *_track_list_k_msgq;
extern struct k_mbox *_track_list_k_mbox;
Expand Down
15 changes: 11 additions & 4 deletions lib/os/fdtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,14 @@ static struct fd_entry fdtable[CONFIG_POSIX_MAX_FDS] = {
{
/* STDIN */
.vtable = &stdinout_fd_op_vtable,
.refcount = ATOMIC_INIT(1)
},
{
/* STDOUT */
.vtable = &stdinout_fd_op_vtable,
.refcount = ATOMIC_INIT(1)
},
{
/* STDERR */
.vtable = &stdinout_fd_op_vtable,
.refcount = ATOMIC_INIT(1)
},
#else
{
Expand Down Expand Up @@ -95,8 +92,9 @@ static int z_fd_unref(int fd)
static int _find_fd_entry(void)
{
int fd;
const int min = IS_ENABLED(CONFIG_POSIX_API) ? 3 : 0;

for (fd = 0; fd < ARRAY_SIZE(fdtable); fd++) {
for (fd = min; fd < ARRAY_SIZE(fdtable); fd++) {
if (!atomic_get(&fdtable[fd].refcount)) {
return fd;
}
Expand All @@ -115,6 +113,15 @@ static int _check_fd(int fd)

fd = k_array_index_sanitize(fd, ARRAY_SIZE(fdtable));

/* lazy-init the mutex in the static descriptors */
if (IS_ENABLED(CONFIG_POSIX_API) && fd < 3) {
if (atomic_cas(&fdtable[fd].refcount, 0, 1)) {
(void)k_mutex_lock(&fdtable_lock, K_FOREVER);
k_mutex_init(&fdtable[fd].lock);
k_mutex_unlock(&fdtable_lock);
}
}

if (!atomic_get(&fdtable[fd].refcount)) {
errno = EBADF;
return -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ CONFIG_POLL=y
CONFIG_SCHED_SCALABLE=y
CONFIG_THREAD_CUSTOM_DATA=y
CONFIG_CMSIS_THREAD_MAX_STACK_SIZE=1024
CONFIG_SMP=n
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ CONFIG_SCHED_SCALABLE=y
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000
CONFIG_CMSIS_V2_THREAD_MAX_STACK_SIZE=2048
CONFIG_CMSIS_V2_THREAD_DYNAMIC_STACK_SIZE=2048
CONFIG_SMP=n
4 changes: 4 additions & 0 deletions samples/userspace/shared_mem/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ void main(void)

k_thread_start(&ct_thread);
k_sem_give(&allforone);
k_yield();
printk("CT thread started\n");
}

Expand Down Expand Up @@ -243,6 +244,7 @@ void enc(void)

}
k_sem_give(&allforone);
k_yield();
}
}

Expand All @@ -265,6 +267,7 @@ void pt(void)
fBUFIN = 1;
}
k_sem_give(&allforone);
k_yield();
k_sem_take(&allforone, K_FOREVER);
if (fBUFIN == 0) { /* send message to decode */
printk("\nPT Sending Message 1'\n");
Expand Down Expand Up @@ -296,5 +299,6 @@ void ct(void)
printk("CT MSG: %s\n", (char *)&tbuf);
}
k_sem_give(&allforone);
k_yield();
}
}
4 changes: 1 addition & 3 deletions scripts/build/gen_kobject_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,7 @@ def find_kobjects(elf, syms):
continue

if "DW_AT_location" not in die.attributes:
debug_die(die,
"No location information for object '%s'; possibly stack allocated"
% name)
# This can happen for linker aliases
continue

loc = die.attributes["DW_AT_location"]
Expand Down
1 change: 1 addition & 0 deletions soc/xtensa/intel_adsp/common/boot_complete.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <errno.h>
#include <zephyr/arch/xtensa/cache.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
Expand Down
2 changes: 2 additions & 0 deletions soc/xtensa/intel_adsp/common/mem_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
*/

#include <zephyr/arch/xtensa/cache.h>
#include <zephyr/arch/xtensa/arch.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/arch/cpu.h>
#include <zephyr/sys/sys_io.h>

#include <adsp_memory.h>
#include <adsp_shim.h>
Expand Down
4 changes: 2 additions & 2 deletions subsys/net/ip/net_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ int net_context_get(sa_family_t family, enum net_sock_type type, uint16_t proto,
}

memset(&contexts[i], 0, sizeof(contexts[i]));
k_mutex_init(&contexts[i].lock);

/* FIXME - Figure out a way to get the correct network interface
* as it is not known at this point yet.
*/
Expand Down Expand Up @@ -312,8 +314,6 @@ int net_context_get(sa_family_t family, enum net_sock_type type, uint16_t proto,
k_sem_init(&contexts[i].recv_data_wait, 1, K_SEM_MAX_LIMIT);
}

k_mutex_init(&contexts[i].lock);

contexts[i].flags |= NET_CONTEXT_IN_USE;
*context = &contexts[i];

Expand Down
18 changes: 0 additions & 18 deletions subsys/tracing/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -224,24 +224,6 @@ config TRACING_ISR
Enable tracing ISRs. This requires the backend to be
very low-latency.

config TRACING_SEMAPHORE
bool "Tracing Semaphores"
default y
help
Enable tracing Semaphores.

config TRACING_MUTEX
bool "Tracing Mutexes"
default y
help
Enable tracing Mutexes.

config TRACING_CONDVAR
bool "Tracing Condition Variables"
default y
help
Enable tracing Condition Variables

config TRACING_QUEUE
bool "Tracing Queues"
default y
Expand Down
26 changes: 0 additions & 26 deletions subsys/tracing/tracing_tracking.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ struct k_spinlock _track_list_k_timer_lock;
struct k_mem_slab *_track_list_k_mem_slab;
struct k_spinlock _track_list_k_mem_slab_lock;

struct k_sem *_track_list_k_sem;
struct k_spinlock _track_list_k_sem_lock;

struct k_mutex *_track_list_k_mutex;
struct k_spinlock _track_list_k_mutex_lock;

struct k_stack *_track_list_k_stack;
struct k_spinlock _track_list_k_stack_lock;

Expand Down Expand Up @@ -65,20 +59,6 @@ void sys_track_k_mem_slab_init(struct k_mem_slab *slab)
SYS_TRACK_LIST_PREPEND(_track_list_k_mem_slab, slab));
}

void sys_track_k_sem_init(struct k_sem *sem)
{
if (sem) {
SYS_PORT_TRACING_TYPE_MASK(k_sem,
SYS_TRACK_LIST_PREPEND(_track_list_k_sem, sem));
}
}

void sys_track_k_mutex_init(struct k_mutex *mutex)
{
SYS_PORT_TRACING_TYPE_MASK(k_mutex,
SYS_TRACK_LIST_PREPEND(_track_list_k_mutex, mutex));
}

void sys_track_k_stack_init(struct k_stack *stack)
{
SYS_PORT_TRACING_TYPE_MASK(k_stack,
Expand Down Expand Up @@ -121,12 +101,6 @@ static int sys_track_static_init(const struct device *arg)
SYS_PORT_TRACING_TYPE_MASK(k_mem_slab,
SYS_TRACK_STATIC_INIT(k_mem_slab, 0));

SYS_PORT_TRACING_TYPE_MASK(k_sem,
SYS_TRACK_STATIC_INIT(k_sem, 0));

SYS_PORT_TRACING_TYPE_MASK(k_mutex,
SYS_TRACK_STATIC_INIT(k_mutex, 0));

SYS_PORT_TRACING_TYPE_MASK(k_stack,
SYS_TRACK_STATIC_INIT(k_stack));

Expand Down
3 changes: 1 addition & 2 deletions tests/benchmarks/footprints/src/mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define STACK_SIZE 512

K_MUTEX_DEFINE(user_mutex);
K_MUTEX_DEFINE(sys_mutex);

#ifdef CONFIG_USERSPACE
static void user_thread_fn(void *arg1, void *arg2, void *arg3)
Expand Down Expand Up @@ -41,8 +42,6 @@ static void run_user_mutex(void)

static void run_system_mutex(void)
{
struct k_mutex sys_mutex;

k_mutex_init(&sys_mutex);

k_mutex_lock(&sys_mutex, K_FOREVER);
Expand Down
2 changes: 1 addition & 1 deletion tests/benchmarks/footprints/src/semaphore.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define STACK_SIZE 512

K_SEM_DEFINE(semaphore0, 0, 1);
K_SEM_DEFINE(sem0, 0, 1);

void thread_fn(void *p1, void *p2, void *p3)
{
Expand All @@ -23,7 +24,6 @@ void thread_fn(void *p1, void *p2, void *p3)
void run_semaphore(void)
{
k_tid_t sem0_tid;
struct k_sem sem0;

k_sem_init(&sem0, 0, 1);

Expand Down
7 changes: 7 additions & 0 deletions tests/drivers/ipm/src/ipm_dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ static int ipm_dummy_send(const struct device *d, int wait, uint32_t id,

irq_offload(ipm_dummy_isr, (const void *)d);

if (IS_ENABLED(CONFIG_ARC)) {
/* ARC's irq_offload doesn't switch threads, so we
* need to do it manually. See #51814
*/
k_yield();
}

if (wait) {
while (driver_data->regs.busy) {
/* busy-wait */
Expand Down
Loading