Page MenuHomeFreeBSD

Use 256 run queues, with 1 priority per queue
Needs ReviewPublic

Authored by vangyzen on Mar 29 2017, 7:38 PM.
Tags
None
Referenced Files
F83407415: D10188.diff
Fri, May 10, 2:36 AM
Unknown Object (File)
Wed, Apr 24, 6:37 PM
Unknown Object (File)
Apr 7 2024, 3:56 AM
Unknown Object (File)
Mar 4 2024, 10:06 AM
Unknown Object (File)
Dec 20 2023, 2:34 AM
Unknown Object (File)
Jun 10 2023, 8:36 PM
Unknown Object (File)
Apr 5 2023, 9:47 PM
Unknown Object (File)
Jan 8 2023, 9:50 AM

Details

Reviewers
jeff
manu
Summary

The FreeBSD schedulers assign four priorities to each run queue, making those priorities effectively equal. This breaks the POSIX real-time priority API.

Applications that use real-time scheduling use sched_get_priority_min() and [[ http://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_get_priority_max.html | sched_get_priority_max() ]] to determine the available range of priorities, and then use simple arithmetic to assign relatively higher or lower priorities. If an application configures two threads with priorities max and max-1 (for example), POSIX says the thread at priority max must be chosen if it is runnable. Since our implementation puts these two priorities in the same run queue, it may choose either thread, so it does not conform.

The above functions currently return 0 and 31, respectively. One solution would change ...max() to return 7 and change other code to translate the 8 POSIX values into the 32 FreeBSD values. However, this would also not conform, because "conforming implementations shall provide a priority range of at least 32 priorities for this policy."

I propose that we assign one priority per run queue. This would conform to POSIX. On a certain commercial block storage product, this change made no difference in performance. Benchmarks of buildworld on two different machines actually showed a tiny improvement in performance.

Assigning 4 priorities per run queue also caused a recent portability issue in ZFS, although that was fixed by r314058.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 8373
Build 8645: arc lint + arc unit

Event Timeline

At work, I built a version of our environment based on head/amd64 @314568, then built another after applying this set of patches. I have been running this pair of images on several (matched pairs) of our "appliances" since about 2017-04-10 03:00:00 UTC -- almost 36 hrs. as of this writing. So far, there's been no apparent difference in behavior for our workload (that I have been able to detect).

I have no basis to comment on this patch. I suggest you contact jeffr@.

I added jeff@. As noted earlier I can't comment on the patch itself.

However, the kernel improved a lot since this revision was created and a repeated test has higher chances of showing the difference (if any).

However, the kernel improved a lot since this revision was created and a repeated test has higher chances of showing the difference (if any).

Thanks. The intent is POSIX compliance, not a performance improvement. Any discussion of performance is only to show no regression.

I had forgotten about this proposed change. I had also forgotten about this mailing-list thread, in which @imp asked a very good question that I missed (or forgot about) and can't answer without some more research:

https://lists.freebsd.org/pipermail/freebsd-hackers/2017-March/050811.html