Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F142834958
D54831 proposal
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
jrtc27
Sat, Jan 24, 12:54 AM
2026-01-24 00:54:56 (UTC+0)
Size
12 KB
Referenced Files
None
Subscribers
None
D54831 proposal
View Options
sys/kern/sched_shim.c | 563 +++++++-------------------------------------------
1 file changed, 75 insertions(+), 488 deletions(-)
diff --git a/sys/kern/sched_shim.c b/sys/kern/sched_shim.c
index a75a1f1e025d..e7486d77917a 100644
--- a/sys/kern/sched_shim.c
+++ b/sys/kern/sched_shim.c
@@ -20,494 +20,81 @@
const struct sched_instance *active_sched;
#ifndef __DO_NOT_HAVE_SYS_IFUNCS
-
-DEFINE_IFUNC(, int, sched_load, (void))
-{
- return (active_sched->load);
-}
-
-DEFINE_IFUNC(, int, sched_rr_interval, (void))
-{
- return (active_sched->rr_interval);
-}
-
-DEFINE_IFUNC(, bool, sched_runnable, (void))
-{
- return (active_sched->runnable);
-}
-
-DEFINE_IFUNC(, void, sched_exit, (struct proc *p, struct thread *childtd))
-{
- return (active_sched->exit);
-}
-
-DEFINE_IFUNC(, void, sched_fork, (struct thread *td, struct thread *childtd))
-{
- return (active_sched->fork);
-}
-
-DEFINE_IFUNC(, void, sched_fork_exit, (struct thread *td))
-{
- return (active_sched->fork_exit);
-}
-
-DEFINE_IFUNC(, void, sched_class, (struct thread *td, int class))
-{
- return (active_sched->class);
-}
-
-DEFINE_IFUNC(, void, sched_nice, (struct proc *p, int nice))
-{
- return (active_sched->nice);
-}
-
-DEFINE_IFUNC(, void, sched_ap_entry, (void))
-{
- return (active_sched->ap_entry);
-}
-
-DEFINE_IFUNC(, void, sched_exit_thread, (struct thread *td, struct thread *child))
-{
- return (active_sched->exit_thread);
-}
-
-DEFINE_IFUNC(, u_int, sched_estcpu, (struct thread *td))
-{
- return (active_sched->estcpu);
-}
-
-DEFINE_IFUNC(, void, sched_fork_thread, (struct thread *td, struct thread *child))
-{
- return (active_sched->fork_thread);
-}
-
-DEFINE_IFUNC(, void, sched_ithread_prio, (struct thread *td, u_char prio))
-{
- return (active_sched->ithread_prio);
-}
-
-DEFINE_IFUNC(, void, sched_lend_prio, (struct thread *td, u_char prio))
-{
- return (active_sched->lend_prio);
-}
-
-DEFINE_IFUNC(, void, sched_lend_user_prio, (struct thread *td, u_char pri))
-{
- return (active_sched->lend_user_prio);
-}
-
-DEFINE_IFUNC(, void, sched_lend_user_prio_cond, (struct thread *td, u_char pri))
-{
- return (active_sched->lend_user_prio_cond);
-}
-
-DEFINE_IFUNC(, fixpt_t, sched_pctcpu, (struct thread *td))
-{
- return (active_sched->pctcpu);
-}
-
-DEFINE_IFUNC(, void, sched_prio, (struct thread *td, u_char prio))
-{
- return (active_sched->prio);
-}
-
-DEFINE_IFUNC(, void, sched_sleep, (struct thread *td, int prio))
-{
- return (active_sched->sleep);
-}
-
-DEFINE_IFUNC(, void, sched_switch, (struct thread *td, int flags))
-{
- return (active_sched->sswitch);
-}
-
-DEFINE_IFUNC(, void, sched_throw, (struct thread *td))
-{
- return (active_sched->throw);
-}
-
-DEFINE_IFUNC(, void, sched_unlend_prio, (struct thread *td, u_char prio))
-{
- return (active_sched->unlend_prio);
-}
-
-DEFINE_IFUNC(, void, sched_user_prio, (struct thread *td, u_char prio))
-{
- return (active_sched->user_prio);
-}
-
-DEFINE_IFUNC(, void, sched_userret_slowpath, (struct thread *td))
-{
- return (active_sched->userret_slowpath);
-}
-
-DEFINE_IFUNC(, fixpt_t, sched_pctcpu_delta, (struct thread *td))
-{
- return (active_sched->pctcpu_delta);
-}
-
-DEFINE_IFUNC(, void, sched_add, (struct thread *td, int flags))
-{
- return (active_sched->add);
-}
-
-DEFINE_IFUNC(, struct thread *, sched_choose, (void))
-{
- return (active_sched->choose);
-}
-
-DEFINE_IFUNC(, void, sched_clock, (struct thread *td, int cnt))
-{
- return (active_sched->clock);
-}
-
-DEFINE_IFUNC(, void, sched_idletd, (void *))
-{
- return (active_sched->idletd);
-}
-
-DEFINE_IFUNC(, void, sched_preempt, (struct thread *td))
-{
- return (active_sched->preempt);
-}
-
-DEFINE_IFUNC(, void, sched_relinquish, (struct thread *td))
-{
- return (active_sched->relinquish);
-}
-
-DEFINE_IFUNC(, void, sched_rem, (struct thread *td))
-{
- return (active_sched->rem);
-}
-
-DEFINE_IFUNC(, void, sched_wakeup, (struct thread *td, int srqflags))
-{
- return (active_sched->wakeup);
-}
-
-DEFINE_IFUNC(, void, sched_bind, (struct thread *td, int cpu))
-{
- return (active_sched->bind);
-}
-
-DEFINE_IFUNC(, void, sched_unbind, (struct thread *td))
-{
- return (active_sched->unbind);
-}
-
-DEFINE_IFUNC(, int, sched_is_bound, (struct thread *td))
-{
- return (active_sched->is_bound);
-}
-
-DEFINE_IFUNC(, void, sched_affinity, (struct thread *td))
-{
- return (active_sched->affinity);
-}
-
-DEFINE_IFUNC(, int, sched_sizeof_proc, (void))
-{
- return (active_sched->sizeof_proc);
-}
-
-DEFINE_IFUNC(, int, sched_sizeof_thread, (void))
-{
- return (active_sched->sizeof_thread);
-}
-
-DEFINE_IFUNC(, char *, sched_tdname, (struct thread *td))
-{
- return (active_sched->tdname);
-}
-
-DEFINE_IFUNC(, void, sched_clear_tdname, (struct thread *td))
-{
- return (active_sched->clear_tdname);
-}
-
-DEFINE_IFUNC(, bool, sched_do_timer_accounting, (void))
-{
- return (active_sched->do_timer_accounting);
-}
-
-DEFINE_IFUNC(, int, sched_find_l2_neighbor, (int cpu))
-{
- return (active_sched->find_l2_neighbor);
-}
-
-DEFINE_IFUNC(, void, schedinit_ap, (void))
-{
- return (active_sched->init_ap);
-}
-
-#else /* __DO_NOT_HAVE_IFUNCS */
-
-int
-sched_load(void)
-{
- return (active_sched->load());
-}
-
-int
-sched_rr_interval(void)
-{
- return (active_sched->rr_interval());
-}
-
-bool
-sched_runnable(void)
-{
- return (active_sched->runnable());
-}
-
-void
-sched_exit(struct proc *p, struct thread *childtd)
-{
- active_sched->exit(p, childtd);
-}
-
-void
-sched_fork(struct thread *td, struct thread *childtd)
-{
- active_sched->fork(td, childtd);
-}
-
-void
-sched_fork_exit(struct thread *td)
-{
- active_sched->fork_exit(td);
-}
-
-void
-sched_class(struct thread *td, int class)
-{
- active_sched->class();
-}
-
-void
-sched_nice(struct proc *p, int nice)
-{
- active_sched->nice(p, nice);
-}
-
-void
-sched_ap_entry(void)
-{
- active_sched->ap_entry();
-}
-
-void
-sched_exit_thread(struct thread *td, struct thread *child)
-{
- active_sched->exit_thread(td, child);
-}
-
-u_int
-sched_estcpu(struct thread *td)
-{
- return (active_sched->estcpu(td));
-}
-
-void
-sched_fork_thread(struct thread *td, struct thread *child)
-{
- active_sched->fork_thread(td, child);
-}
-
-void
-sched_ithread_prio(struct thread *td, u_char prio)
-{
- active_sched->ithread_prio(td, prio);
-}
-
-void
-sched_lend_prio(struct thread *td, u_char prio)
-{
- active_sched->lend_prio(td, prio);
-}
-
-void
-sched_lend_user_prio(struct thread *td, u_char pri)
-{
- active_sched->lend_user_prio(td, pri);
-}
-
-void
-sched_lend_user_prio_cond(struct thread *td, u_char pri)
-{
- active_sched->lend_user_prio_cond(td, pri);
-}
-
-fixpt_t
-sched_pctcpu(struct thread *td)
-{
- return (active_sched->pctcpu(td));
-}
-
-void
-sched_prio(struct thread *td, u_char prio)
-{
- active_sched->prio(td, prio);
-}
-
-void
-sched_sleep(struct thread *td, int prio)
-{
- active_sched->sleep(td, prio);
-}
-
-void
-sched_switch(struct thread *td, int flags)
-{
- active_sched->sswitch(td, flags);
-}
-
-void
-sched_throw(struct thread *td)
-{
- active_sched->throw(td);
-}
-
-void
-sched_unlend_prio(struct thread *td, u_char prio()
-{
- active_sched->unlend_prio(td, prio);
-}
-
-void
-sched_user_prio(struct thread *td, u_char prio))
-{
- active_sched->user_prio(td, prio);
-}
-
-void
-sched_userret_slowpath(struct thread *td)
-{
- active_sched->userret_slowpath(td);
-}
-
-fixpt_t
-sched_pctcpu_delta(struct thread *td)
-{
- return (active_sched->pctcpu_delta(td));
-}
-
-void
-sched_add(struct thread *td, int flags)
-{
- active_sched->add(td, flags);
-}
-
-struct thread *
-sched_choose(void)
-{
- return (active_sched->choose());
-}
-
-void
-sched_clock(struct thread *td, int cnt)
-{
- active_sched->clock(td, cnt);
-}
-
-void
-sched_idletd(void *dummy)
-{
- active_sched->idletd(dummy);
-}
-
-void
-sched_preempt(struct thread *td)
-{
- active_sched->preempt(td));
-}
-
-void
-sched_relinquish(struct thread *td)
-{
- active_sched->relinquish(td);
-}
-
-void
-sched_rem(struct thread *td)
-{
- active_sched->rem();
-}
-
-void
-sched_wakeup(struct thread *td, int srqflags)
-{
- active_sched->wakeup(td, srqflags);
-}
-
-void
-sched_bind(struct thread *td, int cpu))
-{
- active_sched->bind(td, cpu);
-}
-
-void
-sched_unbind(struct thread *td)
-{
- active_sched->unbind(td);
-}
-
-int
-sched_is_bound(struct thread *td)
-{
- return (active_sched->is_bound(td));
-}
-
-void
-sched_affinity(struct thread *td)
-{
- active_sched->affinity(td);
-}
-
-int
-sched_sizeof_proc(void)
-{
- return (active_sched->sizeof_proc());
-}
-
-int
-sched_sizeof_thread(void)
-{
- return (active_sched->sizeof_thread());
-}
-
-char *
-sched_tdname(struct thread *td)
-{
- return (active_sched->tdname(td));
-}
-
-void
-sched_clear_tdname(struct thread *td)
-{
- active_sched->clear_tdname(td);
-}
-
-bool
-sched_do_timer_accounting(void)
-{
- return (active_sched->do_timer_accounting());
-}
-
-int
-sched_find_l2_neighbor(int cpu)
-{
- return (active_sched->find_l2_neighbor(cpu));
-}
-
-void
-schedinit_ap(void)
-{
- active_sched->init_ap();
-}
-
-#endif /* __HAVE_IFUNCS */
+#define __DEFINE_SHIM(__m, __r, __n, __p, __a) \
+ DEFINE_IFUNC(, __r, __n, __p) \
+ { \
+ return (active_sched->__m); \
+ }
+#else
+#define __DEFINE_SHIM(__m, __r, __n, __p, __a) \
+ __r \
+ __n __p \
+ { \
+ return (active_sched->__m __a); \
+ }
+#endif
+#define DEFINE_SHIM0(__m, __r, __n) \
+ __DEFINE_SHIM(__m, __r, __n, (void), ())
+#define DEFINE_SHIM1(__m, __r, __n, __t1, __a1) \
+ __DEFINE_SHIM(__m, __r, __n, (__t1 __a1), (__a1))
+#define DEFINE_SHIM2(__m, __r, __n, __t1, __a1, __t2, __a2) \
+ __DEFINE_SHIM(__m, __r, __n, (__t1 __a1, __t2 __a2), (__a1, __a2))
+
+DEFINE_SHIM0(load, int, sched_load)
+DEFINE_SHIM0(rr_interval, int, sched_rr_interval)
+DEFINE_SHIM0(runnable, bool, sched_runnable)
+DEFINE_SHIM2(exit, void, sched_exit, struct proc *, p,
+ struct thread *, childtd)
+DEFINE_SHIM2(fork, void, sched_fork, struct thread *, td,
+ struct thread *, childtd)
+DEFINE_SHIM1(fork_exit, void, sched_fork_exit, struct thread *, td)
+DEFINE_SHIM2(class, void, sched_class, struct thread *, td, int, class)
+DEFINE_SHIM2(nice, void, sched_nice, struct proc *, p, int, nice)
+DEFINE_SHIM0(ap_entry, void, sched_ap_entry)
+DEFINE_SHIM2(exit_thread, void, sched_exit_thread, struct thread *, td,
+ struct thread *, child)
+DEFINE_SHIM1(estcpu, u_int, sched_estcpu, struct thread *, td)
+DEFINE_SHIM2(fork_thread, void, sched_fork_thread, struct thread *, td,
+ struct thread *, child)
+DEFINE_SHIM2(ithread_prio, void, sched_ithread_prio, struct thread *, td,
+ u_char, prio)
+DEFINE_SHIM2(lend_prio, void, sched_lend_prio, struct thread *, td,
+ u_char, prio)
+DEFINE_SHIM2(lend_user_prio, void, sched_lend_user_prio, struct thread *, td,
+ u_char, pri)
+DEFINE_SHIM2(lend_user_prio_cond, void, sched_lend_user_prio_cond,
+ struct thread *, td, u_char, pri)
+DEFINE_SHIM1(pctcpu, fixpt_t, sched_pctcpu, struct thread *, td)
+DEFINE_SHIM2(prio, void, sched_prio, struct thread *, td, u_char, prio)
+DEFINE_SHIM2(sleep, void, sched_sleep, struct thread *, td, int, prio)
+DEFINE_SHIM2(sswitch, void, sched_switch, struct thread *, td, int, flags)
+DEFINE_SHIM1(throw, void, sched_throw, struct thread *, td)
+DEFINE_SHIM2(unlend_prio, void, sched_unlend_prio, struct thread *, td,
+ u_char, prio)
+DEFINE_SHIM2(user_prio, void, sched_user_prio, struct thread *, td,
+ u_char, prio)
+DEFINE_SHIM1(userret_slowpath, void, sched_userret_slowpath,
+ struct thread *, td)
+DEFINE_SHIM1(pctcpu_delta, fixpt_t, sched_pctcpu_delta, struct thread *, td)
+DEFINE_SHIM2(add, void, sched_add, struct thread *, td, int, flags)
+DEFINE_SHIM0(choose, struct thread *, sched_choose)
+DEFINE_SHIM2(clock, void, sched_clock, struct thread *, td, int, cnt)
+DEFINE_SHIM1(idletd, void, sched_idletd, void *, dummy)
+DEFINE_SHIM1(preempt, void, sched_preempt, struct thread *, td)
+DEFINE_SHIM1(relinquish, void, sched_relinquish, struct thread *, td)
+DEFINE_SHIM1(rem, void, sched_rem, struct thread *, td)
+DEFINE_SHIM2(wakeup, void, sched_wakeup, struct thread *, td, int, srqflags)
+DEFINE_SHIM2(bind, void, sched_bind, struct thread *, td, int, cpu)
+DEFINE_SHIM1(unbind, void, sched_unbind, struct thread *, td)
+DEFINE_SHIM1(is_bound, int, sched_is_bound, struct thread *, td)
+DEFINE_SHIM1(affinity, void, sched_affinity, struct thread *, td)
+DEFINE_SHIM0(sizeof_proc, int, sched_sizeof_proc)
+DEFINE_SHIM0(sizeof_thread, int, sched_sizeof_thread)
+DEFINE_SHIM1(tdname, char *, sched_tdname, struct thread *, td)
+DEFINE_SHIM1(clear_tdname, void, sched_clear_tdname, struct thread *, td)
+DEFINE_SHIM0(do_timer_accounting, bool, sched_do_timer_accounting)
+DEFINE_SHIM1(find_l2_neighbor, int, sched_find_l2_neighbor, int, cpu)
+DEFINE_SHIM0(init_ap, void, schedinit_ap)
static char sched_name[32] = "ULE";
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27918639
Default Alt Text
D54831 proposal (12 KB)
Attached To
Mode
P685 D54831 proposal
Attached
Detach File
Event Timeline
Log In to Comment