casperes1996
Site Champ
- Joined
- Nov 29, 2021
- Posts
- 325
Wasn't aware it kept both. Thought the priority rebalancing changed the base priority in-place. Makes sense.To speak to your comment about priority rebalancing, here's something to consider: the scheduler priority isn't used when recommending P or E cores for a thread, only the base priority. So this sort of rebalancing wouldn't have the effect of changing the recommendation.
I've mostly been reading through the code since I'm curious. There's certainly pieces that I haven't gleaned yet, but so far the key things driving things that I see in the code match up with the sort of analysis that eclecticlight.co has been doing on the scheduler's behavior. About the only thing I haven't seen in action yet that I've read in the code are around trying to keep threads within the same group on the same CPU cluster. Possibly because it's not a common case where you've got threads in a group with different base priorities. However, it does also apply for keeping those threads on the same P cores rather than having them spread across the two different CPU clusters on the M1 Pro/Max.
Any tips for reading the source? Did you just start in osfmk/sched.h and move on from there? Or the affinity.c/h files? They seem to be pretty closely tied to thread-core placement.
It also looks like the XNU documentation section on adding a custom sys call has been removed from the GitHub page though the heading is still there which is pretty odd