Visitar URL original
bpf: leverage map registry to configure and create metrics map by ekoops · Pull Request #50000 · cilium/cilium · GitHub
Skip to content

bpf: leverage map registry to configure and create metrics map - #50000

Open
ekoops wants to merge 3 commits into
cilium:mainfrom
ekoops:ekoops/metrics-map-size
Open

ekoops wants to merge 3 commits into
cilium:mainfrom
ekoops:ekoops/metrics-map-size

Conversation

@ekoops

@ekoops ekoops commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

This lets us get rid of the corresponding METRICS_MAP_SIZE C macro that used to represent the number of max entries for cilium_metrics.

Map flags are configured by leveraging the MapRegistry.Modify() API, while the number of max entries is left untouched, as the base map spec (baked into maps_generated.go, and generated from map's datapath definition) already stores the right value (1024).

Notice that the metricsMap type now embeds a *bpf.Map instead of *ebpf.Map.

Finally, notice that the original static value for METRICS_MAP_SIZE was 65536, but the agent has always set it to 1024 at runtime (see metricsmap.MaxEntries) ignoring the stale static value (that value became stale after 321b147cba33 got merged). For this reason, I changed the map definition to use 1024 instead of 65536.

Related: #48853

AIL: 0

@ekoops
ekoops requested review from a team as code owners November 12, 2026 16:38
@maintainer-s-little-helper maintainer-s-little-helper Bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Nov 12, 2026
@ekoops

This comment has been minimized.

@squeed

squeed commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Congratulations on an auspicious PR number :)

@andreaterzolo andreaterzolo mentioned this pull request Nov 12, 2026
9 of 36 tasks
@ekoops
ekoops force-pushed the ekoops/metrics-map-size branch from e4c9fbc to f9ec2de Compare November 13, 2026 09:19
@ekoops

This comment has been minimized.

@ekoops

This comment has been minimized.

@sayboras

Copy link
Copy Markdown
Member

I come here for 50k PRs 🕺

@dylandreimerink dylandreimerink added release-note/misc This PR makes changes that have no direct user impact. ail:0 Human Created, No AI Involved. labels Nov 13, 2026
@maintainer-s-little-helper maintainer-s-little-helper Bot removed dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. labels Nov 13, 2026
@ekoops

ekoops commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

/test

This required changing the `MetricsMap` interface to provide a
`DeleteAll()` method instead of a `Delete(key)` one: indeed `Delete()`
was used inside the callback provided to `IterateWithCallback()`, and
the new `IterateWithCallback()` implementation holds a read lock over
the map for the entire iteration procedure, so calling `Delete()` in
the callback would have caused a dead-lock.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
`cilium_metrics` max_entries is set to `METRICS_MAP_SIZE`. The agent
generates that macro from `metricsmap.MaxEntries` (1024), so the
datapath map has been created with 1024 entries at runtime since
321b147
("metricsmap: reduce MaxEntries to account for maximum key space").
Only the static value in `bpf/node_config.h` was left at 65536. That
value is the one used by static builds (e.g. the BPF tests) and baked
into `maps_generated.go`, which the map registry uses as the base spec
of the map.

Set the static value to 1024 and regenerate `maps_generated.go`, so
that the static definition matches the one used at runtime. No
functional change for the agent.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
This lets us get rid of the corresponding `METRICS_MAP_SIZE` C macro
that used to represent the number of max entries for `cilium_metrics`.

Map flags are configured by leveraging the `MapRegistry.Modify()` API,
while the number of max entries is left untouched, as the base map
spec (baked into `maps_generated.go`, and generated from map's datapath
definition) already stores the right value (1024).

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
@ekoops
ekoops force-pushed the ekoops/metrics-map-size branch from fa9e5a4 to 7986409 Compare November 13, 2026 13:45
@ekoops

This comment has been minimized.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ail:0 Human Created, No AI Involved. release-note/misc This PR makes changes that have no direct user impact.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants