Skip to content

Commit

Permalink
Merge pull request #1031 from hodgesds/dump-common-header
Browse files Browse the repository at this point in the history
scx: Add scx_bpf_dump_header helper
  • Loading branch information
hodgesds authored Dec 3, 2024
2 parents be5db9d + ba7b309 commit 596268e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions scheds/include/scx/common.bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#define PF_KTHREAD 0x00200000 /* I am a kernel thread */
#define PF_EXITING 0x00000004
#define CLOCK_MONOTONIC 1
extern int LINUX_KERNEL_VERSION __kconfig;
extern const char CONFIG_CC_VERSION_TEXT[64] __kconfig __weak;
extern const char CONFIG_LOCALVERSION[64] __kconfig __weak;

/*
* Earlier versions of clang/pahole lost upper 32bits in 64bit enums which can
Expand Down Expand Up @@ -150,6 +153,20 @@ ___scx_bpf_bstr_format_checker(const char *fmt, ...) {}
___scx_bpf_bstr_format_checker(fmt, ##args); \
})

/*
* scx_bpf_dump_header() is a wrapper around scx_bpf_dump that adds a header
* of system information for debugging.
*/
#define scx_bpf_dump_header() \
({ \
scx_bpf_dump("kernel: %d.%d.%d %s\ncc: %s\n", \
LINUX_KERNEL_VERSION >> 16, \
LINUX_KERNEL_VERSION >> 8 & 0xFF, \
LINUX_KERNEL_VERSION & 0xFF, \
CONFIG_LOCALVERSION, \
CONFIG_CC_VERSION_TEXT); \
})

#define BPF_STRUCT_OPS(name, args...) \
SEC("struct_ops/" #name) \
BPF_PROG(name, ##args)
Expand Down
2 changes: 2 additions & 0 deletions scheds/rust/scx_layered/src/bpf/main.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2198,6 +2198,8 @@ void BPF_STRUCT_OPS(layered_dump, struct scx_dump_ctx *dctx)
int i, j, id;
struct layer *layer;

scx_bpf_dump_header();

bpf_for(i, 0, nr_layers) {
layer = lookup_layer(i);
if (!layer) {
Expand Down

0 comments on commit 596268e

Please sign in to comment.