-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Stack analyzer #1529
Stack analyzer #1529
Conversation
All checks are passing now. Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
a22d3c5
to
32dd56f
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.
This is going to be a useful module for NCS users - it greatly simplifies setup of monitoring of the thread stacks.
This is very nice 🥇 I suggest letting the user pull in this functionality by simply enabling its Kconfig entry (without the addition of any code). That way we'll be able to use from any sample just by editing its project configuration. |
Good point. |
Yes, or print only when the stack usage is above a certain threshold. |
Is there any way to start a timer without the need to call start function? Currently I do not see a way to implement this code without a modification of the application code when not using additional thread. |
I think having a dedicated thread for this is fine. I prefer a separate thread rather than a task for the system work queue, because otherwise it will affect the stack usage of the system work queue 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.
A few nitpicks
398561b
to
7b7ad85
Compare
This looks very useful. Who should we put into the code-owners file as responsible for the |
@carlescufi @joerchan |
There's got to be a code-owner, at least, co-owning debug/ subsystem, IMO. |
@carlescufi AFAIK we have to wait for upmerge to complete this one. |
Indeed. I have to use k_thread_foreach_unlocked that will be there after upmerge. |
@rakons Could this be picked up again now? |
321be20
to
6ea456e
Compare
@ru-fu - What documentation is missed? |
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.
I will check documentation early next week
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.
few findings
const char *stack = (const char *)thread->stack_info.start; | ||
unsigned int size = thread->stack_info.size; | ||
unsigned int unused = stack_unused_space_get(stack, size); | ||
char name[21]; |
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.
magic number?
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.
fixed
include/debug/stack_size_analyzer.h
Outdated
* | ||
* Callback function with stack size statistics. | ||
* | ||
* @param name The name of the 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.
or stringified address of the thread handle if name is not set.
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.
Comment added
endchoice | ||
|
||
config STACK_SIZE_ANALYZER_AUTO | ||
bool "Enable Stack size analyzer automatic printing" |
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.
since it's already in stack size analyzer menu it should be shorter. Just Enable automatic printing
is sufficient.
@rakons Thank you for picking it up. Could you rebase it to fix the conflict? |
Due to the need to have this functionality easily available for the Bluetooth HCI driver in upstream I suggest we move this functionality to zephyr instead. This has already a few mentions for providing this functionality from the kernel: If nobody disagrees then I will start to port this to upstream as @rakons has indicated he does not have the time. We will then not merge this downstream since we would just have to remove it again in the next upmerge. |
@joerchan - wait until I fix the issues reported by krch. |
@joerchan I'm not sure how you want to handle this PR now, I'm adding a small commit with a language review of the RST file that also fixes some RST output issues. I'm pretty sure this will go through another doc review when getting into zephyr. |
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.
looks ok (checkpatch issues should be fixed at some point)
Stack size analyzer is simple module that helps in printing stacks usage statistics. Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no> Signed-off-by: Bartosz Gentkowski <bartosz.gentkowski@nordicsemi.no>
@b-gent Ok. I'll wait for your RST commit and then port the changes to upstream. Then the rest will be handled in a zephyr PR. |
the commit already went it and got squashed. |
This has been merged upstream now. |
Impossible! It was blazingly fast :) |
A code to make stack analysis simple on our examples.