lock holder preemption problem in multiprocessor
play

Lock Holder Preemption Problem in Multiprocessor Virtualization - PowerPoint PPT Presentation

Lock Holder Preemption Problem in Multiprocessor Virtualization Burak Selcuk RheinMain University of Applied Sciences Informatik Master August 24, 2017 Burak Selcuk LHP Problem in Multiprocessor Virtualization 1 / 18 Table of Contents


  1. Lock Holder Preemption Problem in Multiprocessor Virtualization Burak Selcuk RheinMain University of Applied Sciences Informatik Master August 24, 2017 Burak Selcuk LHP Problem in Multiprocessor Virtualization 1 / 18

  2. Table of Contents Introduction 1 Basics 2 Spinlocks Virtualization Lock Holder Preemption Solutions 3 Overview Co-scheduling Guest OS Modification Solution in practice 4 Burak Selcuk LHP Problem in Multiprocessor Virtualization 2 / 18

  3. Introduction Motivation Virtualization is widely used and the fundamental of Cloud Computing Guest OS (should) behave like they are running on a physical machine without knowing they are virtualized Process synchronization techniques rely on assumptions that may not hold when an OS is virtualized Violating those assumptions can cause critical performance issues Spinlock mechanism is one of them! Burak Selcuk LHP Problem in Multiprocessor Virtualization 3 / 18

  4. Basics Spinlocks Spinlocks Inside the kernel, spinlocks are the lowest-level mutual exclusion mechanism Spinlocks uses busy waiting whenever the lock is taken by another thread This wastes CPU resources, but critical sections in kernel are usually short and fast busy waiting is less expensive than doing a context switch Most important: spinlocks rely on the assumption that the lock holder is not preempted while holding the spinlock Burak Selcuk LHP Problem in Multiprocessor Virtualization 4 / 18

  5. Basics Virtualization Overcommitment Virtual machines share the hardware resources of the physical machine A VM gets a number of virtual CPUs (vCPUs) assigned, which are then assigned to the physical CPUs (pCPU) by the hypervisor The total number of vCPUs is usually larger than the number of pCPUs, this situation is called overcommitment Whenever an overcommitment happens, there are always inactive vCPUs Burak Selcuk LHP Problem in Multiprocessor Virtualization 5 / 18

  6. Basics Virtualization Example of Overcommitment VM 0 VM 1 vCPU vCPU vCPU vCPU vCPU vCPU 0-0 0-1 1-0 1-1 1-2 1-3 CPU Scheduler Hypervisor pCPU pCPU pCPU pCPU Hardware 0 1 2 3 Burak Selcuk LHP Problem in Multiprocessor Virtualization 6 / 18

  7. Basics Virtualization Scheduling Process and CPU scheduling happens on two layers: Guest OS scheduler assigns the process to the vCPUs like usually Hypervisor schedules the vCPUs to the pCPUs Each vCPU gets a time slice of execution until it gets preempted by the hypervisor A time slice duration is several microseconds (30-50ms) Burak Selcuk LHP Problem in Multiprocessor Virtualization 7 / 18

  8. Basics Lock Holder Preemption Lock Holder Preemption Problem Preemption Preemption through hypervisor through hypervisor Acquire lock, Leave critical section, enter critical section free lock pCPU 0 vCPU 0 vCPU 2 vCPU 0 pCPU 1 vCPU 1 Busy waiting CPU wasting VM A (caused by LHP) Acquire lock, Acquire lock, VM B start busy waiting enter critical section Burak Selcuk LHP Problem in Multiprocessor Virtualization 8 / 18

  9. Solutions Overview Solutions for LHP problem Co-Scheduling / Gang-Scheduling Guest OS modification Monitoring through hypervisor Burak Selcuk LHP Problem in Multiprocessor Virtualization 9 / 18

  10. Solutions Co-scheduling Co-scheduling Scheduling technique for multiprocessor systems Published by John Ousterhout in 1982 Idea: Threads that communicate should be scheduled concurrently Transferred to virtualization for CPU scheduling Hypervisor assigns all vCPUs of a VM simultaneously, LHP problem can not occur ...but it can cause CPU fragmentation and priority inversion! Burak Selcuk LHP Problem in Multiprocessor Virtualization 10 / 18

  11. Solutions Co-scheduling Example of Co-scheduling Time Slice pCPU 0 vCPU 0 vCPU 2 vCPU 4 vCPU 0 pCPU 1 vCPU 1 vCPU 3 idle vCPU 1 Time VM A VM B VM C Burak Selcuk LHP Problem in Multiprocessor Virtualization 11 / 18

  12. Solutions Co-scheduling CPU Fragmentation and Priority Inversion ready at T1 ready at T0 higher priority pCPU 0 vCPU 0 vCPU 1 I/O vCPU 0 pCPU 1 idle vCPU 2 vCPU 3 idle T3 T0 T1 T2 VM A VM B VM C Burak Selcuk LHP Problem in Multiprocessor Virtualization 12 / 18

  13. Solutions Guest OS Modification Guest OS Modification Hypervisor offers hypercalls to inform him about lock holding or spinning Source code necessary, each hypervisor may has different interface Suitable for para-virtualization Two possibilities: Preemption delay (lock holder) Notify hypervisor during long spinning (lock waiter) Burak Selcuk LHP Problem in Multiprocessor Virtualization 13 / 18

  14. Solutions Guest OS Modification Preemption delay Leave critical section, Acquire lock, Preemption point, check flag, make hypercall to delay preemption, make hypercall to delay preemption for set flag reschedule vCPU n microseconds pCPU 0 vCPU 0 at most n microseconds Burak Selcuk LHP Problem in Multiprocessor Virtualization 14 / 18

  15. Solutions Guest OS Modification Threshold for Spinning Stop spinning after a number of iterations Will not avoid LHP but limit side effects of it After n iterations, make a hypercall to inform hypervisor about long spinning Hypervisor decides to preempt lock waiter vCPU and schedules another one of the same VM Good choice: lock holder vCPU Bad choice: another lock waiter, resulting in spinning again Burak Selcuk LHP Problem in Multiprocessor Virtualization 15 / 18

  16. Solution in practice Which solution is used? VMware vSphere: Uses co-scheduling as customized, relaxed version Limits LHP and CPU fragmentation Xen and KVM: Both hypervisor offer interfaces to notify about long spinning Implemented in Linux spinlock code Microsoft Hyper-V: No co-scheduling necessary, Windows is major guest OS Offers hypercalls for long spinning like in Xen/KVM Probably used in Windows, usage in Linux may be possible Burak Selcuk LHP Problem in Multiprocessor Virtualization 16 / 18

  17. End The End Thanks for your attention! Any questions? Burak Selcuk LHP Problem in Multiprocessor Virtualization 17 / 18

  18. End Monitoring through Hypervisor Monitoring through Hypervisor Approaches whenever guest OS modification is not possible Recognize every entering and leaving of the kernel mode Safe state: Guest OS in user mode. No spinlock is hold. Preemption safe. Unsafe state: Guest OS in kernel mode. Spinlock may be hold. Preemption unsafe. Monitor guest OS instructions, e.g. IA-32 HLT (power saving) Use fake device driver, guest OS is in user mode whenever protocol is handled Burak Selcuk LHP Problem in Multiprocessor Virtualization 18 / 18

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend