Skip to content

Commit 596268e

Browse files
authored
Merge pull request #1031 from hodgesds/dump-common-header
scx: Add scx_bpf_dump_header helper
2 parents be5db9d + ba7b309 commit 596268e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

scheds/include/scx/common.bpf.h

+17
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#define PF_KTHREAD 0x00200000 /* I am a kernel thread */
2424
#define PF_EXITING 0x00000004
2525
#define CLOCK_MONOTONIC 1
26+
extern int LINUX_KERNEL_VERSION __kconfig;
27+
extern const char CONFIG_CC_VERSION_TEXT[64] __kconfig __weak;
28+
extern const char CONFIG_LOCALVERSION[64] __kconfig __weak;
2629

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

156+
/*
157+
* scx_bpf_dump_header() is a wrapper around scx_bpf_dump that adds a header
158+
* of system information for debugging.
159+
*/
160+
#define scx_bpf_dump_header() \
161+
({ \
162+
scx_bpf_dump("kernel: %d.%d.%d %s\ncc: %s\n", \
163+
LINUX_KERNEL_VERSION >> 16, \
164+
LINUX_KERNEL_VERSION >> 8 & 0xFF, \
165+
LINUX_KERNEL_VERSION & 0xFF, \
166+
CONFIG_LOCALVERSION, \
167+
CONFIG_CC_VERSION_TEXT); \
168+
})
169+
153170
#define BPF_STRUCT_OPS(name, args...) \
154171
SEC("struct_ops/" #name) \
155172
BPF_PROG(name, ##args)

scheds/rust/scx_layered/src/bpf/main.bpf.c

+2
Original file line numberDiff line numberDiff line change
@@ -2198,6 +2198,8 @@ void BPF_STRUCT_OPS(layered_dump, struct scx_dump_ctx *dctx)
21982198
int i, j, id;
21992199
struct layer *layer;
22002200

2201+
scx_bpf_dump_header();
2202+
22012203
bpf_for(i, 0, nr_layers) {
22022204
layer = lookup_layer(i);
22032205
if (!layer) {

0 commit comments

Comments
 (0)