Skip to content

Show multiple user PF's in the output#3

Open
damiandsap wants to merge 1 commit intoDispatchCode:mainfrom
damiandsap:main
Open

Show multiple user PF's in the output#3
damiandsap wants to merge 1 commit intoDispatchCode:mainfrom
damiandsap:main

Conversation

@damiandsap
Copy link

No description provided.

@damiandsap damiandsap force-pushed the main branch 2 times, most recently from 9e2dde9 to adb47a7 Compare February 24, 2026 13:28
@damiandsap damiandsap marked this pull request as ready for review February 24, 2026 13:39
@damiandsap damiandsap force-pushed the main branch 5 times, most recently from dbd19c0 to 6c07d5c Compare February 24, 2026 14:57
bpf_map_delete_elem(&tgid_cr2, &tgid);
event->pf_count = 0;
#ifdef TRACE_PF_CR2
u32 tgid = task->tgid;
Copy link
Contributor

@work-robot work-robot Feb 25, 2026

Choose a reason for hiding this comment

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

I'm not sure if we should use the process ID (tgid) or rather the thread ID (pid) for the key of the map... on the one hand, the map can be smaller. On the other hand, we'd need to record which thread has generated the PF, and we might rotate through the ring buffer to quickly.

I'm also not sure if we'd need to use some form of locking if multiple threads can write into the ring buffer.

Copy link
Contributor

@work-robot work-robot Feb 25, 2026

Choose a reason for hiding this comment

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

Yeah we'd need locking: https://docs.ebpf.io/linux/helper-function/bpf_map_lookup_elem/
I just don't know if per-thread would be sufficient, or if we'd need per-CPU.


// By default is commented: a lot of #PF events are hit
// so enable only if it is acceptable.
// #define TRACE_PF_CR2
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should enable this, since it doesn't seem to have much of a performance impact.



#define MAX_LBR_ENTRIES 32
#define MAX_USER_PF_ENTRIES 16
Copy link
Contributor

Choose a reason for hiding this comment

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

16 is fine if the ring buffer is for a single thread, but I fear that with dozens of threads, there might be too many PF, so any interesting one might be rotated out by the time we land in signal_generate. But due to the locking requirement (see my comment in the .bpf.c file) I think we should split this into a per-thread data structure (or per-CPU but while recording the pid, not sure...).

Copy link
Contributor

@work-robot work-robot left a comment

Choose a reason for hiding this comment

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

We need to use a finer-granular key for the PF map, due to race conditions.

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