-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging: Overhaul #31535
Logging: Overhaul #31535
Conversation
c8c5efa
to
bbf35a9
Compare
10e7cb3
to
1893f47
Compare
1893f47
to
cca756a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't done much more than a cursory scan, but this looks pretty clean to my eyes.
One question I can't find an immediate answer to: is this still running the backends out of a timer vs. letting them pull the output as they have bandwidth? It looks like it might be, because I don't see anything like that removed. This has been one of my pet peeves: backends with fast transport[1] drop a LOT of messages essentially needlessly, simply because the logging core never even tries to write them.
[1] The one I work on the most right now is the intel_adsp, where trace output goes into a region of system DRAM shared with the host OS -- it can sink bytes as fast as the DSP can write them)
@andyross following approach is used: logging operates with a circular packet buffer (contrary to list of fragmented messages allocated from memslab). When logging is processing it passes the pointer to the message from the packet buffer to each backend. Call to the backend is synchronous so logging expects that when it returns message is no longer used by the backend. Backend has two option: block the logging thread and process the message or copy the message to its own memory and return. |
Logging v2 is using _Generic keyword for detecting type of log message arguments. Apparently, it does not support handling of pointers to forward declared structures. Added casting to void *. Signed-off-by: Krzysztof Chruscinski <[email protected]>
Refactor and cleanup in preparation for v2. Signed-off-by: Krzysztof Chruscinski <[email protected]>
Added implementation of log_msg2 which is creating log messages using cbprintf packaging and storing them in circular ring buffer (mpsg_pbuf). Signed-off-by: Krzysztof Chruscinski <[email protected]>
Added parsing of log_msg2. Signed-off-by: Krzysztof Chruscinski <[email protected]>
Adapted to be able to switch between v1 and v2. Signed-off-by: Krzysztof Chruscinski <[email protected]>
Added suite for log_msg2 macros. Signed-off-by: Krzysztof Chruscinski <[email protected]>
Added macro which allows to print formatted string using logging infrastructure. Signed-off-by: Krzysztof Chruscinski <[email protected]>
Added test which benchmarks deferred logging v1 and v2. Signed-off-by: Krzysztof Chruscinski <[email protected]>
Extended and refactored logging documentation. Added details about logging v2 and comparison with v1. Signed-off-by: Krzysztof Chruscinski <[email protected]>
Adapted to handle processing of v2 log messages. Signed-off-by: Krzysztof Chruscinski <[email protected]>
Add support for logging v2 to native_posix backend. Signed-off-by: Krzysztof Chruscinski <[email protected]>
Add support for logging v2 to RTT backend. Signed-off-by: Krzysztof Chruscinski <[email protected]>
Added support for v2 backend interface to ADSP. Signed-off-by: Krzysztof Chruscinski <[email protected]>
Extended shell to support logging v2. Signed-off-by: Krzysztof Chruscinski <[email protected]>
Point to commit which contains temporary fix for sof redefining MAX macro. Signed-off-by: Krzysztof Chruscinski <[email protected]>
Refactor logging function to avoid multiple macro calls. Signed-off-by: Krzysztof Chruscinski <[email protected]>
CONFIG_LOG2 with floating point output Here is the list of the required CONFIG to get the LOG2 for floating point working. It is mandatory to set
|
**It is mandatory to set `CONFIG_CBPRINTF_FP_A_SUPPORT=y`** to get `%f` and `%g` working! And `%a` is working also ;-).
No. CONFIG_CBPRINTF_FP_A_SUPPORT is for ... %a.
%f and %g just need CONFIG_CBPRINTF_FP_SUPPORT.
|
THanks for clarification. I have overlooked the So at least one of them has to set to get some output. |
Just a note, |
The warnings are gone, may be they were present with an outdated master on my machine. Here is my CMakeList.txt
|
The issue with logging is fixed in PR zephyrproject-rtos#31535 Signed-off-by: Andrei Emeltchenko <[email protected]>
The issue with logging is fixed in PR #31535 Signed-off-by: Andrei Emeltchenko <[email protected]>
Logging v2 highlights
log_strdup
no longer needed!!long long
,float
anddouble
is now possible!!API changes
No change in logging API! Add
CONFIG_LOG2_MODE_DEFFERED=y
to run sample with new version. Only backend API extended with a function for processing v2 messages. PR updates following backends to support v2:To be added later: bluetooth monitor, net, spinel, swo, xtensa sim
Internals
It is utilizing cbprintf packages (#30675, #31102) to create self-contained log message. Using
_Generic
feature of C11, it is possible to act based on types of arguments. It is used to determine when formatted string requires time consuming, runtime package creation and when log message can be created as simple serialization of the arguments. Whenchar *
arguments are present in the log message then package is created at runtime. This includes copying into a message any string argument which is from rw memory.Additionally, log messages are no longer stored as fragmented chunks allocated from a memslab. They are stored in a circular buffer. This ensures that log message is not fragmented and improves memory utilization. Circular buffer is somehow generic multi producer, single consumer packet buffer (
lib/os/mpsc_pbuf
). Additional requirement is to support overwrite mode where oldest packets are dropped when new message cannot be allocated. MPSC packet buffer uses alloc, commit, claim, free sequence to avoid copying. Additionally, it has functions optimized for storing single word and single word + pointer packets. It is forseen that those will be used by the tracing to logger functionality.It pends currently on #33567 being solved. PR contains temporary workaround to get CI green.
PR content
Fixes #26170
Fixes #18351
Fixes #26246
Fixes #30353