Page MenuHomeFreeBSD

fix a thread preemption regression in schedulers introduced in r270423
ClosedPublic

Authored by avg on Jan 18 2017, 12:12 PM.
Tags
None
Referenced Files
F108322304: D9230.diff
Thu, Jan 23, 8:50 PM
Unknown Object (File)
Wed, Jan 22, 9:29 AM
Unknown Object (File)
Wed, Dec 25, 6:34 AM
Unknown Object (File)
Dec 9 2024, 1:51 AM
Unknown Object (File)
Dec 6 2024, 12:27 PM
Unknown Object (File)
Nov 24 2024, 6:44 PM
Unknown Object (File)
Oct 3 2024, 1:34 AM
Unknown Object (File)
Oct 1 2024, 9:51 AM
Subscribers

Details

Summary

Commit r270423 fixed a regression in sched_yield() that was introduced in
earlier changes. Unfortunately, at the same time it introduced an new regression.
The problem is that SWT_RELINQUISH (6), like all other SWT_* constants and unlike
SW_* flags, is not a bit flag. So, flags & SWT_RELINQUISH is true in cases where
that was not really indended, for example, with SWT_OWEPREEMPT (2) and
SWT_REMOTEPREEMPT (11).

A straight forward fix would be to use (flags & SW_TYPE_MASK) == SWT_RELINQUISH,
but my impression is that the switch types are designed mostly for gathering
statistics, not for influencing scheduling decisions.

So, I decided that it would be better to check for SW_PREEMPT flag instead.
That's also the same flag that was checked before r239157.
I double-checked how that flag is sed and I am confident that the flag is set only
in the places where we really have preemption:

  • critical_exit + td_owepreempt
  • sched_preempt in the ULE scheduler
  • sched_preempt in the 4BSD scheduler

This work is sponsored by Panzura.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 6855
Build 7058: arc lint + arc unit

Event Timeline

avg retitled this revision from to fix a thread preemption regression in schedulers introduced in r270423.
avg updated this object.
avg edited the test plan for this revision. (Show Details)
avg added reviewers: jhb, kib, mav.
kib edited edge metadata.
This revision is now accepted and ready to land.Jan 18 2017, 12:37 PM
avg edited edge metadata.
mav edited edge metadata.

Looks fine, but I don't remember what was I thinking then.

This revision was automatically updated to reflect the committed changes.