Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: Initial version of IPC4 tx message logger using eBPF #1205

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ujfalusi
Copy link
Contributor

@ujfalusi ujfalusi commented Jun 7, 2024

The bpftrace script will tap into the entry of sof_ipc4_log_header() which is always called but only prints if dynamic debugging is enabled. It's parameter list is not expected to be changed.

The bpftrace must be installed to be able to use the script
sudo pacman -S bpftrace
sudo emerge -a bpftrace
sudo apt install bpftrace
sudo dnf install bpftrace

To use the script:
sudo ./tools/sof-ipc4-msg-trace.bt
or
sudo bpftrace tools/sof-ipc4-msg-trace.bt

It will start logging the sent messages (including payloads) and received notification with exception of 0x1b060000 - trace update.

To stop the logging, just terminate the script with CTRL+C

Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

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

I don't know BPF but this seems readable so LGTM. Some kernel developer should review.

Could you move this to a new subdirectory? The tools/ directory (one of the common, meaningless names...) is getting too crowded. How about tools/BPF/ipc4-msg-trace.bt? We already know it's SOF from the repo name.

@marc-hb
Copy link
Collaborator

marc-hb commented Jun 7, 2024

To use the script: ...

Perfect for a ipc4-msg.trace.bt section in a new tools/BPF/README.rst

@ujfalusi ujfalusi force-pushed the peter/pr/add-ipclogging-bpftrace-script-01 branch from ce80292 to 6a574da Compare June 10, 2024 06:03
@ujfalusi
Copy link
Contributor Author

Changes since v1:

  • script moved as tools/BPF/ipc4-msg-trace.bt
  • Readme file added

@ujfalusi ujfalusi force-pushed the peter/pr/add-ipclogging-bpftrace-script-01 branch from 6a574da to 61031d7 Compare June 10, 2024 08:55
@ujfalusi
Copy link
Contributor Author

Changes since v2:

  • Update the README.md file for the eBPF directory

Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

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

Someone else must review the actual BPF code

@marc-hb
Copy link
Collaborator

marc-hb commented Jun 10, 2024

"Big string" support submitted:

@marc-hb
Copy link
Collaborator

marc-hb commented Jun 12, 2024

"Big string" support submitted:

bpftrace/bpftrace#3228

Merged.

@ujfalusi
Copy link
Contributor Author

"Big string" support submitted:

* [Support big strings bpftrace/bpftrace#3228](https://github.com/bpftrace/bpftrace/pull/3228)

Thanks for the heads up.

I think the big string is still short for us (payload can be 4096 bytes) and the bigstring (if I read it right) tops at 1024.
I also prefer to have 'configurable' line length.
We certainly need to keep eye on bpftrace now to see what new features it is bringing for us to use.

@marc-hb
Copy link
Collaborator

marc-hb commented Jun 17, 2024

Someone else must review the actual BPF code

Ping?

PS: LNL had a very bad day on June 10th, let's run things again even if this script is not used anywhere yet.
https://sof-ci.01.org/softestpr/PR1205/build498/devicetest/index.html

@marc-hb
Copy link
Collaborator

marc-hb commented Jun 17, 2024

SOFCI TEST

@ujfalusi ujfalusi force-pushed the peter/pr/add-ipclogging-bpftrace-script-01 branch from 61031d7 to 7800e11 Compare July 15, 2024 08:51
@ujfalusi
Copy link
Contributor Author

Changes since v3:

  • Change the payload dump from bytes to 32bit words to align with kernel format and for easier handling
  • Update the README to note that some distros only have old version of bpftrace.

@ujfalusi ujfalusi force-pushed the peter/pr/add-ipclogging-bpftrace-script-01 branch from 7800e11 to 2013acb Compare July 16, 2024 05:39
The ipc4-msg-trace.bt script will tap into the entry of
sof_ipc4_log_header() which is always called but only prints if dynamic
debugging is enabled. It's parameter list is not expected to be changed.

The bpftrace must be installed to be able to use the script
sudo pacman -S bpftrace
sudo emerge -a bpftrace
sudo apt install bpftrace
sudo dnf install bpftrace

To use the script:
sudo ./tools/sof-ipc4-msg-trace.bt
or
sudo bpftrace tools/sof-ipc4-msg-trace.bt

It will start logging the sent messages (including payloads) and received
notification with exception of 0x1b060000 - trace update.

To stop the logging, just terminate the script with CTRL+C

Signed-off-by: Peter Ujfalusi <[email protected]>
@ujfalusi
Copy link
Contributor Author

Changes since v4:

  • readability cleanup, no functional change

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.

2 participants