-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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: add minimal implementation #19322
Conversation
All checks are passing now. Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
25cb604
to
f9a144b
Compare
f9a144b
to
d991064
Compare
d991064
to
6298b9a
Compare
6298b9a
to
c888ef1
Compare
Would be nice to refactor the console stuff to do less Also saw a bunch of select-with-unsatisfied-deps. issues there earlier, but maybe most of them have gotten fixed. |
@ulfalizer I ran into this. If I change the "imply PRINTK" to "depends-on PRINTK" for CONFIG_LOG_MINIMAL, it all goes up in flames with a circular dependency.
Think I've seen these at times, but might because I modfied some Kconfig and needed to do a clean build. |
c888ef1
to
2d7491c
Compare
Yeah, honestly those errors are a pain to figure out for me too. Usually, it helps to try to stick to Unrelated to this PR though. |
Could this minimal implementation be used instead of LOG_IMMEDIATE? |
The main issue (once #19339 gets in) is the fact that when log immediate is enabled then thread stack usage increases and that will lead to mpu faults since stacks are tuned for deferred logging. Minimal logging won't help with that since main stack contributor is string formatting. By switching to log minimal we safe ~2k of ROM compared to log_immediate but we lose things like pretty output (timestamp, module name/log level/function name prefix), support for multiple backends, integration with shell. Imo, the difference is significant enough to have both options. |
include/logging/log_core.h
Outdated
|
||
#define Z_LOG(_level, fmt, ...) do { \ | ||
if (Z_LOG_CONST_LEVEL_CHECK(_level)) { \ | ||
printk(fmt "\n", ##__VA_ARGS__); \ |
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.
there is no locking here. Won't it crash if one log interrupts another? I guess that simple console like uart may survive but what about console over cdc acm?
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.
it doesn't. these emit to the console drivers one character at a time.
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.
For the code itself, I don't see anything wrong.
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.
log_strdup has an issue if it is called twice in the same call to LOG_INFO. I would really like to see this fixed, as there are instances where this happens in the stack at the moment. And using minimal logging would yield very confusing logging info when this happens. (see my earlier comment https://github.com/zephyrproject-rtos/zephyr/pull/19322/files#r327967725)
I'm not seeing how this is related to my patch? |
@andrewboie We have discussed this offline and reached the conclusion that we can leave log_strdup like this. (although for the record the name is misleading and could possible lead to the same confusion for others). |
2d7491c
to
2673d30
Compare
Updated PR:
|
443c97c
to
d25ac9c
Compare
Similar to how LOG_INIT(), LOG_PANIC(), etc are wrapped. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
The same function should not be defined in two different headers. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
printk() doesn't return a value, this doesn't need to either. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
These checks should be against CONFIG_SHELL_LOG_BACKEND, and not against CONFIG_LOG, since it's possible to enable logging without building this particular backend. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Log backends don't exist with minimal logging enabled, don't compile this code. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
The log mechanism, even in immediate mode, adds somewhere between 1K-2K of footprint to applications that use it. We want to standardize the logging APIs for all logging within the kernel, but need to not let platforms with very constrained RAM/ROM in the dust. This patch introduces CONFIG_LOG_MINIMAL, which is a very thin wrapper to printk(). It supports the APIs expressed in logging/log.h. This will be the new default for test cases. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
d25ac9c
to
73f0257
Compare
Thank you. |
The log mechanism, even in immediate mode, adds somewhere
between 1K-2K of footprint to applications that use it.
We want to standardize the logging APIs for all logging
within the kernel, but need to not let platforms with
very constrained RAM/ROM in the dust.
This patch introduces CONFIG_LOG_MINIMAL, which is a very
thin wrapper to printk(). It supports the APIs expressed
in logging/log.h.
This will be the new default for test cases.
log_printk()'s return value was removed to make it more like Zephyr printk().
Some code in shell and bluetooth monitor which assumed that the backend code existed has been adjusted.
Fixes: #19317