diff options
| author | Olivier Certner <olce@FreeBSD.org> | 2026-09-07 16:19:53 +0000 |
|---|---|---|
| committer | Olivier Certner <olce@FreeBSD.org> | 2026-10-06 13:27:41 +0000 |
| commit | 42490d5cd29d7a6acd3c28dacfbdc527c2d39028 (patch) | |
| tree | 61eb01c208e2492e18aa14ca13d2bac1f0b781a8 /sys/modules/ciss/(public-mirror) | |
| parent | b4e2c9abaf14d6eabbce59656d448c064e0dc40b (diff) | |
Define the scheduler interface once and for all (in 'sys/sys/sched.h')
and remove all code duplication related to it (function signatures, slot
names, dispatch, scheduler instance declaration), making it easier to
modify the interface or to add new schedulers.
This is implemented by defining the interface as X macros, which are
passed a macro (and additional arguments for it) that is "called" with
a variable number of arguments describing a single function of the
interface. The convention used for a function's parameters is that each
parameter is represented with two macro arguments, the first one being
the type and the second one being the name. Helper macros allow to
process arguments described in this convention in order to generate
a list of arguments for function definitions (currently, up to
4 function parameters). The chosen convention eliminates the need for
any specific declaration of functions depending on their number of
arguments.
DECLARE_SCHEDULER() has been changed to automatically declare and fill
a 'struct sched_instance' structure. Its number of parameters has been
reduced to the minimum, and the symbol part used to produce distinct
structure names can now start with a digit (useful for 4BSD).
The new implementation has the following additional benefits:
1. The name of implementations for the interface functions is imposed
(same name as the interface function but with the scheduler symbol
that was passed to DECLARE_SCHEDULER() added just after the 'sched_'
prefix, e.g., for ULE, 'sched_ule_*()') and checked at compile-time.
2. Missing functions in an implementation are detected at compile-time
(and not at runtime with a NULL dereference).
3. Failures to fill correctly the 'struct sched_instance' object
associated to an implementation are eliminated.
Preserve comments/categories of interface functions by moving comments
that were in the old explicit interface declarations to the SCHED_ITF*()
macros, and while here, marginally improve some (and move the common
documentation for sched_initticks() from the implementations to the
interface). Several of them are not exact, but this will be fixed in
a separate commit.
Make the active scheduler instance object internal, as it is not used
outside of the shim implementation and one of the purposes of the
interface is also to hide the actual implementation. If the need
arises, it would be easy to add scheduler-specific routines as new
fields in 'struct sched_instance' and to extend the machinery to
automatically assign routines returning EOPNOTSUPP to these fields, and
then to provide a macro to register non-trivial implementation, instead
of making the current instance object visible again.
Additionally, in order to avoid collision with C and C++ keywords:
1. Fields in 'struct sched_instance' are now suffixed with '_impl', so
that, e.g., 'switch()' does not require special treatment anymore and
the corresponding implementations can be renamed back to
`sched_*_switch()`. This suffix avoids any collision with existing
C++ keywords as new functions are added to the interface. (See
SCHED_ITF_FIELD_NAME().)
2. Actual interface functions' C declarations do not list parameter
names anymore (sched_class() was causing a problem in C++ with its
'class' parameter).
allowing to remove the bracketing with '#ifndef __cplusplus'.
Reviewed by: mchoo, kib
Fixes: ce38acee8d0b ("Add kern/sched_shim.c") (+ some followups)
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D59988
Diffstat (limited to 'sys/modules/ciss/(public-mirror)')
0 files changed, 0 insertions, 0 deletions
