You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE] Switch implementation of IPC payload dump to Linux BPF #1201
Today a question was raised: should this BPF script be hosted in sof-test.git or sof.git?
The most important point to consider for any test code is: how tightly coupled with production code is it? If tightly coupled (e.g.: unit tests), then the test code should live in the same repo, otherwise there will be mismatches and breakages all the time. If very loose then it should live in the separate sof-test.git for flexibility.
The best litmus test is: imagine you're bisecting sof.git. Would you rather this BPF script to downgrade and upgrade at the same time you're bisecting sof? Or not? Which is the more likely? Same idea with branching, rebasing, cherry-picking etc.
As IPC4 is a very stable API, I'm guessing this BPF script should live in sof-test?
My take is that BPF can provide access to lots of Linux kernel functions, and as such isn't guaranteed to be stable over time. Bisecting with BPF may or may not be possible between different Linux versions.
That means that if/when there are changes to the kernel, the scripts shall be updated.
We have similar issues with kmod scripts, the names of modules and the list of modules may change over time.
@plbossart, I agree that there is a risk of kernel change breaking the BPF script, I'm proposing to tap on the sof_ipc4_log_header() which is not expected to change (famous last words?).
We can only get the TX message payloads reliably, I'm not sure if there is a way around to get the reply and I don't plan to decode the notification payload.
For the reply payload we might be able to use kretprobe with saving pointer in kprope and then using that to print the received reply payload, but I have not tried that and I find that a bit more risky than the send IPC message traffic.
BPF scripts are not part of the kernel tree. Ideally we should have 'trampolines' (iow, stable BPF entries) for proper support then the scripts could be part of sof-bin package.
But we are not planning to support BPF officially and this script is for developers/CI only.
We can also just see how things work with the dmesg dumping...
I don't think there's a better proposal than using sof-test for those BPF scripts, so unless there's a sustained objection let's go with that direction.
We can also just see how things work with the dmesg dumping...
Even if the current script above is just a "works4me" and does not end up being used, it is still better placed in sof-test.git than in a discussion comment.
It's not like sof-test.git has "coverage" requirement for everything in it, pretty far from that. The bar is of course higher for code that is used every day but it is low for demos and prototypes.
How about sof-test/BPFTrace/IPClogs.bpf ? OR something like it.
changed the title [-][FEATURE] Switch IPC payload dump to Linux BPF[/-][+][FEATURE] Switch implementation of IPC payload dump to Linux BPF[/+]on Aug 13, 2024
Activity
ujfalusi commentedon May 31, 2024
for the record, the bpf script to capture the tx IPC messages with payload (the rx trace position update message is ignored):
the log:
marc-hb commentedon Jun 5, 2024
Today a question was raised: should this BPF script be hosted in sof-test.git or sof.git?
The most important point to consider for any test code is: how tightly coupled with production code is it? If tightly coupled (e.g.: unit tests), then the test code should live in the same repo, otherwise there will be mismatches and breakages all the time. If very loose then it should live in the separate sof-test.git for flexibility.
The best litmus test is: imagine you're bisecting sof.git. Would you rather this BPF script to downgrade and upgrade at the same time you're bisecting sof? Or not? Which is the more likely? Same idea with branching, rebasing, cherry-picking etc.
As IPC4 is a very stable API, I'm guessing this BPF script should live in sof-test?
plbossart commentedon Jun 6, 2024
My take is that BPF can provide access to lots of Linux kernel functions, and as such isn't guaranteed to be stable over time. Bisecting with BPF may or may not be possible between different Linux versions.
https://lwn.net/Articles/921088/
That means that if/when there are changes to the kernel, the scripts shall be updated.
We have similar issues with kmod scripts, the names of modules and the list of modules may change over time.
ujfalusi commentedon Jun 6, 2024
@plbossart, I agree that there is a risk of kernel change breaking the BPF script, I'm proposing to tap on the
sof_ipc4_log_header()which is not expected to change (famous last words?).We can only get the TX message payloads reliably, I'm not sure if there is a way around to get the reply and I don't plan to decode the notification payload.
For the reply payload we might be able to use
kretprobewith saving pointer inkpropeand then using that to print the received reply payload, but I have not tried that and I find that a bit more risky than the send IPC message traffic.marc-hb commentedon Jun 6, 2024
Then the ideal git repo for the BPF script would be the kernel repo; that's the one it's most tightly coupled with. But that's not possible because https://thesofproject.github.io/latest/contribute/linux/development_tree.html#development-summary
So is there a "second best" between sof-test.git and sof.git? Maybe not. Maybe they are both equally inferior.
ujfalusi commentedon Jun 7, 2024
BPF scripts are not part of the kernel tree. Ideally we should have 'trampolines' (iow, stable BPF entries) for proper support then the scripts could be part of sof-bin package.
But we are not planning to support BPF officially and this script is for developers/CI only.
We can also just see how things work with the dmesg dumping...
plbossart commentedon Jun 7, 2024
I don't think there's a better proposal than using sof-test for those BPF scripts, so unless there's a sustained objection let's go with that direction.
ujfalusi commentedon Jun 7, 2024
The initial script: #1205
marc-hb commentedon Jun 7, 2024
Even if the current script above is just a "works4me" and does not end up being used, it is still better placed in sof-test.git than in a discussion comment.
It's not like sof-test.git has "coverage" requirement for everything in it, pretty far from that. The bar is of course higher for code that is used every day but it is low for demos and prototypes.
How about
sof-test/BPFTrace/IPClogs.bpf? OR something like it.[-][FEATURE] Implement IPC payload dump with BFP in sof-test[/-][+][FEATURE] Switch IPC payload dump to BPF[/+][-][FEATURE] Switch IPC payload dump to BPF[/-][+][FEATURE] Switch IPC payload dump to Linux BPF[/+][-][FEATURE] Switch IPC payload dump to Linux BPF[/-][+][FEATURE] Switch implementation of IPC payload dump to Linux BPF[/+]