From 44149737b789d31379bbbb0b61687518b713c255 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 2 Apr 2024 09:24:55 -1000 Subject: [PATCH 1/2] scx: Reorder scx_ops_flags enums to restore backward compatibility SCX_OPS_SWITCH_PARTIAL was added recently but assigned the first bit shifting all the other values. This breaks backward compatibility as flag values are hard coded into e.g. sched_ext_ops definitions. Let's reorder the enums so that the existing values aren't shifted around. --- include/linux/sched/ext.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/linux/sched/ext.h b/include/linux/sched/ext.h index 978e6b1b7093b..12031306b8cc5 100644 --- a/include/linux/sched/ext.h +++ b/include/linux/sched/ext.h @@ -92,16 +92,10 @@ struct scx_exit_info { /* sched_ext_ops.flags */ enum scx_ops_flags { - /* - * If set, only tasks with policy set to SCHED_EXT are attached to - * sched_ext. If clear, SCHED_NORMAL tasks are also included. - */ - SCX_OPS_SWITCH_PARTIAL = 1LLU << 0, - /* * Keep built-in idle tracking even if ops.update_idle() is implemented. */ - SCX_OPS_KEEP_BUILTIN_IDLE = 1LLU << 1, + SCX_OPS_KEEP_BUILTIN_IDLE = 1LLU << 0, /* * By default, if there are no other task to run on the CPU, ext core @@ -109,7 +103,7 @@ enum scx_ops_flags { * flag is specified, such tasks are passed to ops.enqueue() with * %SCX_ENQ_LAST. See the comment above %SCX_ENQ_LAST for more info. */ - SCX_OPS_ENQ_LAST = 1LLU << 2, + SCX_OPS_ENQ_LAST = 1LLU << 1, /* * An exiting task may schedule after PF_EXITING is set. In such cases, @@ -122,7 +116,13 @@ enum scx_ops_flags { * depend on pid lookups and wants to handle these tasks directly, the * following flag can be used. */ - SCX_OPS_ENQ_EXITING = 1LLU << 3, + SCX_OPS_ENQ_EXITING = 1LLU << 2, + + /* + * If set, only tasks with policy set to SCHED_EXT are attached to + * sched_ext. If clear, SCHED_NORMAL tasks are also included. + */ + SCX_OPS_SWITCH_PARTIAL = 1LLU << 3, /* * CPU cgroup knob enable flags From 5dc95302301fb7e51cd4d218008b9dad10110069 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 2 Apr 2024 09:30:44 -1000 Subject: [PATCH 2/2] scx/compat.h: __COMPAT_read_enum() should use btf__find_by_name() instead of btf__find_by_name_kind() w/ BTF_KIND_ENUM as it also needs to read BTF_KIND_ENUM64's. --- tools/sched_ext/include/scx/compat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/sched_ext/include/scx/compat.h b/tools/sched_ext/include/scx/compat.h index ec941513531d3..77ec97a0b468b 100644 --- a/tools/sched_ext/include/scx/compat.h +++ b/tools/sched_ext/include/scx/compat.h @@ -28,7 +28,7 @@ static inline bool __COMPAT_read_enum(const char *type, const char *name, u64 *v __COMPAT_load_vmlinux_btf(); - tid = btf__find_by_name_kind(__COMPAT_vmlinux_btf, type, BTF_KIND_ENUM); + tid = btf__find_by_name(__COMPAT_vmlinux_btf, type); if (tid < 0) return false;