From nobody Wed Feb 11 05:17:17 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4f9mrt0j0sz6RtRL for ; Wed, 11 Feb 2026 05:17:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4f9mrs5P5Yz3SLc for ; Wed, 11 Feb 2026 05:17:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1770787037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MJ5FWtri92WB104Y13Q1rt3NlqxcJUtudp3mPNWgdKo=; b=TpEK/FcIWzoq2rRg42JCQ/et+Sizk1srH6T3s2h6Um3lkLz4C8DjKlgS3Z78IDdQfbG4Ap 0AdhXnmiGxl33TXi1AtvkM2w7qVTkJ+wuE5AXe1HGRENOJZK4ka2eJfu6tcRzDybpjN5r0 Fo+pULTFUSJp1RnVUyh2LYw7XaLjPxl57TpizBRNSjlOWXnPGtwHM1Yvzoe1utmdtm9AdN zanpboupbwLjPVEe6PmAkbc2xHFFuKv3SHst7plYwnCFTtRpj/KMzp5/c19pqlagftddNm aNE2HjOhikrYf5nwsLjcrz6d9JfWEqq3DUnqtDmNpMbCWY8qVMzbvq8O9yi/bQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1770787037; a=rsa-sha256; cv=none; b=jyYmA48JsKNn1JgKZ8DUq10ytOvEFtJ+fKBxciloM8kAVkyi2nYrAnFVKUs8i5NtcENQ0k SR3W9VAQbHkOI8/gd7KcfKiQOw9et6e0rsm/HCFODh5Wi4RoVNiBp5St1j50aMZEWGQT7S qM+tV/Yoi+gAtfI6KS4QhuHs/3l0MMzWY+tC13KwdEYGWsLydEOT/SRCbxQJ9B/GxLP6Jh 7TPpUKXaK9kOFKcSTFMds3z+ED1MbGfXNR7iq3yYIZDhjoMWfHn2tYdbk6nWooXd6/lHf1 SJxf25n8In2yV9FWaunSdbCgGqhYI15igqW83CR1T6pUIXiMGh9WvVWFz08N8A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1770787037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MJ5FWtri92WB104Y13Q1rt3NlqxcJUtudp3mPNWgdKo=; b=PGxfO0M5zK0MmfEs4zfAX3YcY1dJHWl0b62hZlCp1jA60O4Uqs12x2Bkak4VsPMByXkD0w WWSF2yq8xzVQFAVvtx6JASdj1T1CG2l//B/2iE40i4Wug+vqvgQdY0yH4Ht6jufzsgIO+i WKz/bZLwwW76zfBF7Og/Ngx08iWOytXdWUL2JPEJ/lJTm0hN6evvmXk+v69ehTBkNKXfN1 HBywRTlbtdzGDxPL2VS99DjHXIcpqTBAThmGFsElTcCQNPy6bqu5tMfZZeOw2u95TXR2Ou G0q4xeWBYCEesfyYZrRzeTf+QlwUEoGmUadXKKDf9p+pn6payBY3jkbY/Lv2Jw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4f9mrs4nVMzbtQ for ; Wed, 11 Feb 2026 05:17:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 25bef by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 11 Feb 2026 05:17:17 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 9c5067a07b2e - stable/15 - Add kern/sched_shim.c List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 9c5067a07b2e9b3fde2c12eab3bb297e7d46d00b Auto-Submitted: auto-generated Date: Wed, 11 Feb 2026 05:17:17 +0000 Message-Id: <698c10dd.25bef.242132f@gitrepo.freebsd.org> The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9c5067a07b2e9b3fde2c12eab3bb297e7d46d00b commit 9c5067a07b2e9b3fde2c12eab3bb297e7d46d00b Author: Konstantin Belousov AuthorDate: 2026-01-22 04:19:52 +0000 Commit: Konstantin Belousov CommitDate: 2026-02-11 05:12:36 +0000 Add kern/sched_shim.c (cherry picked from commit ce38acee8d0bb35223b227479b9998c77b47f41b) --- sys/conf/files | 1 + sys/kern/sched_shim.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++ sys/sys/sched.h | 48 ++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) diff --git a/sys/conf/files b/sys/conf/files index 20d9fa194b28..e8c9476f29a8 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -3905,6 +3905,7 @@ kern/linker_if.m standard kern/p1003_1b.c standard kern/posix4_mib.c standard kern/sched_4bsd.c optional sched_4bsd +kern/sched_shim.c standard kern/sched_ule.c optional sched_ule kern/serdev_if.m standard kern/stack_protector.c standard \ diff --git a/sys/kern/sched_shim.c b/sys/kern/sched_shim.c new file mode 100644 index 000000000000..079d7d73ec45 --- /dev/null +++ b/sys/kern/sched_shim.c @@ -0,0 +1,94 @@ +/* + * Copyright 2026 The FreeBSD Foundation + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + */ + +#include "opt_sched.h" + +#include +#include +#include +#include +#include +#include +#include + +const struct sched_instance *active_sched; + +#ifndef __DO_NOT_HAVE_SYS_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_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(init_ap, void, schedinit_ap) diff --git a/sys/sys/sched.h b/sys/sys/sched.h index 8f383840192f..b733d4d07e34 100644 --- a/sys/sys/sched.h +++ b/sys/sys/sched.h @@ -239,6 +239,54 @@ void schedinit(void); * Fixup scheduler state for secondary APs */ void schedinit_ap(void); + +struct sched_instance { + int (*load)(void); + int (*rr_interval)(void); + bool (*runnable)(void); + void (*exit)(struct proc *p, struct thread *childtd); + void (*fork)(struct thread *td, struct thread *childtd); + void (*fork_exit)(struct thread *td); + void (*class)(struct thread *td, int class); + void (*nice)(struct proc *p, int nice); + void (*ap_entry)(void); + void (*exit_thread)(struct thread *td, struct thread *child); + u_int (*estcpu)(struct thread *td); + void (*fork_thread)(struct thread *td, struct thread *child); + void (*ithread_prio)(struct thread *td, u_char prio); + void (*lend_prio)(struct thread *td, u_char prio); + void (*lend_user_prio)(struct thread *td, u_char pri); + void (*lend_user_prio_cond)(struct thread *td, u_char pri); + fixpt_t (*pctcpu)(struct thread *td); + void (*prio)(struct thread *td, u_char prio); + void (*sleep)(struct thread *td, int prio); + void (*sswitch)(struct thread *td, int flags); + void (*throw)(struct thread *td); + void (*unlend_prio)(struct thread *td, u_char prio); + void (*user_prio)(struct thread *td, u_char prio); + void (*userret_slowpath)(struct thread *td); + void (*add)(struct thread *td, int flags); + struct thread *(*choose)(void); + void (*clock)(struct thread *td, int cnt); + void (*idletd)(void *); + void (*preempt)(struct thread *td); + void (*relinquish)(struct thread *td); + void (*rem)(struct thread *td); + void (*wakeup)(struct thread *td, int srqflags); + void (*bind)(struct thread *td, int cpu); + void (*unbind)(struct thread *td); + int (*is_bound)(struct thread *td); + void (*affinity)(struct thread *td); + int (*sizeof_proc)(void); + int (*sizeof_thread)(void); + char *(*tdname)(struct thread *td); + void (*clear_tdname)(struct thread *td); + void (*init)(void); + void (*init_ap)(void); +}; + +extern const struct sched_instance *active_sched; + #endif /* _KERNEL */ /* POSIX 1003.1b Process Scheduling */