Giant lock
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.
As of September 2022[update], Linux kernel still has console_lock and rtnl_lock, which are sometimes referred as BKL, and its removal is in progress.[4][5][6][7]
BSD
[edit]As of July 2019[update], OpenBSD and NetBSD are still using the spl family of primitives to facilitate synchronisation of critical sections within the kernel,[8][9][10] 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.[11]
FreeBSD still has support for the Giant mutex,[12] 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.[11]
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.[9][13]
See also
[edit]References
[edit]- ^ a b Robert N M Watson (2007-11-25). "Before & After Under The Giant Lock". FreeBSD-Hackers@ (Mailing list). FreeBSD. Retrieved 2019-07-25.
- ^ "git.kernel.org: BKL: that's all folks". Archived from the original on 2012-07-20. Retrieved 2019-12-28.
- ^ https://kernelnewbies.org/BigKernelLock – BigKernelLock at kernelnewbies.org
- ^ PATCH - fbcon: Make fbcon a built-time depency for fbdev. Daniel Vetter. June 28, 2017
- ^ Thomas Gleixner (September 11, 2022). "[patch RFC 19/29] printk: Add basic infrastructure for non-BKL consoles". linux-kernel (Mailing list).
- ^ Florian Westphal (November 2017). rtnl mutex, the network stack big kernel lock (PDF). netdev 2.2. Seoul.
- ^ Kuniyuki Iwashima (September 18, 2024). Per Netns RTNL. Linux Plumbers Conference 2024. Vienna, Austria.
- ^ "/sys/net/if.c". BSD Cross Reference. OpenBSD. 2019-06-30. Retrieved 2019-07-25.
s = splnet();
- ^ a b "/sys/net/if.c". BSD Cross Reference. NetBSD. 2019-07-25. Retrieved 2019-07-25.
s = splnet();
- ^ "splx(9) — modify system interrupt priority level". NetBSD, OpenBSD. Retrieved 2019-07-25.
- ^ a b Matthew Dillon (2019-07-22). "DragonFlyBSD Project Update - colo upgrade, future trends". users@ (Mailing list). DragonFly BSD. Retrieved 2019-07-25.
- ^ Julian Elischer (2007). "locking(9) — kernel synchronization primitives". BSD Cross Reference. FreeBSD. Retrieved 2019-07-25.
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, …
- "locking -- kernel synchronization primitives". FreeBSD Manual Pages.
- ^ "SMP Networking (aka remove the big network lock)". NetBSD. 2013-02-14. Archived from the original on 2019-07-25. Retrieved 2023-03-26.