Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.
/ zephyr Public archive
forked from zephyrproject-rtos/zephyr

Commit

Permalink
Revert "Bug zephyrproject-rtos#21045 Port logging system fixes from z…
Browse files Browse the repository at this point in the history
  • Loading branch information
rerickson1 committed Feb 22, 2022
1 parent a802f8b commit e9c8745
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 99 deletions.
47 changes: 0 additions & 47 deletions include/logging/log_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -724,53 +724,6 @@ void log_generic_from_user(struct log_msg_ids src_level,
*/
bool log_is_strdup(const void *buf);

/** @brief Free allocated buffer.
*
* @param buf Buffer.
*/
void log_free(void *buf);

/**
* @brief Get current number of allocated buffers for string duplicates.
*/
uint32_t log_get_strdup_pool_current_utilization(void);

/**
* @brief Get maximal number of simultaneously allocated buffers for string
* duplicates.
*
* Value can be used to determine pool size.
*/
uint32_t log_get_strdup_pool_utilization(void);

/**
* @brief Get length of the longest string duplicated.
*
* Value can be used to determine buffer size in the string duplicates pool.
*/
uint32_t log_get_strdup_longest_string(void);

/** @brief Indicate to the log core that one log message has been dropped.
*
* @param buffered True if dropped message was already buffered and it is being
* dropped to free space for another message. False if message is being dropped
* because allocation failed.
*/
void z_log_dropped(bool buffered);

/** @brief Read and clear current drop indications counter.
*
* @return Dropped count.
*/
uint32_t z_log_dropped_read_and_clear(void);

/** @brief Check if there are any pending drop notifications.
*
* @retval true Pending unreported drop indications.
* @retval false No pending unreported drop indications.
*/
bool z_log_dropped_pending(void);

/** @brief Log a message from user mode context.
*
* @note This function is intended to be used internally
Expand Down
57 changes: 13 additions & 44 deletions include/logging/log_msg2.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ do { \
*
* @param ... Optional string with arguments (fmt, ...). It may be empty.
*/
#if CONFIG_LOG2_ALWAYS_RUNTIME
#define Z_LOG_MSG2_CREATE3(_try_0cpy, _mode, _cstr_cnt, _domain_id, _source,\
#ifdef CONFIG_LOG2_ALWAYS_RUNTIME
#define Z_LOG_MSG2_CREATE2(_try_0cpy, _mode, _cstr_cnt, _domain_id, _source,\
_level, _data, _dlen, ...) \
do {\
Z_LOG_MSG2_STR_VAR(_fmt, ##__VA_ARGS__) \
Expand All @@ -353,8 +353,8 @@ do {\
Z_LOG_FMT_ARGS(_fmt, ##__VA_ARGS__));\
_mode = Z_LOG_MSG2_MODE_RUNTIME; \
} while (0)
#elif CONFIG_LOG2_MODE_IMMEDIATE /* CONFIG_LOG2_ALWAYS_RUNTIME */
#define Z_LOG_MSG2_CREATE3(_try_0cpy, _mode, _cstr_cnt, _domain_id, _source,\
#elif defined(CONFIG_LOG2_MODE_IMMEDIATE) /* CONFIG_LOG2_ALWAYS_RUNTIME */
#define Z_LOG_MSG2_CREATE2(_try_0cpy, _mode, _cstr_cnt, _domain_id, _source,\
_level, _data, _dlen, ...) \
do { \
Z_LOG_MSG2_STR_VAR(_fmt, ##__VA_ARGS__); \
Expand All @@ -371,7 +371,7 @@ do { \
} \
} while (0)
#else /* CONFIG_LOG2_ALWAYS_RUNTIME */
#define Z_LOG_MSG2_CREATE3(_try_0cpy, _mode, _cstr_cnt, _domain_id, _source,\
#define Z_LOG_MSG2_CREATE2(_try_0cpy, _mode, _cstr_cnt, _domain_id, _source,\
_level, _data, _dlen, ...) \
do { \
Z_LOG_MSG2_STR_VAR(_fmt, ##__VA_ARGS__); \
Expand All @@ -396,50 +396,19 @@ do { \
} while (0)
#endif /* CONFIG_LOG2_ALWAYS_RUNTIME */

#define Z_LOG_MSG2_CREATE2(_try_0cpy, _mode, _domain_id, _source,\
#define Z_LOG_MSG2_CREATE(_try_0cpy, _mode, _domain_id, _source,\
_level, _data, _dlen, ...) \
Z_LOG_MSG2_CREATE3(_try_0cpy, _mode, UTIL_CAT(Z_LOG_FUNC_PREFIX_, _level), \
Z_LOG_MSG2_CREATE2(_try_0cpy, _mode, UTIL_CAT(Z_LOG_FUNC_PREFIX_, _level), \
_domain_id, _source, _level, _data, _dlen, \
Z_LOG_STR(_level, __VA_ARGS__))

/* Macro for getting name of a local variable with the exception of the first argument
* which is a formatted string in log message.
*/
#define Z_LOG_LOCAL_ARG_NAME(idx, arg) COND_CODE_0(idx, (arg), (_v##idx))

/* Create local variable from input variable (expect first (fmt) argument). */
#ifdef __cplusplus
#define Z_LOG_LOCAL_ARG_CREATE(idx, arg) \
COND_CODE_0(idx, (), (auto Z_LOG_LOCAL_ARG_NAME(idx, arg) = (arg) + 0))
#else
#define Z_LOG_LOCAL_ARG_CREATE(idx, arg) \
COND_CODE_0(idx, (), (__auto_type Z_LOG_LOCAL_ARG_NAME(idx, arg) = (arg) + 0))
#endif

/* First level of processing creates stack variables to be passed for further processing.
* This is done to prevent multiple evaluations of input arguments (in case argument
* evaluation has consequences, e.g. it is a function call).
/** @brief Allocate log message.
*
* @param wlen Length in 32 bit words.
*
* @return allocated space or null if cannot be allocated.
*/
#define Z_LOG_MSG2_CREATE(_try_0cpy, _mode, _domain_id, _source, _level, _data, _dlen, ...) \
do { \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wpointer-arith\"") \
FOR_EACH_IDX(Z_LOG_LOCAL_ARG_CREATE, (;), __VA_ARGS__); \
_Pragma("GCC diagnostic pop") \
Z_LOG_MSG2_CREATE2(_try_0cpy, _mode, _domain_id, _source,\
_level, _data, _dlen, \
FOR_EACH_IDX(Z_LOG_LOCAL_ARG_NAME, (,), __VA_ARGS__)); \
} while (0)

#define Z_TRACING_LOG_HDR_INIT(name, id) \
struct log_msg2_trace name = { \
.hdr = { \
.type = Z_LOG_MSG2_TRACE, \
.valid = 1, \
.busy = 0, \
.evt_id = id, \
} \
}
struct log_msg2 *z_log_msg2_alloc(uint32_t wlen);

/** @brief Finalize message.
*
Expand Down
8 changes: 3 additions & 5 deletions subsys/logging/log_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,12 +851,10 @@ uint32_t z_vrfy_log_buffered_cnt(void)
#include <syscalls/log_buffered_cnt_mrsh.c>
#endif

void z_log_dropped(bool buffered)
void z_log_dropped(void)
{
atomic_inc(&dropped_cnt);
if (buffered) {
atomic_dec(&buffered_cnt);
}
atomic_dec(&buffered_cnt);
}

uint32_t z_log_dropped_read_and_clear(void)
Expand All @@ -875,7 +873,7 @@ static void notify_drop(const struct mpsc_pbuf_buffer *buffer,
ARG_UNUSED(buffer);
ARG_UNUSED(item);

z_log_dropped(true);
z_log_dropped();
}


Expand Down
4 changes: 2 additions & 2 deletions subsys/logging/log_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ union log_msg_chunk *log_msg_no_space_handle(void)
if (IS_ENABLED(CONFIG_LOG_MODE_OVERFLOW)) {
do {
more = log_process(true);
z_log_dropped(true);
z_log_dropped();
err = k_mem_slab_alloc(&log_msg_pool,
(void **)&msg,
K_NO_WAIT);
} while ((err != 0) && more);
} else {
z_log_dropped(false);
z_log_dropped();
}
return msg;

Expand Down
2 changes: 1 addition & 1 deletion subsys/logging/log_msg2.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void z_log_msg2_finalize(struct log_msg2 *msg, const void *source,
const struct log_msg2_desc desc, const void *data)
{
if (!msg) {
z_log_dropped(false);
z_log_dropped();

return;
}
Expand Down

0 comments on commit e9c8745

Please sign in to comment.