Logging thread busy loop in z_impl_log_process function #68289
Unanswered
JungoLin1978
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am experiencing an issue with the behavior of the logging thread.
I want to verify whether this behavior is expected or not.
Below are the configurations on my platform.
The configuration in my platform is listed below:
When the issue is happened, the logging thread will be kept running z_impl_log_process(void) function because of z_log_msg_pending() always return true.
https://elixir.bootlin.com/zephyr/latest/source/subsys/logging/log_core.c#L544
We enable the MPSC_PBUF_DEBUG for this issue
https://elixir.bootlin.com/zephyr/v3.5.0/source/lib/os/mpsc_pbuf.c#L8
Here is the issue log (PS. some UART logs are lost)
The logging thread cannot claim the valid message item with buffer->tmp_rd_idx: 15756.
This message item with tmp_wr_idx:15756 was allocated with 10 words at 11:19:40.333 by thread A, but it was not committed due to a context switch to thread B. Furthermore, the priority of thread A is lower than that of threads B and the logging thread. As a result, there is always a 10-word offset between wr_idx and tmp_wr_idx in the MPSC_PBUF_DEBUG log.
When the logging thread is active, it uses mpsc_pbuf_is_pending(struct mpsc_pbuf_buffer *buffer) to determine whether to release the CPU or not. However, the consistently true returned result leads to thread A experiencing starvation.
https://elixir.bootlin.com/zephyr/v3.5.0/source/lib/os/mpsc_pbuf.c#L606
My question is:
a) Is this an issue? If not, where should I fix it?
b) If yes, does it get fixed in the mpsc_pbuf_is_pending function to check the available buffer and the valid item at the same time?
I appreciate your feedback in advance.
Best regards,
Jungo
Beta Was this translation helpful? Give feedback.
All reactions