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

Untangle the section id, factories and modules #421

Merged
merged 9 commits into from
Oct 7, 2024

Conversation

atenart
Copy link
Contributor

@atenart atenart commented Aug 12, 2024

Semi-RFC material; since code is ready let's not flag it but feel free to discuss the approach :)

The main goal of this series is $title, and some preliminary work for a possible future removal of the module concept. In any way this solve issues linked to how the section ids were used which did not map to the reality:

  • Factories are tied to a BPF counterpart, not to an event section. Eg. the tracking section is generated at post-processing time and does not have any link to the BPF side.
  • Modules are not strictly tied to event sections. Eg. all core sections do not have a corresponding module.
  • Factories and modules are not in a 1:1 relationship. Eg. core factories are not in a module.

This also now allows to have a factory producing more than a single type of event section; this is no side effect and is intended.

Overall this was something I wanted to tackle for some time now, but I was keeping it for later. But adding support for enum sk_rst_reason showed w/o this preliminary rework things would have gotten even worse between event sections, factories and modules. This is why I chose to keep those patches in that PR; but I can split into two PRs if needed.

One question I have is with the last commit: should be put all those "common types" into the same event section or add one for each. Having a dedicated section helps for possible future improvement (more fields when applicable), but makes event section count to potentially grow quite a lot. Also I should find a better name instead of "common types".

@atenart atenart added the run-functional-tests Request functional tests to be run by CI label Aug 12, 2024
@atenart
Copy link
Contributor Author

atenart commented Aug 12, 2024

Again we have a failure due to benchmarking being so difficult to maintain. I'm not going to fix this here as we have #412; so let's merge it first.

retis-events/src/ct.rs Outdated Show resolved Hide resolved
retis-derive/src/lib.rs Show resolved Hide resolved
retis/src/core/probe/kernel/bpf/include/common.h Outdated Show resolved Hide resolved
@amorenoz
Copy link
Contributor

Mainly I have comments on the last two patches. For the code refactorization, besides nits, it looks great to me and I think it goes in the right direction of getting rid of the module abstraction.

@atenart
Copy link
Contributor Author

atenart commented Sep 26, 2024

Rebased on top of #411 (as it seems to be ready) to avoid conflicts and removed the common type commits from this. I'll open a dedicated PR and we can have the discussion about those there.

@atenart
Copy link
Contributor Author

atenart commented Sep 26, 2024

Same CI error as the others, this week our running CI can't work.

@atenart
Copy link
Contributor Author

atenart commented Sep 26, 2024

Removed the same commit as in #411.

@atenart
Copy link
Contributor Author

atenart commented Sep 26, 2024

The benchmarking CI is actually failing for a good reason; will have a look.

@atenart
Copy link
Contributor Author

atenart commented Sep 26, 2024

All good now.

retis-derive/src/lib.rs Outdated Show resolved Hide resolved
amorenoz
amorenoz previously approved these changes Sep 30, 2024
Copy link
Contributor

@amorenoz amorenoz left a comment

Choose a reason for hiding this comment

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

Leaving a nit aside, the PR LGTM.

@atenart
Copy link
Contributor Author

atenart commented Oct 1, 2024

Renamed section/factory_id() helpers into id().

@atenart atenart added this to the v1.5 milestone Oct 2, 2024
Since commit 2373796 ("events: split ebpf and json factories")
raw factories are only parsing and converting raw events, aka BPF ones.
Thus we no longer have to differentiate the user of such factories and
can make raw factory implementations cleaner.

Signed-off-by: Antoine Tenart <[email protected]>
This makes modules not required to produce events, as they can provide
value by doing other scoped work (eg. installing probes).

This shows again the limits of our module abstraction and it might be
removed at some point to clean things up a bit.

Signed-off-by: Antoine Tenart <[email protected]>
SectionId member can be directly casted as u8, there's no need to
maintain an helper doing so.

Signed-off-by: Antoine Tenart <[email protected]>
We no longer have a need to split both definitions, EventSection is
never used outside of event_section.

Signed-off-by: Antoine Tenart <[email protected]>
Those two were loosely tightened, when adding sub-sections to an event.
Even more, the section names where both defined in the event sections
and in the section ids.

As there should be a 1:1 relationship between event sections and ids,
make the id part of the event section.

This has another advantage as a side effect: raw section factories do
not need a 1:1 relationship with an event section and can generate any
event section.

Signed-off-by: Antoine Tenart <[email protected]>
Stop using SectionId for indexing event section factories; those are
tied to a BPF counterpart, not to a section id. This helps modelizing
that a factory can produce different sections and that a section does
not necessarily have a BPF counterpart, such as the Tracking one.

To do this use a dedicated FactoryId enum instead of reusing SectionId
and use a similar logic as what we do for event sections (eg. embed the
id into the factory definition).

While doing this we can remove the TrackingInfoEventFactory.

Signed-off-by: Antoine Tenart <[email protected]>
Stop using SectionId for indexing modules (aka. collectors nowadays);
there is no 1:1 relationship between the two. Eg. core events are not
tied to a module.

To to this introduce a ModuleId enum. Hopefully this will go away once
we remove the module abstraction.

Signed-off-by: Antoine Tenart <[email protected]>
Cosmetic only.

Signed-off-by: Antoine Tenart <[email protected]>
@atenart
Copy link
Contributor Author

atenart commented Oct 4, 2024

Rebased on top of main to fix a conflict. No other change.

@amorenoz amorenoz merged commit 77b303a into main Oct 7, 2024
5 of 9 checks passed
@amorenoz amorenoz deleted the at/section-id-untangle branch October 7, 2024 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-functional-tests Request functional tests to be run by CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants