Skip to content

Conversation

lmb
Copy link
Collaborator

@lmb lmb commented Jul 2, 2024

ci: fix golangci-lint

For some reason the Action decided to break now, after being updated a
couple of weeks ago.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>

program, btf: probe correct log buffer size

The kernel exposes a log of operations to aid debugging a program or BTF
load. Until recently there was no way to know the size of that buffer, so
the library forces the user to specify a buffer size. From a cursory survey
on sourcegraph.com it seems that users either hardcode a large fixed buffer
or probe the correct size by doubling the buffer size when hitting ENOSPC.

Since commit 47a71c1f9af0 ("bpf: Add log_true_size output field to return
necessary log buffer size") the kernel does provide a hint to user space.

Move probing of the correct log buffer size into the library. On recent (>=
6.4) kernels this is guaranteed to work in a single call. On older kernels
we use the doubling strategy employed by cilium and tetragon.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>

@github-actions github-actions bot added the breaking-change Changes exported API label Jul 2, 2024
For some reason the Action decided to break now, after being updated
a couple of weeks ago.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
@lmb lmb force-pushed the prog-log-sizing branch 3 times, most recently from 0efaff5 to 7cfb785 Compare July 3, 2024 08:03
@lmb lmb marked this pull request as ready for review July 3, 2024 08:04
@lmb lmb requested review from dylandreimerink and a team as code owners July 3, 2024 08:04
Copy link
Member

@dylandreimerink dylandreimerink left a comment

Choose a reason for hiding this comment

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

LGTM other than the bit Florian already pointed out

The kernel exposes a log of operations to aid debugging a program
or BTF load. Until recently there was no way to know the size of
that buffer, so the library forces the user to specify a buffer
size. From a cursory survey on sourcegraph.com it seems that
users either hardcode a large fixed buffer or probe the correct
size by doubling the buffer size when hitting ENOSPC.

Since commit 47a71c1f9af0 ("bpf: Add log_true_size output field
to return necessary log buffer size") the kernel does provide a
hint to user space.

Move probing of the correct log buffer size into the library. On
recent (>= 6.4) kernels this is guaranteed to work in a single
call. On older kernels we use the doubling strategy employed by
cilium and tetragon.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Changes exported API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants