Bug 197922 - [patch] [sched] Remove random() from sched_ule, add short circuit for non-SMP, non-balancing
Summary: [patch] [sched] Remove random() from sched_ule, add short circuit for non-SMP...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
URL: https://github.com/AstrodogInc/freebs...
Keywords: needs-qa, patch
Depends on:
Blocks:
 
Reported: 2015-02-22 15:16 UTC by Harrison Grundy
Modified: 2015-07-06 22:21 UTC (History)
5 users (show)

See Also:


Attachments
Replace random with get_cyclecount as a suitable source of entropy for the balancer. Short circuit for non-SMP/Balance (656 bytes, patch)
2015-02-22 15:16 UTC, Harrison Grundy
no flags Details | Diff
Remove randomness entirely. (583 bytes, patch)
2015-02-24 04:25 UTC, Harrison Grundy
no flags Details | Diff
Creates sched_random, using the system used in cpu_search. (1.75 KB, patch)
2015-02-25 09:40 UTC, Harrison Grundy
no flags Details | Diff
Updated patch to create sched_random() to provide entropy in the scheduler. (1.76 KB, patch)
2015-02-25 10:34 UTC, Harrison Grundy
no flags Details | Diff
No randomness in scheduler at all (1.64 KB, patch)
2015-02-25 10:40 UTC, Harrison Grundy
no flags Details | Diff
Removes all scheduler randomness (1.89 KB, patch)
2015-02-25 10:54 UTC, Harrison Grundy
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Harrison Grundy 2015-02-22 15:16:32 UTC
Created attachment 153317 [details]
Replace random with get_cyclecount as a suitable source of entropy for the balancer. Short circuit for non-SMP/Balance

As discovered by John-Mark Gurney, ULE uses random() which is not SMP/preemption safe. 

Move the check for SMP and Balancer being enabled above the generation of the balancing interval.
Comment 1 Harrison Grundy 2015-02-24 04:25:31 UTC
Created attachment 153415 [details]
Remove randomness entirely.

Some testing indicates that balancing here may not require any randomness at all.
Comment 2 Harrison Grundy 2015-02-25 09:40:20 UTC
Created attachment 153513 [details]
Creates sched_random, using the system used in cpu_search.

Another option.

If this doesn't work, I suppose we could put an actual PRNG in here, or bitshift get_cyclecount.
Comment 3 Ivan Klymenko 2015-02-25 10:01:15 UTC
Do I understand correctly that now patch " Remove randomness entirely." is no longer needed?
Comment 4 Harrison Grundy 2015-02-25 10:04:49 UTC
(In reply to Ivan Klymenko from comment #3)

Each of the 3 patches solves the problem in a slightly different way. There's some discussion on -arch about which approach makes the most sense here, so I was planning to just leave them up until a decision is made.
Comment 5 Harrison Grundy 2015-02-25 10:34:11 UTC
Created attachment 153514 [details]
Updated patch to create sched_random() to provide entropy in the scheduler.

Whoops. Forgot to have it "reseed". Thanks Konstantin Belousov.
Comment 6 Harrison Grundy 2015-02-25 10:40:50 UTC
Created attachment 153515 [details]
No randomness in scheduler at all
Comment 7 Harrison Grundy 2015-02-25 10:54:54 UTC
Created attachment 153516 [details]
Removes all scheduler randomness

Forgot the high group. One of those days...
Comment 8 Pedro F. Giffuni freebsd_committer 2015-07-06 22:21:59 UTC
sched_random() was committed in r279349 (by imp) and further refined afterwards.