Skip to content

Conversation

@gnurizen
Copy link
Collaborator

@gnurizen gnurizen commented Feb 14, 2025

This saves 2MB of map memory.

Make labels key length 16 instead of 64 bytes. Make value length 48
instead of 64. Make max custom labels 10. This keeps space added
to trace structure to 640 bytes.

Don't store key/value length, just copy MAX-1 bytes and rely on things
being null terminated.

@gnurizen gnurizen changed the title rem hash Remove custom labels hash and write directly to Trace Feb 14, 2025
@gnurizen gnurizen requested a review from umanwizard February 14, 2025 21:52
@gnurizen gnurizen requested a review from brancz February 19, 2025 19:51
CustomLabel *lbl = &out->labels[out->len];
if (map_value->keys[i].str != NULL) {
long res = bpf_probe_read_user(lbl->key.key_bytes, CUSTOM_LABEL_MAX_KEY_LEN, map_value->keys[i].str);
unsigned klen = MIN(map_value->keys[i].len, CUSTOM_LABEL_MAX_KEY_LEN-1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the -1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since I removed the len I need to leave a character for the null terminator.

@gnurizen gnurizen force-pushed the rem-hash branch 2 times, most recently from 07fd31d to 4fc9887 Compare February 22, 2025 20:47
Put go label collection in a separate unwinder routine and tail call it.

Native unwinder and other custom labels code stays in unwind_stop.

Hand unroll loops and great simplify the hash function.

Reduce number of custom labels from 16 to 14.

Remove opaquify.h, fix verifier errors by moving code around.

Add a simple integration test for custom labels that runs against all
kernels.

Refactor test code to put shared code in a helper package.
@gnurizen gnurizen merged commit b79cb38 into main Feb 24, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants