Skip to content

Commit a73aa3a

Browse files
committed
sched_ext: Guard BPF arena helper calls to fix 32-bit build
BPF arena (kernel/bpf/arena.c) is compiled only on MMU && 64BIT, while SCHED_CLASS_EXT depends on BPF_SYSCALL && BPF_JIT && DEBUG_INFO_BTF with no 64BIT requirement. On a 32-bit arch with a BPF JIT, SCX builds while the arena helpers are absent, so the cid-form code's unconditional calls to bpf_prog_arena() and bpf_arena_map_kern_vm_start() fail to link: build_policy.o: undefined reference to `bpf_prog_arena' build_policy.o: undefined reference to `bpf_arena_map_kern_vm_start' Guard the three call sites with the same MMU && 64BIT condition that gates arena.o. A cid-form scheduler needs a BPF arena, which isn't available on such builds, so it can't run there regardless. cpu-form schedulers don't touch the arena and are unaffected. This is a quick workaround to get past the build errors. A fuller fix may make the whole cid-form path conditional on the same condition, or drop 32-bit support outright. Fixes: 0e2819c ("sched_ext: Require an arena for cid-form schedulers") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202605310454.U9iByL2n-lkp@intel.com/ Closes: https://lore.kernel.org/oe-kbuild-all/202605310926.APXMc0RJ-lkp@intel.com/ Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 6bf8973 commit a73aa3a

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

kernel/sched/ext.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,12 @@ static inline void scx_call_op_set_cpumask(struct scx_sched *sch, struct rq *rq,
622622

623623
if (scx_is_cid_type()) {
624624
struct scx_cmask *kern_va = *this_cpu_ptr(sch->set_cmask_scratch);
625-
unsigned long uaddr = (unsigned long)kern_va -
626-
bpf_arena_map_kern_vm_start(sch->arena_map);
625+
unsigned long uaddr = (unsigned long)kern_va;
626+
627+
/* arena.o, which defines these, is built only on MMU && 64BIT */
628+
#if defined(CONFIG_MMU) && defined(CONFIG_64BIT)
629+
uaddr -= bpf_arena_map_kern_vm_start(sch->arena_map);
630+
#endif
627631
/*
628632
* Build the per-CPU arena cmask and hand BPF the uaddr. Caller
629633
* holds the rq lock with IRQs disabled, which makes us the sole
@@ -7992,8 +7996,12 @@ struct scx_arena_scan {
79927996
static int scx_arena_scan_prog(struct bpf_prog *prog, void *data)
79937997
{
79947998
struct scx_arena_scan *s = data;
7995-
struct bpf_map *arena = bpf_prog_arena(prog);
7999+
struct bpf_map *arena = NULL;
79968000

8001+
/* arena.o, which defines these, is built only on MMU && 64BIT */
8002+
#if defined(CONFIG_MMU) && defined(CONFIG_64BIT)
8003+
arena = bpf_prog_arena(prog);
8004+
#endif
79978005
if (!arena)
79988006
return 0;
79998007
if (s->arena && s->arena != arena) {

kernel/sched/ext_arena.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ static int scx_arena_grow(struct scx_sched *sch, u32 page_cnt)
8080
return -ENOMEM;
8181

8282
uaddr32 = (u32)(unsigned long)p;
83+
/* arena.o, which defines these, is built only on MMU && 64BIT */
84+
#if defined(CONFIG_MMU) && defined(CONFIG_64BIT)
8385
kern_vm_start = bpf_arena_map_kern_vm_start(sch->arena_map);
86+
#else
87+
kern_vm_start = 0;
88+
#endif
8489

8590
ret = gen_pool_add(sch->arena_pool, kern_vm_start + uaddr32,
8691
page_cnt * PAGE_SIZE, NUMA_NO_NODE);

0 commit comments

Comments
 (0)