-
Notifications
You must be signed in to change notification settings - Fork 59
use journalctl as default kernel log reader #509
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
Changes from all commits
f7ca69f
e672e35
56d0d0f
cbe2bc4
cdeb363
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,12 @@ | ||
| #!/bin/bash | ||
| # | ||
| # read kernel log to get topology file loaded by SOF driver | ||
| # Example from an apl up2 pcm512x device: | ||
| # | ||
| # sof-audio-pci 0000:00:0e.0: loading topology:intel/sof-tplg/sof-apl-pcm512x.tplg | ||
| # | ||
| # sof-apl-pcm512x.tplg will be returned | ||
| # | ||
|
|
||
| # Current: load TPLG file order: | ||
| # dmesg | ||
| # journalctl | ||
| # /var/log/syslog (sof-kernel-dump.sh) | ||
| # Future: possibly be loaded from elsewhere | ||
| # Notice: Only verified on Ubuntu 18.04 | ||
| tplg_file=$(dmesg |grep -i topology|awk -F ':' '/tplg/ {print $NF;}'|tail -n 1) | ||
| [[ ! "$tplg_file" ]] && \ | ||
| tplg_file=$(journalctl -k |grep -i topology |awk -F ':' '/tplg/ {print $NF;}'|tail -n 1) | ||
| [[ ! "$tplg_file" ]] && \ | ||
| tplg_file=$(sof-kernel-dump.sh |grep -i topology|awk -F ':' '/tplg/ {print $NF;}'|tail -n 1) | ||
| tplg_file=$(journalctl -k |grep -i topology |awk -F ':' '/tplg/ {print $NF;}'|tail -n 1) | ||
xiulipan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| [[ "$tplg_file" ]] && basename "$tplg_file" || echo "" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -126,11 +126,14 @@ | |
| # Append some garbage to an ignore pattern to turn it off. Much easier | ||
| # than deleting it. | ||
|
|
||
|
|
||
| begin_line=${1:-1} | ||
| # fallback to use dmseg when set to 0. | ||
| # TODO: update the fallback option when drop dmesg | ||
| begin_timestamp=${1:-0} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I already submitted this in September in PR #366 but something was wrong at the time. Is it OK now and why?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because I drop the usage for line number now. And with my comments below We will always fallback to use demsg if no checkpoint is provided or wrong format checkpoint is provided
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The only user of this script is ourselves, so to reduce complexity a lot let's just fix the user instead of providing a fallback. Fail here when some test does not provide a valid checkpoint and then calls this script, which seems very wrong!? Let's fix all these broken tests and make them consistent before switching the checkpoint to journalctl
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we have an agreement in #468 (comment)
Now we have done half of the step 1 by changing the LINE into CHECKPOINT in #499. Now I am not sure if I can do clean up in step 4 before we change to use journalctl with use Or we can do something more simpler, merge a big PR #468 I have already made and tested and fix bugs if we find any. Any suggestions here @marc-hb @aiChaoSONG @plbossart @mengdonglin If we do not make progress before my vacation next week. I will use my super power to merge all the change in one PR. |
||
| declare err_str ignore_str | ||
|
|
||
| platform=$(sof-dump-status.py -p) | ||
| # pwd resolves relative paths | ||
| my_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
| platform=$("$my_dir"/sof-dump-status.py -p) | ||
|
|
||
| err_str="error|failed|timed out|panic|oops" | ||
|
|
||
|
|
@@ -250,32 +253,22 @@ case "$platform" in | |
| ;; | ||
| esac | ||
|
|
||
| [[ ! "$err_str" ]] && echo "Missing error keyword list" && exit 0 | ||
| # dmesg KB size buffer size | ||
| #dmesg_config_define=$(awk -F '=' '/CONFIG_LOG_BUF_SHIFT/ {print $2;}' /boot/config-$(uname -r)) | ||
| #dmesg_buffer_size=$( echo $(( (1<<$dmesg_config_define) / 1024 )) ) | ||
| # kernel file log buffer size | ||
| #kernel_buffer_size=$(du -k /var/log/kern.log |awk '{print $1;}') | ||
| # now decide using which to catch the kernel log | ||
| #[[ $kernel_buffer_size -lt $dmesg ]] && cmd="dmesg" || cmd="tail -n +${begin_line} /var/log/kern.log" | ||
|
|
||
| # confirm begin_line is number, if it is not the number, direct using dmesg | ||
| [[ "${begin_line//[0-9]/}" ]] && begin_line=0 | ||
| [[ "$begin_line" -eq 0 ]] && cmd="dmesg" || cmd="tail -n +${begin_line} /var/log/kern.log" | ||
| # confirm begin_timestamp is in UNIX timestamp format, otherwise use dmesg | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment explaining why we still need to support a different begin_timestamp format.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not think we need a different begin_timestamp format. What I mean here is to keep the fallback we used to have to dmesg now to cover the small migration steps. |
||
| # TODO: drop dmesg usage as fallback and use no --since as fallback | ||
| journalctlflag="-k -q --no-pager --utc --output=short-iso --no-hostname" | ||
| [[ $begin_timestamp =~ ^[0-9]{10} ]] && cmd="journalctl $journalctlflag --since=@$begin_timestamp" || cmd="dmesg" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why stick to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| #echo "run $0 with parameter '$*' for check kernel message error" | ||
|
|
||
| # declare -p cmd | ||
| declare -p cmd | ||
| if [ "$ignore_str" ]; then | ||
| err=$( $cmd | grep 'Call Trace' -A5 -B3)$( $cmd | grep -E "$err_str"|grep -vE "$ignore_str") | ||
| err=$($cmd | grep 'Call Trace' -A5 -B3)$($cmd | grep -E "$err_str"|grep -vE "$ignore_str") | ||
| else | ||
| err=$( $cmd | grep 'Call Trace' -A5 -B3)$( $cmd | grep -E "$err_str") | ||
| err=$($cmd | grep 'Call Trace' -A5 -B3)$($cmd | grep -E "$err_str") | ||
| fi | ||
|
|
||
| if [ "$err" ]; then | ||
| echo "$(date -u '+%Y-%m-%d %T %Z')" "[ERROR]" "Caught dmesg error" | ||
| [[ -z "$err" ]] || { | ||
| echo "$(date -u '+%Y-%m-%d %T %Z')" "[ERROR]" "Caught kernel log error" | ||
| echo "===========================>>" | ||
| echo "$err" | ||
| echo "<<===========================" | ||
| builtin exit 1 | ||
| fi | ||
| } | ||
xiulipan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure this has to be in the same PR than the rest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I named this PR as
use journalctl as default kernel log reader, so I think put all change there is OK.I split them into different commit. If you want single commit in one PR I am OK with that.