Giant lock

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

In operating systems, a giant lock, also known as a big-lock or kernel-lock, is a lock that may be used in the kernel to provide concurrency control required by symmetric multiprocessing (SMP) systems.

A giant lock is a solitary global lock that is held whenever a thread enters kernel space and released when the thread returns to user space; a system call is the archetypal example. In this model, threads in user space can run concurrently on any available processors or processor cores, but no more than one thread can run in kernel space; any other threads that try to enter kernel space are forced to wait. In other words, the giant lock eliminates all concurrency in kernel space.

By isolating the kernel from concurrency, many parts of the kernel no longer need to be modified to support SMP. However, as in giant-lock SMP systems only one processor can run the kernel code at a time, performance for applications spending significant amounts of time in the kernel is not much improved.[1] Accordingly, the giant-lock approach is commonly seen as a preliminary means of bringing SMP support to an operating system, yielding benefits only in user space. Most modern operating systems use a fine-grained locking approach.

Linux[edit]

The Linux kernel had a big kernel lock (BKL) since the introduction of SMP, until Arnd Bergmann removed it in 2011 in kernel version 2.6.39,[2][3] with the remaining uses of the big lock removed or replaced by finer-grained locking. Linux distributions at or above CentOS 7, Debian 7 (Wheezy) and Ubuntu 11.10 are therefore not using BKL.

BSD[edit]

As of July 2019, OpenBSD and NetBSD are still using the spl (Unix) family of primitives to facilitate synchronisation of critical sections within the kernel,[4][5][6] meaning that many system calls may inhibit SMP capabilities of the system, and, according to Matthew Dillon, the SMP capabilities of these two systems cannot be considered modern.[7]

FreeBSD still has support for the Giant mutex,[8] which provides semantics akin to the old spl interface, but performance-critical core components have long been converted to use finer-grained locking.[1]

It is claimed by Matthew Dillon that out of the open-source software general-purpose operating systems, only Linux, DragonFly BSD and FreeBSD have modern SMP support, with OpenBSD and NetBSD falling behind.[7]

The NetBSD Foundation views modern SMP support as vital to the direction of The NetBSD Project, and has offered grants to developers willing to work on SMP improvements; NPF (firewall) was one of the projects that arose as a result of these financial incentives, but further improvements to the core networking stack may still be necessary.[5][9]

See also[edit]

References[edit]

  1. ^ a b Robert N M Watson (2007-11-25). "Before & After Under The Giant Lock". FreeBSD-Hackers@ (Mailing list). FreeBSD. Retrieved 2019-07-25.
  2. ^ "git.kernel.org: BKL: that's all folks". Archived from the original on 2012-07-20. Retrieved 2019-12-28.
  3. ^ https://kernelnewbies.org/BigKernelLock – BigKernelLock at kernelnewbies.org
  4. ^ "/sys/net/if.c". BSD Cross Reference. OpenBSD. 2019-06-30. Retrieved 2019-07-25. s = splnet();
  5. ^ a b "/sys/net/if.c". BSD Cross Reference. NetBSD. 2019-07-25. Retrieved 2019-07-25. s = splnet();
  6. ^ "splx(9) — modify system interrupt priority level". NetBSD, OpenBSD. Retrieved 2019-07-25.
  7. ^ a b Matthew Dillon (2019-07-22). "DragonFlyBSD Project Update - colo upgrade, future trends". users@ (Mailing list). DragonFly BSD. Retrieved 2019-07-25.
  8. ^ Julian Elischer (2007). "locking(9) — kernel synchronization primitives". BSD Cross Reference. FreeBSD. Retrieved 2019-07-25. Lay summary. Giant is a special mutex used to protect data structures that do not yet have their own locks. Since it provides semantics akin to the old spl(9) interface, … {{cite web}}: Cite uses deprecated parameter |lay-url= (help)
  9. ^ "SMP Networking (aka remove the big network lock)". NetBSD. 2013-02-14. Archived from the original on 2019-07-25. Retrieved 2019-07-25.