-
Notifications
You must be signed in to change notification settings - Fork 7k
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
A sample application to demonstrate use of kernel event logger feature. #4552
Conversation
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.
suggested edits
@@ -0,0 +1,40 @@ | |||
.. _kerneleventlogger_sample: | |||
|
|||
Kerneleventlogger Sample |
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.
How about:
Kernel Event Logger Sample
##########################
Note the #### underline must be at least as long as the title above it.
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.
done
|
||
A simple application that demonstrates use of kernel event | ||
logger feature.Two threads (A and B) of same priority are | ||
created and another thread with less priority (i.e event_ |
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.
Words that end with an underscore are meaningful to the doc gen process, so break the line before event_
so the line doesn't end with an underscore. Also some clarity edits:
created and a third thread with lower priority (i.e.,
event_logger_thread) is also created, which reads
the events from
******** | ||
|
||
A simple application that demonstrates use of kernel event | ||
logger feature.Two threads (A and B) of same priority are |
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.
add a space after the period ending a sentence
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.
k
******** | ||
|
||
A simple application that demonstrates use of kernel event | ||
logger feature.Two threads (A and B) of same priority are |
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.
and change to "of the same priority"
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.
k
logger feature.Two threads (A and B) of same priority are | ||
created and another thread with less priority (i.e event_ | ||
logger_thread)is also created which reads the events from | ||
kernel event loggerbuffer and prints on to the console. |
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.
Change to:
kernel event logger's buffer
to match what you've written below, and change "prints on to" to just "prints to"
created and another thread with less priority (i.e event_ | ||
logger_thread)is also created which reads the events from | ||
kernel event loggerbuffer and prints on to the console. | ||
When thread 'A' gets schecduled it will sleep for 1 second. |
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.
scheduled
kernel event loggerbuffer and prints on to the console. | ||
When thread 'A' gets schecduled it will sleep for 1 second. | ||
Similarly when thread 'B' gets scheduled it will sleep for | ||
0.5 seconds. When both A and B are sleeping event logger |
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.
change to:
... are sleeping, the event logger
When thread 'A' gets schecduled it will sleep for 1 second. | ||
Similarly when thread 'B' gets scheduled it will sleep for | ||
0.5 seconds. When both A and B are sleeping event logger | ||
thread gets scheduled and retrieve the events captured |
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.
retrieves
Similarly when thread 'B' gets scheduled it will sleep for | ||
0.5 seconds. When both A and B are sleeping event logger | ||
thread gets scheduled and retrieve the events captured | ||
from kernel event loggers buffer and prints it on the console. |
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.
logger's
@@ -0,0 +1,40 @@ | |||
.. _kerneleventlogger_sample: |
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.
This is the first document in the logging area, so you'll need to also add a file samples/subsys/logging/logging.rst that looks like samples/subsys/console/console.rst (copy that one and edit the title). This will remove the "not included in a toc-tree" warning.
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.
ok
obj-y += main.o | ||
|
||
ccflags-y += -I${ZEPHYR_BASE}/ext/debug/segger/rtt | ||
ccflags-y += -I${ZEPHYR_BASE}/ext/debug/segger/systemview |
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.
you do not need those
|
||
timestamp = event_data[0]; | ||
|
||
switch (event_id) { |
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.
add a default to the switch
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.
ok
case KERNEL_EVENT_LOGGER_SLEEP_EVENT_ID: | ||
break; | ||
case KERNEL_EVENT_LOGGER_THREAD_EVENT_ID: | ||
printk("thread = %x, is moved to = %s , |
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.
reformat this message, this should fit in 2 lines and would be more readable.
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.
ok.
static u32_t timestamp; | ||
char thread_event_type[][12] = {"REDAY_Q", "PEND_STATE", "EXIT_STATE"}; | ||
|
||
static void event_logger_thread(void) |
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.
why not make this the main thread?
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.
The thread which reads event from the kernel event logger should be of least priority, because this thread should not affect application related threads. As main thread is set with priority zero, it should not be used for reading events from event loggers
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.
you can change the main thread priority using CONFIG_MAIN_THREAD_PRIORITY
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 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.
ok .
db20ecf
to
f8e847a
Compare
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.
almost done...
|
||
A simple application that demonstrates use of kernel event | ||
logger feature. Two threads (A and B) of the same priority | ||
are created and main thread is configured to have low priority , |
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.
delete space before the comma
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.
ok
which reads the events from kernel event logger's buffer and | ||
prints to the console. When thread 'A' gets scheduled it will | ||
sleep for 1 second. Similarly when thread 'B' gets scheduled | ||
it will sleep for 0.5 seconds. When both A and B are sleeping , |
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.
delete space before the comma
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.
ok
f8e847a
to
8a8bd0d
Compare
A CPU fault occurs when sys_k_event_logger_get_wait() api invoked with config KERNEL_EVENT_LOGGER_THREAD enabled. sys_k_event_logger_get_wait() supposed to pend on a semaphore when all the events from kernel event logger are read.But when sys_k_event_logger_get_wait() inovked with config KERNEL_EVENT_LOGGER_THREAD(i.e captures thread events) subsquent call inside this function will write to kernel event log buffer to capture pend event.This will release the semaphore on which sys_k_event_logger_get_wait() was pending hence thread gets unpend before swap gets called. Which in other words a thread which is invoking sys_k_event_logger_get_wait()(i. e sem_count = 0) get pends and unpends in single function flow when KERNEL_EVENT_LOGGER_THREAD enabled. This would cause overlapping of the stack address where return address of "_pend_current_thread" stored with esp of callee saved(i. e thread->callee_saved.esp). Thus return adrress of "_pend_current_thread" would be overwitten with zero. Which in turn causes CPU fault. The thread invoking sys_k_event_logger_get_wait() supposed to only read the events of the threads which logged to kernel event logger buffer. But it should not write to kernel event logger buffer. Otherwise it would cause the race condition explained above. Signed-off-by: Savinay Dharmappa <[email protected]>
patch adds a sample application to demonstrate use of kernel event logger feature. Signed-off-by: Savinay Dharmappa <[email protected]>
fixes #3412