SLIDE 1 Avoiding Scheduler Subversion using Scheduler-Cooperative Locks
Yuvraj Patel, Leon Yang, Leo Arulraj, Andrea Arpaci-Dusseau, Remzi Arpaci-Dusseau, Michael Swift University of Wisconsin-Madison
SLIDE 2
Once upon a time ....
P0 P1
Accessing a kernel service
1 Processes
SLIDE 3
P0 P1
Accessing a kernel service Default priority
1 Processes
Once upon a time ....
SLIDE 4 P0 P1
Accessing a kernel service Default priority
1 Processes
Once upon a time ....
*Linux CFS Scheduler
SLIDE 5
Schedulers are important for resource sharing
2
SLIDE 6
Let us now introduce a lock....
3
SLIDE 7
A ticket lock reduces wait-time and avoids starvation
4
SLIDE 8
If P0 holds the lock twice as long as P1
5
SLIDE 9 If P0 holds the lock twice as long as P1
5
P1 P0
Time
SLIDE 10 If P0 holds the lock twice as long as P1
5
P1 P0
Time
While in critical section, P0 uses twice much CPU as P1
SLIDE 11 If P0 holds the lock twice as long as P1
5
P1 P0
Time
SLIDE 12 If P0 holds the lock twice as long as P1
5
P1 P0
Time
SLIDE 13 If P0 holds the lock twice as long as P1
5
P1 P0
Time
Every time P0 enters critical section, it uses twice as much CPU as P1
SLIDE 14
6
Despite 50:50 allocation, P0 uses twice as much CPU as P1's
SLIDE 15
Locks determine the CPU allocation instead of the scheduler
7 Scheduler Subversion
SLIDE 16
When does scheduler subversion happen?
8
SLIDE 17
Two reasons
9
SLIDE 18
Different critical section lengths
10
SLIDE 19
11
Different critical section lengths
Thread dwelling longer in critical section becomes dominant user of CPU
SLIDE 20
Majority locked run time
12
SLIDE 21 Majority locked run time
Lock–Unlock: Is That All? A Pragmatic Analysis of Locking in Software
- Systems. ACM Trans. Comput. Syst.,36(1), March 2019.
Remote Core Locking: Migrating Critical-Section Execution to Improve the Performance of Multithreaded Applications. USENIX ATC 2012 Understanding Manycore Scalability of File Systems, USENIX ATC 2016 Non-scalable locks are dangerous. Linux Symposium, 2012 1. 2. 3. 4.
13
Threads have to spend a lot
- f time in the critical section
and it is often a case
1, 2, 3, 4
SLIDE 22
Every concurrent system can be prone to scheduler subversion
14
SLIDE 23
Remedy
15
SLIDE 24
Track lock usage of users
16
Three design components
SLIDE 25 Track lock usage of users
16
P1 P0 x Track the time spent by each process in critical section
Example
Three design components
SLIDE 26 Track lock usage of users
16
P1 P0 x 2x Track the time spent by each process in critical section
Example
Three design components
SLIDE 27 16
P1 P0 x 2x
Track lock usage of users Penalize dominant users Example
Three design components
SLIDE 28 Track lock usage of users Penalize dominant users
16
Penalize while acquiring the lock again P1 P0 x 2x
Example
Three design components
SLIDE 29 Track lock usage of users Penalize dominant users
16
P1 P0 x 2x x
Example
Three design components
SLIDE 30 16
P1 P0 x 2x x
Track lock usage of users Penalize dominant users Provide appropriate
Example
Three design components
SLIDE 31 16
P1 P0 x 2x x x Penalizing P0 creates enough opportunity to let P1 acquire the lock multiple times
Track lock usage of users Penalize dominant users Provide appropriate
Example
Three design components
SLIDE 32 16
P1 P0 x 2x x x Opportunity depends on the scheduling goals
Track lock usage of users Penalize dominant users Provide appropriate
Example
Three design components
SLIDE 33 Scheduler-Cooperative Locks (SCL)
17
Ticket Lock SCL
SLIDE 34
Conclusion
We introduce the scheduler subversion problem We introduce scheduler- cooperative locks (SCL) to mitigate scheduler subversion
SLIDE 35
Thank you!!! Queries??