-
Notifications
You must be signed in to change notification settings - Fork 7.6k
kernel: Add k_thread_runtime_stats_is_enabled function #80450
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
base: main
Are you sure you want to change the base?
Conversation
fc52903
to
075a033
Compare
70b4aa0
to
04e6d25
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.
Thanks for all of the POSIX clock work.
Just a question / suggestion regarding runtime function call overhead.
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.
Just some suggestions around CONFIG_POSIX_THREAD_CPUTIME
5302a73
to
e9323cc
Compare
I've made change, Please riewer again! |
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.
Kernel side seems reasonable to me.
Fine. It seems difficult to handle. |
@rruuaanng - it's possible that this has been fixed already. But you will need to rebase to fix merge conflicts anyway. |
It seems to still exist :(
other: |
@rruuaanng this needs another rebase |
45a24db
@rruuaanng - Looks like this has conflicts that need to get resolved. |
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.
Tiny nitpick. I'll let others weigh in on the posix changes, seems like that could be a separate PR? +1 for the meat of the PR.
* @param thread ID of thread | ||
* @return true if usage statistics are enabled for the given thread, otherwise false | ||
*/ | ||
bool k_thread_runtime_stats_is_enabled(k_tid_t 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.
If this just depends on the thread struct, that header appears in the include paths already. You can make this inline without worry and save a few code bytes for users.
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.
Maybe we should stick to the existing API style? It looks like there are no static inline functions in kernel.h
.
Add 'k_thread_runtime_stats_is_enabled' function, whichs used to check whether runtime statistics collection is enabled for a thread. Signed-off-by: James Roy <rruuaanng@outlook.com>
Add test for 'k_thread_runtime_stats_is_enabled(tid)'. Signed-off-by: James Roy <rruuaanng@outlook.com>
Add the `k_thread_runtime_stats_is_enabled` function to check if runtime statistics are enabled. Signed-off-by: James Roy <rruuaanng@outlook.com>
I will open a new PR to finish the POSIX part, just to avoid any confusion. |
|
Add 'k_thread_runtime_stats_is_enabled' to 'usage.c', which's used to check whether runtime statistics collection is enabled for a thread.
It can determine whether the thread has enabled runtime statistics collection when the program is running. It allows users to add conditional statements based on this function when using it.
for example:
And it can provide a complete support when similar operations are needed. for example
enable
,disable
,is_enabled
.For example, its use in the implementation of CLOCK_THREAD_CPUTIME_ID actually lacks k_thread_runtime_stats_is_enabled, which makes the entire function impossible to implement safely. It is necessary.
..