logging: Use runtime packaging in immediate mode
Always use runtime packaging in immediate mode. Removing attempt to package on stack if possible. It would be done only to speed up logging but that is not a requirement in immediate mode where packaging time is fractional compared to backend processing. Using runtime packaging also reduces stack usage in the context which calls log message. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
e83a13aabf
commit
154ca8526c
|
@ -117,9 +117,6 @@ enum z_log_msg2_mode {
|
|||
* more code size.
|
||||
*/
|
||||
Z_LOG_MSG2_MODE_ZERO_COPY,
|
||||
|
||||
/* Mode used when synchronous logging is enabled. */
|
||||
Z_LOG_MSG2_MODE_SYNC
|
||||
};
|
||||
|
||||
#define Z_LOG_MSG_DESC_INITIALIZER(_domain_id, _level, _plen, _dlen) \
|
||||
|
@ -194,23 +191,6 @@ enum z_log_msg2_mode {
|
|||
Z_LOG_MSG2_ALIGNMENT), \
|
||||
sizeof(uint32_t))
|
||||
|
||||
#define Z_LOG_MSG2_SYNC(_domain_id, _source, _level, _data, _dlen, ...) do { \
|
||||
int _plen; \
|
||||
CBPRINTF_STATIC_PACKAGE(NULL, 0, _plen, Z_LOG_MSG2_ALIGN_OFFSET, \
|
||||
0, __VA_ARGS__); \
|
||||
struct log_msg2 *_msg; \
|
||||
Z_LOG_MSG2_ON_STACK_ALLOC(_msg, Z_LOG_MSG2_LEN(_plen, _dlen)); \
|
||||
if (_plen) {\
|
||||
CBPRINTF_STATIC_PACKAGE(_msg->data, _plen, _plen, \
|
||||
Z_LOG_MSG2_ALIGN_OFFSET, \
|
||||
0, __VA_ARGS__); \
|
||||
} \
|
||||
struct log_msg2_desc _desc = \
|
||||
Z_LOG_MSG_DESC_INITIALIZER(_domain_id, _level, \
|
||||
(uint32_t)_plen, _dlen); \
|
||||
z_log_msg2_finalize(_msg, _source, _desc, _data); \
|
||||
} while (0)
|
||||
|
||||
#define Z_LOG_MSG2_STACK_CREATE(_domain_id, _source, _level, _data, _dlen, ...)\
|
||||
do { \
|
||||
int _plen; \
|
||||
|
@ -353,23 +333,6 @@ do {\
|
|||
Z_LOG_FMT_ARGS(_fmt, ##__VA_ARGS__));\
|
||||
_mode = Z_LOG_MSG2_MODE_RUNTIME; \
|
||||
} while (0)
|
||||
#elif defined(CONFIG_LOG_MODE_IMMEDIATE) /* CONFIG_LOG2_ALWAYS_RUNTIME */
|
||||
#define Z_LOG_MSG2_CREATE3(_try_0cpy, _mode, _cstr_cnt, _domain_id, _source,\
|
||||
_level, _data, _dlen, ...) \
|
||||
do { \
|
||||
Z_LOG_MSG2_STR_VAR(_fmt, ##__VA_ARGS__); \
|
||||
if (CBPRINTF_MUST_RUNTIME_PACKAGE(_cstr_cnt, 0, __VA_ARGS__)) { \
|
||||
LOG_MSG2_DBG("create runtime message\n");\
|
||||
z_log_msg2_runtime_create(_domain_id, (void *)_source, \
|
||||
_level, (uint8_t *)_data, _dlen,\
|
||||
Z_LOG_FMT_ARGS(_fmt, ##__VA_ARGS__));\
|
||||
_mode = Z_LOG_MSG2_MODE_RUNTIME; \
|
||||
} else {\
|
||||
Z_LOG_MSG2_SYNC(_domain_id, _source, _level, \
|
||||
_data, _dlen, Z_LOG_FMT_ARGS(_fmt, ##__VA_ARGS__)); \
|
||||
_mode = Z_LOG_MSG2_MODE_SYNC; \
|
||||
} \
|
||||
} while (0)
|
||||
#else /* CONFIG_LOG2_ALWAYS_RUNTIME */
|
||||
#define Z_LOG_MSG2_CREATE3(_try_0cpy, _mode, _cstr_cnt, _domain_id, _source,\
|
||||
_level, _data, _dlen, ...) \
|
||||
|
|
|
@ -35,16 +35,18 @@ config LOG2_USE_VLA
|
|||
compile time so at runtime arrays have fixed size.
|
||||
|
||||
config LOG2_ALWAYS_RUNTIME
|
||||
bool "Always use runtime message creation (v2)"
|
||||
bool
|
||||
default y if NO_OPTIMIZATIONS
|
||||
default y if LOG_MODE_IMMEDIATE
|
||||
help
|
||||
If enabled, runtime method is always used for message creation. Static
|
||||
creation relies on compiler being able to optimize and remove code
|
||||
based on information known at compile time. It is recommended to
|
||||
enable this option when optimization is disabled because some compilers
|
||||
based on information known at compile time. Runtime only approach is
|
||||
used when optimization is disabled because some compilers
|
||||
(seen on arm_cortex_m and x86) were using unrealistic amount of stack
|
||||
for dead code. Option applies to v1 as well because distinction
|
||||
between versions is done by the compiler.
|
||||
for dead code. It is also used in immediate mode since it requires
|
||||
less stack than static message creation and speed has lower priority
|
||||
in that mode.
|
||||
|
||||
config LOG2_FMT_SECTION
|
||||
bool "Keep log strings in dedicated section"
|
||||
|
|
|
@ -163,6 +163,7 @@ config LOG_TIMESTAMP_64BIT
|
|||
|
||||
config LOG_SPEED
|
||||
bool "Prefer performance over size"
|
||||
depends on LOG_MODE_DEFERRED
|
||||
help
|
||||
If enabled, logging may take more code size to get faster logging.
|
||||
endif # LOG2
|
||||
|
|
Loading…
Reference in a new issue