Page MenuHomeFreeBSD

mi_switch(): clean up switch types and their usage
ClosedPublic

Authored by mhorne on Jan 24 2023, 9:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 22 2024, 6:38 PM
Unknown Object (File)
Jan 1 2024, 12:59 PM
Unknown Object (File)
Jan 1 2024, 12:59 PM
Unknown Object (File)
Jan 1 2024, 12:59 PM
Unknown Object (File)
Dec 29 2023, 8:20 AM
Unknown Object (File)
Dec 29 2023, 8:07 AM
Unknown Object (File)
Dec 22 2023, 11:42 PM
Unknown Object (File)
Jul 10 2023, 5:10 AM
Subscribers

Details

Summary

Overall, this is a non-functional change, except for kernels built with
SCHED_STATS. However, the switch types are useful for communicating the
intent of the caller.

  1. Ensure that every caller provides a type. In most cases, we upgrade the basic yield to sched_relinquish() aka SWT_RELINQUISH.
  2. The case of sched_bind() is distinct, so add a new switch type SWT_BIND.
  3. Remove the two unused types, SWT_PREEMPT and SWT_SLEEPQTIMO.
  4. Remove SWT_NONE altogether and assert that callers always provide a type flag.
  5. Reference the mi_switch(9) man page in the comments, as these flags will be documented there.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Jan 24 2023, 10:06 PM

Expand the scope of the change. Modify callers that don't currently specify a switch reason, and forbid it going forward. Add SWT_BIND for sched_bind(), which IMO is distinct from existing cases.

This revision now requires review to proceed.Jan 30 2023, 7:28 PM
mhorne retitled this revision from mi_switch: trim unused type flags to mi_switch(): clean up switch types and their usage.Jan 30 2023, 7:29 PM
mhorne edited the summary of this revision. (Show Details)
mhorne added inline comments.
sys/kern/kern_switch.c
87–88

FYI this does mean we have an unused slot at index zero.

markj added inline comments.
sys/kern/kern_switch.c
87–88

Not the end of the world, really. If it's really important we could subtract one when selecting the counter.

Another minor cleanup might be to make these an array of counter(9) instead. We didn't have that facility when these counters were added.

This revision is now accepted and ready to land.Jan 30 2023, 8:17 PM

I just pushed a change to lua loader, but got a compile error message back from ci:

usr/src/sys/kern/kern_poll.c:568:4: error: call to undeclared function 'sched_relinquish'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration]

sched_relinquish(td);

and git log -S sched_relinquish pointed me here...

In D38184#875473, @imp wrote:

I just pushed a change to lua loader, but got a compile error message back from ci:

usr/src/sys/kern/kern_poll.c:568:4: error: call to undeclared function 'sched_relinquish'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration]

sched_relinquish(td);

and git log -S sched_relinquish pointed me here...

Thanks, should be fixed by rG78919798e79e.