Avoiding Scheduler Subversion using Scheduler - Cooperative Locks - - PowerPoint PPT Presentation

avoiding scheduler subversion using scheduler cooperative
SMART_READER_LITE
LIVE PREVIEW

Avoiding Scheduler Subversion using Scheduler - Cooperative Locks - - PowerPoint PPT Presentation

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 Once upon a time .... Processes P0 P1


slide-1
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
SLIDE 2

Once upon a time ....

P0 P1

Accessing a kernel service

1 Processes

slide-3
SLIDE 3

P0 P1

Accessing a kernel service Default priority

1 Processes

Once upon a time ....

slide-4
SLIDE 4

P0 P1

Accessing a kernel service Default priority

1 Processes

Once upon a time ....

*Linux CFS Scheduler

slide-5
SLIDE 5

Schedulers are important for resource sharing

2

slide-6
SLIDE 6

Let us now introduce a lock....

3

slide-7
SLIDE 7

A ticket lock reduces wait-time and avoids starvation

4

slide-8
SLIDE 8

If P0 holds the lock twice as long as P1

5

slide-9
SLIDE 9

If P0 holds the lock twice as long as P1

5

P1 P0

Time

slide-10
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
SLIDE 11

If P0 holds the lock twice as long as P1

5

P1 P0

Time

slide-12
SLIDE 12

If P0 holds the lock twice as long as P1

5

P1 P0

Time

slide-13
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
SLIDE 14

6

Despite 50:50 allocation, P0 uses twice as much CPU as P1's

slide-15
SLIDE 15

Locks determine the CPU allocation instead of the scheduler

7 Scheduler Subversion

slide-16
SLIDE 16

When does scheduler subversion happen?

8

slide-17
SLIDE 17

Two reasons

9

slide-18
SLIDE 18

Different critical section lengths

10

slide-19
SLIDE 19

11

Different critical section lengths

Thread dwelling longer in critical section becomes dominant user of CPU

slide-20
SLIDE 20

Majority locked run time

12

slide-21
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
SLIDE 22

Every concurrent system can be prone to scheduler subversion

14

slide-23
SLIDE 23

Remedy

15

slide-24
SLIDE 24

Track lock usage of users

16

Three design components

slide-25
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
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
SLIDE 27

16

P1 P0 x 2x

Track lock usage of users Penalize dominant users Example

Three design components

slide-28
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
SLIDE 29

Track lock usage of users Penalize dominant users

16

P1 P0 x 2x x

Example

Three design components

slide-30
SLIDE 30

16

P1 P0 x 2x x

Track lock usage of users Penalize dominant users Provide appropriate

  • pportunity to each user

Example

Three design components

slide-31
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

  • pportunity to each user

Example

Three design components

slide-32
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

  • pportunity to each user

Example

Three design components

slide-33
SLIDE 33

Scheduler-Cooperative Locks (SCL)

17

Ticket Lock SCL

slide-34
SLIDE 34

Conclusion

We introduce the scheduler subversion problem We introduce scheduler- cooperative locks (SCL) to mitigate scheduler subversion

slide-35
SLIDE 35

Thank you!!! Queries??