sched_ext: build errors when building flatcg and qmap schedulers
Hi,
Getting build error when trying to compile example schedulers in tools/sched_ext/* (logs shared in the end)
tools/sched_ext # make -s -k
git repo state
$ git log --oneline e32cde8d2bd7d (HEAD -> master, origin/master, origin/HEAD) Merge tag 'sched_ext-for-6.12-rc1-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext 190ecde722dd0 Merge tag 'probes-fixes-v6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace a5f24c795513f Merge tag 'vfs-6.12-rc2.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs f801850bc263d netfs: Fix the netfs_folio tracepoint to handle NULL mapping 28e8c5c095ec2 netfs: Add folio_queue API documentation 2007d28ec0095 bcachefs: rename version -> bversion for big endian builds 34820304cc2cd uprobes: fix kernel info leak via "[uprobes]" vma 9852d85ec9d49 (tag: v6.12-rc1) Linux 6.12-rc1
Adding __weak attribute seems to have fixed it and compilation completed with no errors.
tools/sched_ext/include/scx/common.bpf.h +3 -3
@@ -41,8 +41,8 @@ void scx_bpf_dispatch_vtime(struct task_struct *p, u64 dsq_id, u64 slice, u64 vt u32 scx_bpf_dispatch_nr_slots(void) __ksym; void scx_bpf_dispatch_cancel(void) __ksym; bool scx_bpf_consume(u64 dsq_id) __ksym; -void scx_bpf_dispatch_from_dsq_set_slice(struct bpf_iter_scx_dsq *it__iter, u64 slice) __ksym; -void scx_bpf_dispatch_from_dsq_set_vtime(struct bpf_iter_scx_dsq *it__iter, u64 vtime) __ksym; +void scx_bpf_dispatch_from_dsq_set_slice(struct bpf_iter_scx_dsq *it__iter, u64 slice) __ksym __weak; +void scx_bpf_dispatch_from_dsq_set_vtime(struct bpf_iter_scx_dsq *it__iter, u64 vtime) __ksym __weak; bool scx_bpf_dispatch_from_dsq(struct bpf_iter_scx_dsq *it__iter, struct task_struct *p, u64 dsq_id, u64 enq_flags) __ksym __weak; bool scx_bpf_dispatch_vtime_from_dsq(struct bpf_iter_scx_dsq *it__iter, struct task_struct *p, u64 dsq_id, u64 enq_flags) __ksym __weak; u32 scx_bpf_reenqueue_local(void) __ksym;
@@ -71,7 +71,7 @@ s32 scx_bpf_pick_any_cpu(const cpumask_t *cpus_allowed, u64 flags) __ksym; bool scx_bpf_task_running(const struct task_struct *p) __ksym; s32 scx_bpf_task_cpu(const struct task_struct *p) __ksym;struct rq *scx_bpf_cpu_rq (s32 cpu) __ksym; -struct cgroup *scx_bpf_task_cgroup (struct task_struct *p) __ksym; +struct cgroup *scx_bpf_task_cgroup (struct task_struct *p) __ksym__weak ;/* * Use the following as @it__iter when calling
---- Start of error log
$ make -s -k Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' differs from latest version at 'include/uapi/linux/bpf.h' Warning: Kernel ABI header at 'tools/include/uapi/linux/if_xdp.h' differs from latest version at 'include/uapi/linux/if_xdp.h'
Auto-detecting system features:
... clang-bpf-co-re: [ on ]
... llvm: [ on ]
... libcap: [ OFF ]
... libbfd: [ OFF ]
scx_qmap.bpf.c:321:4: error: static assertion failed due to requirement '!__builtin_constant_p(!!scx_bpf_dispatch_from_dsq_set_slice)': scx_bpf_dispatch_from_dsq_set_slice should be marked as __weak
321 | __COMPAT_scx_bpf_dispatch_from_dsq_set_slice(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
322 | BPF_FOR_EACH_ITER, slice_ns * 2);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$HOME/linux-x86/tools/sched_ext/include/scx/compat.bpf.h:25:3: note: expanded from macro '__COMPAT_scx_bpf_dispatch_from_dsq_set_slice'
25 | (bpf_ksym_exists(scx_bpf_dispatch_from_dsq_set_slice) ? \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$HOME/linux-x86/tools/sched_ext/build/include/bpf/bpf_helpers.h:191:17: note: expanded from macro 'bpf_ksym_exists'
191 | _Static_assert(!__builtin_constant_p(!!sym), \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
scx_qmap.bpf.c:323:4: error: static assertion failed due to requirement '!__builtin_constant_p(!!scx_bpf_dispatch_from_dsq_set_vtime)': scx_bpf_dispatch_from_dsq_set_vtime should be marked as __weak
323 | __COMPAT_scx_bpf_dispatch_from_dsq_set_vtime(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
324 | BPF_FOR_EACH_ITER, highpri_seq++);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$HOME/linux-x86/tools/sched_ext/include/scx/compat.bpf.h:28:3: note: expanded from macro '__COMPAT_scx_bpf_dispatch_from_dsq_set_vtime'
28 | (bpf_ksym_exists(scx_bpf_dispatch_from_dsq_set_vtime) ? \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$HOME/linux-x86/tools/sched_ext/build/include/bpf/bpf_helpers.h:191:17: note: expanded from macro 'bpf_ksym_exists'
191 | _Static_assert(!__builtin_constant_p(!!sym), \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
make: *** [Makefile:165: $HOME/linux-x86/tools/sched_ext/build/obj/sched_ext/scx_qmap.bpf.o] Error 1
scx_flatcg.bpf.c:388:9: error: static assertion failed due to requirement '!__builtin_constant_p(!!scx_bpf_task_cgroup)': scx_bpf_task_cgroup should be marked as __weak
388 | cgrp = __COMPAT_scx_bpf_task_cgroup(p);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$HOME/linux-x86/tools/sched_ext/include/scx/compat.bpf.h:20:3: note: expanded from macro '__COMPAT_scx_bpf_task_cgroup'
20 | (bpf_ksym_exists(scx_bpf_task_cgroup) ? \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$HOME/linux-x86/tools/sched_ext/build/include/bpf/bpf_helpers.h:191:17: note: expanded from macro 'bpf_ksym_exists'
191 | _Static_assert(!__builtin_constant_p(!!sym), \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
scx_flatcg.bpf.c:514:9: error: static assertion failed due to requirement '!__builtin_constant_p(!!scx_bpf_task_cgroup)': scx_bpf_task_cgroup should be marked as __weak
514 | cgrp = __COMPAT_scx_bpf_task_cgroup(p);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$HOME/linux-x86/tools/sched_ext/include/scx/compat.bpf.h:20:3: note: expanded from macro '__COMPAT_scx_bpf_task_cgroup'
20 | (bpf_ksym_exists(scx_bpf_task_cgroup) ? \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$HOME/linux-x86/tools/sched_ext/build/include/bpf/bpf_helpers.h:191:17: note: expanded from macro 'bpf_ksym_exists'
191 | _Static_assert(!__builtin_constant_p(!!sym), \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
scx_flatcg.bpf.c:527:9: error: static assertion failed due to requirement '!__builtin_constant_p(!!scx_bpf_task_cgroup)': scx_bpf_task_cgroup should be marked as __weak
527 | cgrp = __COMPAT_scx_bpf_task_cgroup(p);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$HOME/linux-x86/tools/sched_ext/include/scx/compat.bpf.h:20:3: note: expanded from macro '__COMPAT_scx_bpf_task_cgroup'
20 | (bpf_ksym_exists(scx_bpf_task_cgroup) ? \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$HOME/linux-x86/tools/sched_ext/build/include/bpf/bpf_helpers.h:191:17: note: expanded from macro 'bpf_ksym_exists'
191 | _Static_assert(!__builtin_constant_p(!!sym), \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
scx_flatcg.bpf.c:570:9: error: static assertion failed due to requirement '!__builtin_constant_p(!!scx_bpf_task_cgroup)': scx_bpf_task_cgroup should be marked as __weak
570 | cgrp = __COMPAT_scx_bpf_task_cgroup(p);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$HOME/linux-x86/tools/sched_ext/include/scx/compat.bpf.h:20:3: note: expanded from macro '__COMPAT_scx_bpf_task_cgroup'
20 | (bpf_ksym_exists(scx_bpf_task_cgroup) ? \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$HOME/linux-x86/tools/sched_ext/build/include/bpf/bpf_helpers.h:191:17: note: expanded from macro 'bpf_ksym_exists'
191 | _Static_assert(!__builtin_constant_p(!!sym), \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
scx_flatcg.bpf.c:584:9: error: static assertion failed due to requirement '!__builtin_constant_p(!!scx_bpf_task_cgroup)': scx_bpf_task_cgroup should be marked as __weak
584 | cgrp = __COMPAT_scx_bpf_task_cgroup(p);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$HOME/linux-x86/tools/sched_ext/include/scx/compat.bpf.h:20:3: note: expanded from macro '__COMPAT_scx_bpf_task_cgroup'
20 | (bpf_ksym_exists(scx_bpf_task_cgroup) ? \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$HOME/linux-x86/tools/sched_ext/build/include/bpf/bpf_helpers.h:191:17: note: expanded from macro 'bpf_ksym_exists'
191 | _Static_assert(!__builtin_constant_p(!!sym), \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~5 errors generated.
make: *** [Makefile:165: $HOME/linux-x86/tools/sched_ext/build/obj/sched_ext/scx_flatcg.bpf.o] Error 1
make: Target 'all' not remade because of errors.
---- End of error log
Tejun Heo
reviewerHello, Vishal.
Quoted 19 lines · Vishal Chourasia
Getting build error when trying to compile example schedulers in
tools/sched_ext/*(logs shared in the end)
tools/sched_ext# make -s -kgit repo state
$ git log --oneline e32cde8d2bd7d (HEAD -> master, origin/master, origin/HEAD) Merge tag 'sched_ext-for-6.12-rc1-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext 190ecde722dd0 Merge tag 'probes-fixes-v6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace a5f24c795513f Merge tag 'vfs-6.12-rc2.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs f801850bc263d netfs: Fix the netfs_folio tracepoint to handle NULL mapping 28e8c5c095ec2 netfs: Add folio_queue API documentation 2007d28ec0095 bcachefs: rename version -> bversion for big endian builds 34820304cc2cd uprobes: fix kernel info leak via "[uprobes]" vma 9852d85ec9d49 (tag: v6.12-rc1) Linux 6.12-rc1
Quoted 2 lines
Adding
__weakattribute seems to have fixed it and compilation completed with no errors.
Hmm... I don't see the failure here. Maybe toolchain difference? Anyways, can you send the patch to add __weak?
Thanks.
Signature · 1 line
tejun
Quoted 22 lines · Tejun Heo
Hello, Vishal.
Quoted 19 lines · Vishal Chourasia
Getting build error when trying to compile example schedulers in
tools/sched_ext/*(logs shared in the end)
tools/sched_ext# make -s -kgit repo state
$ git log --oneline e32cde8d2bd7d (HEAD -> master, origin/master, origin/HEAD) Merge tag 'sched_ext-for-6.12-rc1-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext 190ecde722dd0 Merge tag 'probes-fixes-v6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace a5f24c795513f Merge tag 'vfs-6.12-rc2.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs f801850bc263d netfs: Fix the netfs_folio tracepoint to handle NULL mapping 28e8c5c095ec2 netfs: Add folio_queue API documentation 2007d28ec0095 bcachefs: rename version -> bversion for big endian builds 34820304cc2cd uprobes: fix kernel info leak via "[uprobes]" vma 9852d85ec9d49 (tag: v6.12-rc1) Linux 6.12-rc1
Quoted 4 lines
Quoted 2 lines
Adding
__weakattribute seems to have fixed it and compilation completed with no errors.Hmm... I don't see the failure here. Maybe toolchain difference? Anyways,
$ clang --version clang version 20.0.0git (https://github.com/llvm/llvm-project.git 00c198b2ca6b6bee2d90e62d78816686ab056b1b) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/local/bin
$ gcc --version gcc (GCC) 14.2.1 20240912 (Red Hat 14.2.1-3) Copyright (C) 2024 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Do let me know if you need any other information
Quoted 1 line
can you send the patch to add
__weak?
Sure.
Quoted 5 lines
Thanks.
Signature · 1 line
tejun