Sched_ext development
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: David Vernet <void@manifault.com>,
	Andrea Righi <arighi@nvidia.com>,
	Changwoo Min <changwoo@igalia.com>,
	sched-ext@lists.linux.dev
Cc: Emil Tsalapatis <emil@etsalapatis.com>, linux-kernel@vger.kernel.org
Subject: [PATCH sched_ext/for-7.2] sched_ext: Guard BPF arena helper calls to fix 32-bit build
Date: Sun, 31 May 2026 07:57:45 -1000	[thread overview]
Message-ID: <e8d28ed3e35f72b7dc647a6ef27e1b80@kernel.org> (raw)

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: 0e2819cba977 ("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>
---
 kernel/sched/ext.c       | 14 +++++++++++---
 kernel/sched/ext_arena.c |  5 +++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index ffad1a90196f..8ef55dac69c8 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -622,8 +622,12 @@ static inline void scx_call_op_set_cpumask(struct scx_sched *sch, struct rq *rq,
 
 	if (scx_is_cid_type()) {
 		struct scx_cmask *kern_va = *this_cpu_ptr(sch->set_cmask_scratch);
-		unsigned long uaddr = (unsigned long)kern_va -
-			bpf_arena_map_kern_vm_start(sch->arena_map);
+		unsigned long uaddr = (unsigned long)kern_va;
+
+		/* arena.o, which defines these, is built only on MMU && 64BIT */
+#if defined(CONFIG_MMU) && defined(CONFIG_64BIT)
+		uaddr -= bpf_arena_map_kern_vm_start(sch->arena_map);
+#endif
 		/*
 		 * Build the per-CPU arena cmask and hand BPF the uaddr. Caller
 		 * holds the rq lock with IRQs disabled, which makes us the sole
@@ -8005,8 +8009,12 @@ struct scx_arena_scan {
 static int scx_arena_scan_prog(struct bpf_prog *prog, void *data)
 {
 	struct scx_arena_scan *s = data;
-	struct bpf_map *arena = bpf_prog_arena(prog);
+	struct bpf_map *arena = NULL;
 
+	/* arena.o, which defines these, is built only on MMU && 64BIT */
+#if defined(CONFIG_MMU) && defined(CONFIG_64BIT)
+	arena = bpf_prog_arena(prog);
+#endif
 	if (!arena)
 		return 0;
 	if (s->arena && s->arena != arena) {
diff --git a/kernel/sched/ext_arena.c b/kernel/sched/ext_arena.c
index b413e155ba6b..493c2424f842 100644
--- a/kernel/sched/ext_arena.c
+++ b/kernel/sched/ext_arena.c
@@ -80,7 +80,12 @@ static int scx_arena_grow(struct scx_sched *sch, u32 page_cnt)
 		return -ENOMEM;
 
 	uaddr32 = (u32)(unsigned long)p;
+	/* arena.o, which defines these, is built only on MMU && 64BIT */
+#if defined(CONFIG_MMU) && defined(CONFIG_64BIT)
 	kern_vm_start = bpf_arena_map_kern_vm_start(sch->arena_map);
+#else
+	kern_vm_start = 0;
+#endif
 
 	ret = gen_pool_add(sch->arena_pool, kern_vm_start + uaddr32,
 			   page_cnt * PAGE_SIZE, NUMA_NO_NODE);

             reply	other threads:[~2026-05-31 17:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-31 17:57 Tejun Heo [this message]
2026-05-31 18:08 ` [PATCH sched_ext/for-7.2] sched_ext: Guard BPF arena helper calls to fix 32-bit build Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e8d28ed3e35f72b7dc647a6ef27e1b80@kernel.org \
    --to=tj@kernel.org \
    --cc=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=emil@etsalapatis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=void@manifault.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox