Skip to content

Conversation

@kyledong-suse
Copy link
Contributor

@kyledong-suse kyledong-suse commented Nov 13, 2025

Description

This commit adds support for controlling the BPF_F_NO_PREALLOC flag on BPF maps through CLI flags. Users can now disable preallocation globally or for specific maps to reduce memory usage.

Fixes: #4249

@kyledong-suse kyledong-suse requested a review from a team as a code owner November 13, 2025 16:50
@kyledong-suse kyledong-suse requested a review from FedeDP November 13, 2025 16:50
@kkourt kkourt added the release-note/minor This PR introduces a minor user-visible change label Nov 17, 2025
@netlify
Copy link

netlify bot commented Nov 17, 2025

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit 5d5bd6e
🔍 Latest deploy log https://app.netlify.com/projects/tetragon/deploys/69437d4817685e0008b2d054
😎 Deploy Preview https://deploy-preview-4340--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 project configuration.

@kyledong-suse kyledong-suse force-pushed the pr/kyledong-suse/optimize-inner-policy-maps-memory-usage branch from 24d75a6 to 100c6e6 Compare November 17, 2025 15:38
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.

Looks fine to me but let's see if that would be better to have a global flag instead of a per map flag for NO_PREALLOC disable since you mentioned another map in the issue. I'm really not sure which one is best 🤔

We could even extend this flag to the map we already have using no_prealloc, but maybe that's too much for this patch set and out of scope!

@kyledong-suse
Copy link
Contributor Author

Thanks for taking time to review this PR @mtardy!
Let's wait @kkourt for his comment about this idea.
If you all agree to have a generic flag to enable/disable BPF_F_NO_PREALLOC, I can modify the title of the issue as well as this PR and commit messages.

@kyledong-suse kyledong-suse force-pushed the pr/kyledong-suse/optimize-inner-policy-maps-memory-usage branch from 100c6e6 to 7bdfbdf Compare November 30, 2025 21:01
@kyledong-suse kyledong-suse changed the title pkg/policyfilter: optimize inner policy maps memory usage tetragon/pkg: add user-configurable BPF_F_NO_PREALLOC flag support Nov 30, 2025
@kyledong-suse kyledong-suse force-pushed the pr/kyledong-suse/optimize-inner-policy-maps-memory-usage branch 3 times, most recently from 780db2d to a34a05e Compare December 1, 2025 02:50
@olsajiri olsajiri self-requested a review December 1, 2025 10:00
@mtardy
Copy link
Member

mtardy commented Dec 1, 2025

is it ready for re-review @kyledong-suse ? :)

@kyledong-suse
Copy link
Contributor Author

@mtardy @kkourt I have modified the implementation regarding to the discussion in #4249
It's ready for re-review. Thanks!

@mtardy mtardy self-requested a review December 1, 2025 14:40
Copy link
Contributor

@olsajiri olsajiri left a comment

Choose a reason for hiding this comment

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

heya, looks good, left some comments

I need to check the issue properly, but did we discuss performance implications? I guess policy_filter_maps is fine, I'm not sure override_task is that straight forward

thanks

@kyledong-suse
Copy link
Contributor Author

I need to check the issue properly, but did we discuss performance implications? I guess policy_filter_maps is fine, I'm not sure override_task is that straight forward

It has been discussed a bit in the issue. Additionally, #4204 proposed an idea to use shared override_task map, which will optimize both memory utilization and CPU consumption.

@kyledong-suse kyledong-suse force-pushed the pr/kyledong-suse/optimize-inner-policy-maps-memory-usage branch from a34a05e to 9438ba6 Compare December 18, 2025 03:56
This commit adds support for controlling the BPF_F_NO_PREALLOC flag
on BPF maps through CLI flags. Users can now disable preallocation
globally or for specific maps to reduce memory usage.

Fixes: cilium#4249
Signed-off-by: Kyle Dong <[email protected]>
@kyledong-suse kyledong-suse force-pushed the pr/kyledong-suse/optimize-inner-policy-maps-memory-usage branch from 9438ba6 to 5d5bd6e Compare December 18, 2025 04:04
@olsajiri
Copy link
Contributor

olsajiri commented Jan 2, 2026

@kyledong-suse I think it's ok, I have one more idea for the code, please check 4705b87

  • let's mark program.Map object with SetNoPreAlloc when we allow to use BPF_F_NO_PREALLOC, like:
    overrideTasksMap := program.MapBuilderProgram("override_tasks", load).SetNoPreAlloc()
  • perhaps GetPreallocFlags could have generic name, maybe just Flags ?
  • I think we should change pkg/policyfilter to use program.Map object, so we do not have separate BPF_F_NO_PREALLOC code in there, but that can be follow up, meanwhile just move the BPF_F_NO_PREALLOC setup in single function please check 4705b87

just to make sure I understand the options semantics.. we either enable no-prealloc for all allowed maps (via SetNoPreAlloc) with --bpf-maps-prealloc=false or specificaly enable separated maps with --bpf-maps-disable-prealloc=map1,map2..

@kkourt kkourt self-requested a review January 6, 2026 13:16
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.

Optimize BPF maps with BPF_F_NO_PREALLOC to reduce memory usage

4 participants