Skip to content
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

Introducing Object Cores #59075

Merged
merged 14 commits into from Sep 30, 2023
Merged

Conversation

peter-mitsis
Copy link
Collaborator

Introducing object cores in response to #57672.

Zephyr objects can have a special structure embedded within them (an object core). Zephyr objects of the same type are linked together through this object core. Additional functionality can be linked to the object core (such as statistics tracking). This can then provide a uniform means to access that additional functionality without needing to develop many custom interfaces. In the case of object cores, debugging tools can walk the object lists and obtain information about the objects.

The current iteration of object cores is quite minimal. The have a list node, a back pointer to the object type list of which it is a part, and an optional pointer to "raw" stats information. The object type contains a list node (linking different object types together), a list of all linked zephyr objects of that type, an ID and obj_core offset (to be leveraged by debugging tools to be able to identify and easily find relevant data of the object type), and an optional pointer to the a statistics descriptor.

Basic statistics operations include getting raw stats data, cooked stats data, resetting, enabling and disabling stats gathering. Not all functionality is required to be implemented--only what makes sense for the object.

@nashif
Copy link
Member

nashif commented Jun 8, 2023

documentation? :-)

@peter-mitsis
Copy link
Collaborator Author

Documentation? Gah! I knew I had to be forgetting something.

Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some notes. Mostly this seems reasonable. It would definitely good to see the patch ordering cleaned up for bisectability reasons.

I will say that I'm a little confused about how the stats framework is intended to work. Mostly I'd imagine "stats" to look like a per-type struct with fields that the type uses directly, like an set of atomic counts or a "last event time" value or whatever. And each type would then expose those stats for analysis via a "here's my stats" API of its own. Instead it looks like everyone is supposed to copy all the stats at once for every object in an opaque blob? What's the advantage there?

include/zephyr/kernel/obj_core.h Outdated Show resolved Hide resolved
include/zephyr/kernel/obj_core.h Outdated Show resolved Hide resolved
include/zephyr/kernel/obj_core.h Outdated Show resolved Hide resolved
include/zephyr/kernel/obj_core.h Outdated Show resolved Hide resolved
include/zephyr/kernel/obj_core.h Outdated Show resolved Hide resolved
include/zephyr/kernel/obj_core.h Outdated Show resolved Hide resolved
include/zephyr/kernel/obj_core.h Outdated Show resolved Hide resolved
include/zephyr/kernel/obj_core.h Show resolved Hide resolved
include/zephyr/kernel/obj_core.h Outdated Show resolved Hide resolved
kernel/Kconfig Show resolved Hide resolved
@peter-mitsis peter-mitsis force-pushed the pmitsis-obj_core branch 4 times, most recently from 6187e1d to 7f5ad9e Compare June 12, 2023 17:43
Adds the infrastructure to integrate statistics into
the object core.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
Integrates object core statistics framework into the following
kernel objects:
  sys_mem_blocks, k_mem_slab
  threads, _cpu, z_kernel

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
Creates a test to verify that kernel objects can be found within
the object core framework.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
Creates a set of tests to verify that the top-level
k_obj_core_stats_xxx() routines behave as expected.
Note that this test is not meant to test the details
of the object core statistics operator function pointers.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
Adds a test to test the objects integrated into the object core
statistics framework.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
Adds documentation for both object cores and object core statistics.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
Changing the name of the routine test_obj_core_stats_deregister()
to something shorter (test_obj_core_stats_dereg) has been found to
be a workaround to the issue identified in zephyrproject-rtos#61087.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
@peter-mitsis
Copy link
Collaborator Author

Needed to fix a build issue stemming from the use of z_current_get() instead of k_current_get(). (A recent commit renamed z_current_get).

teburd
teburd previously approved these changes Sep 29, 2023
Copy link
Collaborator

@teburd teburd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a neat feature. The docs page does an excellent job explaining the idea and layout.

PR looks great.

jhedberg
jhedberg previously approved these changes Sep 29, 2023
@peter-mitsis peter-mitsis dismissed stale reviews from jhedberg and teburd via 6ee558a September 29, 2023 15:38
@zephyrbot zephyrbot added manifest manifest-percepio DNM This PR should not be merged (Do Not Merge) labels Sep 29, 2023
@zephyrbot
Copy link
Collaborator

zephyrbot commented Sep 29, 2023

The following west manifest projects have been modified in this Pull Request:

Name Old Revision New Revision Diff
percepio zephyrproject-rtos/percepio@7ba53eb zephyrproject-rtos/percepio@7224483 (zephyr) zephyrproject-rtos/percepio@7ba53eb1..72244836

Note: This message is automatically posted and updated by the Manifest GitHub Action.

Pulls in the latest percepio module updates that alter how it
accesses the k_mem_slab structure (due to changes from this PR).

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
@zephyrbot zephyrbot removed the DNM This PR should not be merged (Do Not Merge) label Sep 29, 2023
@nashif
Copy link
Member

nashif commented Sep 30, 2023

@jhedberg andyross already approved that earlier, please take this into 3.5 :)

Copy link
Collaborator

@kartben kartben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for docs

@jhedberg jhedberg merged commit a956f7a into zephyrproject-rtos:main Sep 30, 2023
31 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

10 participants