The Lock Holder and the Lock Waiter Pre-Emption Problems: Nip Them In

The Lock Holder and the Lock Waiter Pre-Emption Problems: Nip Them In

The lock holder and the lock waiter pre-emption problems: nip them in the bud using informed spinlocks (I-Spinlocks) Boris Djomgwe Teabe, Vlad-Tiberiu Nitu, Alain Tchana, Daniel Hagimont To cite this version: Boris Djomgwe Teabe, Vlad-Tiberiu Nitu, Alain Tchana, Daniel Hagimont. The lock holder and the lock waiter pre-emption problems: nip them in the bud using informed spinlocks (I-Spinlocks). European Conference on Computer Systems (EuroSys 2017), Apr 2017, Belgrade, Serbia. pp.286-297. hal-02604135 HAL Id: hal-02604135 https://hal.archives-ouvertes.fr/hal-02604135 Submitted on 16 May 2020 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. Open Archive Toulouse Archive Ouverte OATAO is an open access repository that collects the work of Toulouse researchers and makes it freely available over the web where possible This is an author’s version published in: https://oatao.univ-toulouse.fr/22297 To cite this version: Djomgwe Teabe, Boris and Nitu, Vlad-Tiberiu and Tchana, Alain- Bouzaïde and Hagimont, Daniel The lock holder and the lock waiter pre-emption problems: nip them in the bud using informed spinlocks (I-Spinlocks). (2017) In: European Conference on Computer Systems (EuroSys 2017), 23 April 2017 - 26 April 2017 (Belgrade, Serbia). Any correspondence concerning this service should be sent to the repository administrator: [email protected] The lock holder and the lock waiter pre-emption problems: nip them in the bud using informed spinlocks (I-Spinlock) Boris Teabe Vlad Nitu Alain Tchana Daniel Hagimont Toulouse University, France fi[email protected] Abstract kernel called the hypervisor is running on the real hardware and provides the illusion of several hardwares (called virtual In native Linux systems, spinlock’s implementation relies machines - VM) on top of which guest operating systems on the assumption that both the lock holder thread and lock can be run. waiter threads cannot be preempted. However, in a virtual- In operating systems, spinlock is the lowest-level mutual ized environment, these threads are scheduled on top of vir- exclusion mechanism for synchronizing access to shared tual CPUs (vCPU) that can be preempted by the hypervisor data structures in the kernel on multicore architectures. Its at any time, thus forcing lock waiter threads on other vC- implementation has a significant impact on performance and PUs to busy wait and to waste CPU cycles. This leads to scalability of operating systems and applications [28, 29]. In the well-known Lock Holder Preemption (LHP) and Lock native Linux systems, spinlock’s implementation relies on Waiter Preemption (LWP) issues. the assumption that the locking primitive is not preemptable In this paper, we propose I-Spinlock (for Informed Spin- on its execution core. lock), a new spinlock implementation for virtualized envi- However, in a virtualized environment, even if the guest ronments. Its main principle is to only allow a thread to OS scheduler does not allow preemption within the lock- acquire a lock if and only if the remaining time-slice of its ing primitive, the guest OS (and more precisely its vCPUs) vCPU is sufficient to enter and leave the critical section. can be preempted by the hypervisor at any time, leading to This is possible if the spinlock primitive is aware (informed) the well-known Lock Holder Preemption (LHP) and Lock of its time-to-preemption (by the hypervisor). Waiter Preemption (LWP) issues. The LHP problem arises We implemented I-Spinlock in the Xen virtualization sys- when a lock holder running on a vCPU is preempted by the tem. We show that our solution is compliant with both para- hypervisor, thus forcing other lock waiter threads running on virtual and hardware virtualization modes. We performed other vCPUs from the same VM to perform useless spinning extensive performance evaluations with various reference and to waste CPU cycles. The LWP problem arises when a benchmarks and compared our solution to previous solu- lock waiter (with a ticket, tickets enforcing an order among tions. The evaluations demonstrate that I-Spinlock outper- waiters) is preempted, thus forcing other waiters with higher forms other solutions, and more significantly when the num- ticket numbers to busy wait even if the lock was freed. ber of core increases. Several research works addressed these issues. Many Keywords spinlocks; multi-core; scheduler; virtual ma- of them consist in detecting the problematic busy waiting chine threads and scheduling the vCPUs of these threads out, in or- der to reduce wasted cycles. [1] proposes to monitor pause 1. Introduction instructions from the hypervisor in order to detect busy wait- The last decade has seen the widespread of virtualized en- ing vCPUs. [5, 6, 7] introduce a hypercall in paravirtual vironments, especially for the management of cloud com- systems, enabling the lock primitive to release the processor puting infrastructures which implement the Infrastructure as when busy waiting is detected. [8, 9] propose to enforce a Service (IaaS) model. In virtualized systems, a low level the simultaneous execution (coscheduling) of all vCPUs of the same VM, thus avoiding LHP and LWP. [10, 11, 25] propose to reduce the time-slice so that a preempted vCPU is rescheduled quickly. All these works tolerate LHP and LWP, but aim at limiting the side effects of LHP and LWP. Comparatively, our solution aims at limiting and almost can- celling the occurrences of LHP and LWP. DOI: http://dx.doi.org/10.1145/3064176.3064180 In this paper, we propose I-Spinlock (for Informed Spin- are generally used for short duration locking. The critical lock), a new spinlock implementation for virtualized envi- section is supposed to be rapidly freed by the holder thread ronments. The main principle is to only allow a thread running on a different core. Spinlocks have a great deal of in- to acquire a lock if and only if its time-to-preemption fluence on safety and performance of the kernel. Therefore, is sufficient to wait for its turn (according to its ticket several studies have investigated their improvement in Linux number), enter and leave the critical section. Therefore, kernels [28, 29, 24], which is the research context of this I-Spinlock prevents LHP and LWP instead of detecting paper. The rest of this section presents the two main spin- them and limiting their effects. In order to implement it, lock improvements in Linux systems, embodied in kernel the spinlock primitive has to be aware (informed) of its versions ≤ 2.6.24 and kernel versions ≥ 2.6.25. time-to-preemption (provided by the hypervisor). We im- Spinlocks in kernel versions ≤ 2.6.24. In these versions, a plemented I-Spinlock in the Xen virtualization system [31]. spinlock is implemented with an integer (hereafter noted l) We performed extensive performance evaluations with var- which indicates whether the lock is available or held. The ious reference benchmarks (Kerbench, Pbzip2 and Ebizzy) lock is acquired by decrementing and reading the value of l and compared our solution to previous solutions. First, the (with an atomic instruction). If the returned value is zero, the evaluation results show that I-Spinlock does not compromize thread acquires the lock. Otherwise, the thread is blocked. l fairness and liveness and it does not incur any overhead on is set to one when the thread releases the lock. During the performance. Second, I-Spinlock is able to almost cancel blocked state, the thread spins testing l. It stops spinning LHP and LWP, leading to significant performance improve- when l becomes positive. The main shortcoming of this im- ments compared to standard Linux ticket spinlocks. Finally, plementation is unfairness. Indeed, there is no way to ensure we compared our prototype with four existing solutions: that the thread which has been waiting the longest time ob- para-virtualized ticket spinlock [6], preemptable ticket spin- tains the lock first. This can lead to starvation. This issue was lock [5], time slice reduction solution [10] and Oticket [7]. addressed in Linux kernel versions greater than 2.6.24. The obtained results show that I-Spinlock outperforms all Spinlocks in kernel versions ≥ 2.6.25. In these versions, these solutions: up to 15% for para-virtualized ticket spin- spinlocks are implemented with a data structure called ticket lock, up to 60% for preemptable ticket spinlock, up to 25% spinlock, which includes two integer fields namely head and for time slice reduction, and up to 8% for Oticket when the tail. These fields in a lock are respectively initialized to one number of core increases. and zero. Each time a thread attempts to acquire the lock, it In summary, this paper makes the following contribu- first increments the value of tail and then makes a copy of it. tions: This operation is called taking a ticket and the ticket num- ber is the value of this copy. The acquisition of the lock by • We introduce I-Spinlock, a new spinlock implementation a thread is allowed if its ticket number is equal to the lock’s which avoids LHP and LWP in both types of virtualiza- head. The release of the lock is followed by the incremen- tion (paravirtual and hardware-assisted); tation of its head. This way, the lock is acquired in a FIFO • We implemented I-Spinlock in the Linux kernel and the (First In First Out) order.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    14 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us