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)
Sat, Nov 2, 7:46 PM
Unknown Object (File)
Sep 30 2024, 3:43 PM
Unknown Object (File)
Sep 29 2024, 3:37 PM
Unknown Object (File)
Sep 28 2024, 9:15 PM
Unknown Object (File)
Sep 27 2024, 7:02 AM
Unknown Object (File)
Sep 26 2024, 8:02 AM
Unknown Object (File)
Sep 15 2024, 10:09 PM
Unknown Object (File)
Sep 11 2024, 11:31 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 Passed
Unit
No Test Coverage
Build Status
Buildable 49337
Build 46227: arc lint + arc unit

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

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

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

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.