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

Reorg to factor mac entries setup and add a max entries test #2587

Merged
merged 4 commits into from
Jul 1, 2024

Conversation

olsajiri
Copy link
Contributor

@olsajiri olsajiri commented Jun 19, 2024

centralizing map entries configuration and adding tests

@olsajiri olsajiri added the release-note/minor This PR introduces a minor user-visible change label Jun 19, 2024
Copy link
Member

@mtardy mtardy left a comment

Choose a reason for hiding this comment

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

thanks! Yeah the hasMaps make sense, especially for fdinstall. In the singleKprobe part it looks a bit weird that we copy the info in this when it's available on the genericKprobe directly but overall with the multi_kprobe, it's better than this lonely fdinstall bool.

Thanks a lot for the test, I wanted to write something similar to check that those memory patch aren't broken! That's really cool :)

maybe we could document in this hasMap struct which are per kprobe and which are per sensor?

@@ -272,14 +272,12 @@ func filterMaps(load *program.Program, pinPath string, kprobeEntry *genericKprob
return maps
}

func createMultiKprobeSensor(sensorPath, policyName string, multiIDs []idtable.EntryID, enableFDInstall bool) ([]*program.Program, []*program.Map, error) {
func createMultiKprobeSensor(sensorPath, policyName string, multiIDs []idtable.EntryID, has *hasMaps) ([]*program.Program, []*program.Map, error) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe I would pass this by value for clarity that it's read only

Comment on lines 563 to 574
has.fdInstall = has.fdInstall || selectorsHaveFDInstall(kprobe.Selectors)
if has.fdInstall {
break
}
Copy link
Member

Choose a reason for hiding this comment

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

you could simplify it, we can always modify if this gets more complicated later

Suggested change
has.fdInstall = has.fdInstall || selectorsHaveFDInstall(kprobe.Selectors)
if has.fdInstall {
break
}
if selectorsHaveFDInstall(kprobe.Selectors) {
has.fdInstall = true
break
}

or

Suggested change
has.fdInstall = has.fdInstall || selectorsHaveFDInstall(kprobe.Selectors)
if has.fdInstall {
break
}
if selectorsHaveFDInstall(kprobe.Selectors) {
return &hasMap{
fdInstall: true,
}
}

Copy link

netlify bot commented Jun 20, 2024

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit 20f86f7
🔍 Latest deploy log https://app.netlify.com/sites/tetragon/deploys/667c0a6222b1c100085c57c8
😎 Deploy Preview https://deploy-preview-2587--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mtardy mtardy self-requested a review June 20, 2024 10:18
Copy link
Member

@mtardy mtardy left a comment

Choose a reason for hiding this comment

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

Thanks! lgtm

@mtardy mtardy changed the title Pr/olsajiri/entries Reorg to factor mac entries setup and add a max entries test Jun 21, 2024
Pass spec pointer directly to createGenericTracepointSensor,
it will make following changes easier.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Centralizing maps 'has' config into hasMaps object,
which gets initialized before we create the sensor
and checked when we create sensor maps.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
We need enforcer map only when enforcer is configured, so making
the map entries by default 1 and resizing it when it's needed.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
@olsajiri olsajiri force-pushed the pr/olsajiri/entries branch 3 times, most recently from 24920e3 to e1b5c16 Compare June 26, 2024 20:34
Adding max entries test for all maps that are resized
based on configuration.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
@olsajiri olsajiri marked this pull request as ready for review June 27, 2024 11:14
@olsajiri olsajiri requested a review from a team as a code owner June 27, 2024 11:14
@olsajiri olsajiri requested review from jrfastab and kkourt June 27, 2024 11:14
Copy link
Member

@mtardy mtardy left a comment

Choose a reason for hiding this comment

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

yep still like it!

@olsajiri olsajiri merged commit d63d828 into main Jul 1, 2024
45 checks passed
@olsajiri olsajiri deleted the pr/olsajiri/entries branch July 1, 2024 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/minor This PR introduces a minor user-visible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants