sched-ext / scx

sched_ext schedulers and tools
https://bit.ly/scx_slack
GNU General Public License v2.0
871 stars 82 forks source link

Is CONFIG_PAHOLE_HAS_BTF_TAG needed? #251

Closed vanfanel closed 5 months ago

vanfanel commented 5 months ago

Hi there,

I'm trying to setup a self-built 6.8.8 kernel with the Cachyos patchset to experiment with sched-ext.

I have seen on Phoronix that these kernel config options are supposedly needed for sched-ext to work:

# essential configs to enable sched_ext
CONFIG_BPF=y
CONFIG_SCHED_CLASS_EXT=y
CONFIG_BPF_SYSCALL=y
CONFIG_BPF_JIT=y
CONFIG_BPF_JIT_ALWAYS_ON=y
CONFIG_BPF_JIT_DEFAULT_ON=y
CONFIG_PAHOLE_HAS_BTF_TAG=y
CONFIG_DEBUG_INFO_BTF=y

Is that correct? I mean, is CONFIG_PAHOLE_HAS_BTF_TAG really needed? It seems to depend on CONFIG_CC_IS_CLANG which is an additional hurdle since I have never built the kernel with CLANG (which is needed for sched-ext anyway, but still I would like to be sure of what am I doing and why).

Thanks!

bunkbail commented 5 months ago

I built my kernel using gcc and I don't have CONFIG_PAHOLE_HAS_BTF_TAG in my config file. I also dunno why but for some reason I have to have CONFIG_DEBUG_INFO_DWARF4=y enabled otherwise BTF isn't working for me.

arighi commented 5 months ago

I've always built the sched-ext Ubuntu kernel using gcc and all the schedulers have been functioning properly without CONFIG_PAHOLE_HAS_BTF_TAG. Therefore,, I am pretty confident in saying that this option is not strictly needed in general (but it's probably required if you build the kernel using clang).

vanfanel commented 5 months ago

@arighi Thanks alot for chiming in! What about CONFIG_DEBUG_INFO_BTF, is that one needed for working sched_ext? And I have CONFIG_DEBUG_INFO_DWARF5, but @bunkbail says that CONFIG_DEBUG_INFO_DWARF4 is needed, what do you think?

arighi commented 5 months ago

@vanfanel CONFIG_DEBUG_INFO_BTF is mandatory in order to have access to /sys/kernel/btf/vmlinux.

About CONFIG_DEBUG_INFO_DWARF4 I don't think it's required, I actually have CONFIG_DEBUG_INFO_DWARF5 in my kernel...

arighi commented 5 months ago

BTW, as a reference to the required kernel configs, you can always check https://github.com/sched-ext/sched_ext/blob/sched_ext/.github/workflows/sched-ext.config

vanfanel commented 5 months ago

@arighi Thanks, I have built a 6.8.8 kernel with CONFIG_DEBUG_INFO_BTF enabled too. Do you happen to know what kernel option provides exit_dump_len? I have this error when running the schedulers, which seems to point to a missing kernel feature:


root@debian:~# scx_rustland 
16:06:37 [INFO] libbpf: struct_ops rustland: member exit_dump_len not found in kernel, skipping it as it's set to zero

Error: Failed to attach struct ops

Caused by:
    bpf call "libbpf_rs::map::Map::attach_struct_ops::{{closure}}" returned NULL

I have searched on the kernel sources and found no reference to exit_dump_len, and nothing in .config or in the https://github.com/sched-ext/sched_ext/blob/sched_ext/.github/workflows/sched-ext.config seem to be related to that.

vanfanel commented 5 months ago

Ok, I got this working (no idea why it was failing, I would really like to document it here, but I rebuilt the kernel with new options and it's working now, no idea what I changed, really!)