From: Gentoo CachyOS overlay
Subject: [PATCH] sched/alt: add rt_mutex_futex_{pre,post}_schedule()

The 6.18.55 and 7.2.10 stable kernels make rt_mutex_wait_proxy_lock()
call rt_mutex_futex_{pre,post}_schedule(), which only exist in
kernel/sched/core.c. PRJC replaces core.c, so the link fails.
Mirror the core.c helpers, as upstream already did for MuQSS.

--- a/kernel/sched/alt_core.c
+++ b/kernel/sched/alt_core.c
@@ -5126,6 +5126,17 @@
 	sched_submit_work(current);
 }
 
+/*
+ * Used within the futex syscall context, skips sched_submit_work() because none
+ * its work will be done. Asserts ensure that it is indeed the case.
+ */
+void rt_mutex_futex_pre_schedule(void)
+{
+	lockdep_assert(!(current->flags & (PF_WQ_WORKER | PF_IO_WORKER)));
+	lockdep_assert(!current->plug);
+	lockdep_assert(!fetch_and_set(current->sched_rt_mutex, 1));
+}
+
 void rt_mutex_schedule(void)
 {
 	lockdep_assert(current->sched_rt_mutex);
@@ -5138,6 +5149,11 @@
 	lockdep_assert(fetch_and_set(current->sched_rt_mutex, 0));
 }
 
+void rt_mutex_futex_post_schedule(void)
+{
+	lockdep_assert(fetch_and_set(current->sched_rt_mutex, 0));
+}
+
 /*
  * rt_mutex_setprio - set the current priority of a task
  * @p: task to boost
