Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Improve debug dump #201

Merged
merged 12 commits into from
May 9, 2024
Merged

Improve debug dump #201

merged 12 commits into from
May 9, 2024

Conversation

htejun
Copy link
Collaborator

@htejun htejun commented May 8, 2024

  • Dumps can now be read through sched_ext_dump tracepoint.
  • Dumps can now be triggered non-destructively using sysrq-D.

@htejun htejun requested a review from Byte-Lab May 8, 2024 22:57
Copy link
Collaborator

@Byte-Lab Byte-Lab left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks a lot for making the debug story so much better with these last few change sets.

seq_buf_putc(s, '\n');
}

static __printf(2, 0) void dump_line(struct seq_buf *s, const char *fmt, ...)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be __printf(2, 3)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

* needed from vmlinux.h. This is error-prone. Hopefully, we'll figure out a
* better way to do this in the future.
*/
enum scx_ops_flags {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Per our offline discussion, we could use __COMPAT_ENUM_OR_ZERO() here to give this CO-RE semantics. Something like:

define SCX_OPS_KEEP_BUILTIN_IDLE __COMPAT_enum_or_zero("scx_ops_flags", SCX_OPS_KEEP_BUILTIN_IDLE)

Feel free to ignore or apply as you think best.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I dropped this patch. Let's do it in a separate patch. In an earlier version, I added a new ops flag for trace dumping but then switched to using a TP which makes this change unnecessary for this PR. I'll add this later.

htejun added 12 commits May 9, 2024 09:51
Nothing's gained by keeping these percpu. Let's make them global.
Add dump_line() which wraps seq_buf_vprintf(). Replace seq_buf_printf() and
seq_buf_putc() usages with the new wrapper. Also, don't print more than one
line. This is preparation for sending debug dump through a tracepoint.
Let's output stack trace using dump_line() too.
- Factor out __bstr_format() which takes broken out buffer arguments. Will
  be used to implement incremental formatting.

- bstr_format() now takes struct scx_bstr_buf * instead of implicitly using
  the global buffer.

- Rename scx_bstr_buf to scx_exit_bstr_buf and switch the dump path to its
  own bstr_buf.

No functional changes.
scx_bpf_dump_bstr() was outputing character by character into the dump
buffer. This is fine for the dump attached to the exit info but we also want
to output through a tracepoint. This patch makes ops dump output into lines
so that dump_line() is always called with a full line.
Make dump_line() append newline implicitly and add dump_newline() for
outputting a blank line. The latter is needed because __printf format
checking gets unhappy with empty format string "". This doesn't cause any
behavior changes and will be used to enable dump output through a
tracepoint.
- In dump_stack_trace(), seq_buf_commit() triggers BUG() if $s is already
  overflowed when $ns was created. Commit iff $avail is non-zero.

- seq_buf_putc() and seq_buf_vprintf() trigger a warning if @s has zero
  length, which can happen with $ns. Skip them for empy seq_bufs.
Add a new tracepoint, sched_ext_dump, which also receives the dump output.
The TP output is not limted by dump buffer size and truncation will only
happen on trace buffer overflows.
This triggers debug dump in a non-destructive manner.
@htejun htejun merged commit 5a00279 into sched_ext May 9, 2024
1 check passed
@htejun htejun deleted the htejun/dump branch May 9, 2024 19:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants