Commit 872f3636 authored by Dong Wang's avatar Dong Wang Committed by Benjamin Cabé
Browse files

logging: Ensure atomic update of log filter slot in LOG_FILTER_SLOT_SET

Replaced the read-modify-write sequence with a single read and write
operation, preventing the intermediate value is wrongly used to filter
out logs of another thread with higher priority that preempts the current
thread.

Signed-off-by: default avatarDong Wang <dong.d.wang@intel.com>
parent 3fac8315
Loading
Loading
Loading
Loading
+3 −3
Changes for include/zephyr/logging/log_core.h: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -403,10 +403,10 @@ static inline char z_log_minimal_level_to_char(int level)

#define LOG_FILTER_SLOT_SET(_filters, _id, _filter)			      \
	do {								      \
		*(_filters) &= ~(LOG_FILTER_SLOT_MASK <<	     \
		uint32_t others = *(_filters) & ~(LOG_FILTER_SLOT_MASK <<     \
				 LOG_FILTER_SLOT_SHIFT(_id));		      \
		*(_filters) = others | (((_filter) & LOG_FILTER_SLOT_MASK) << \
			       LOG_FILTER_SLOT_SHIFT(_id));		      \
		*(_filters) |= ((_filter) & LOG_FILTER_SLOT_MASK) << \
			       LOG_FILTER_SLOT_SHIFT(_id);	     \
	} while (false)

#define LOG_FILTER_AGGR_SLOT_IDX 0