Skip to content

Commit c7e6034

Browse files
danieldegrassecfriedt
authored andcommitted
tracing: ctf: take IRQ lock before generating timestamp
CTF tracing relies on all packet timestamps being increasing- if a timestamp of a later packet is less than the prior packet, the CTF parser assumes the timestamp field has overflowed and adds to the overall timestamp to account for this. When taking a timestamp for a CTF packet, it was possible for an interrupt to occur before the packet was submitted to the tracing core framework but after the timestamp was generated. The interrupt itself would generate a tracing event with a later timestamp then the packet in question, leading to the packets being recorded out of order. To resolve this, take an IRQ lock before generating the timestamp and release it after submitting the packet to the tracing core. Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent 8240ed9 commit c7e6034

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

subsys/tracing/ctf/ctf_top.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@
5252
#ifdef CONFIG_TRACING_CTF_TIMESTAMP
5353
#define CTF_EVENT(...) \
5454
{ \
55+
int key = irq_lock(); \
5556
const uint32_t tstamp = k_cyc_to_ns_floor64(k_cycle_get_32()); \
5657
\
5758
CTF_GATHER_FIELDS(tstamp, __VA_ARGS__) \
59+
irq_unlock(key); \
5860
}
5961
#else
6062
#define CTF_EVENT(...) \

0 commit comments

Comments
 (0)