PROPHET/OS
NAME
locks: the kernel locks, and where the machine loses time waiting for one
SYNOPSIS
locks [--tui]
DESCRIPTION
The kernel locks, and where the machine loses time waiting for one.
Taken is how often a lock was taken, Waited how many of those takes had to spin first, and Wait the share of the two, in percent with one place. The share is the number that says something: a lock taken ten million times costs nothing as long as nobody waits for it, and a lock taken twice with both takes waiting is a lock two cores fight over. The rows stand with the worst share on top.
Held by is a CORE and never a process. These are the kernel's spinlocks; a program in ring 3 takes none of them, it runs into a call and the kernel takes them there. - is free, cN is the core that holds it and stands out green, ? is a lock that carries no core mark: its word holds a one, and a one is the mark of core zero, so c0 would be a lie. Its two counts are measured all the same.
The line above the table is the coverage, and it is why the table can be trusted: how many locks stand in the list, how many of them can name their holder, and how many stand on their own in the tree. The first can stand above the last, because the list also carries the locks that live inside another structure, the waiting queue of a sleep lock and the lock of a message queue.
How long a lock was **held** is not here, and nothing in the tree measures it: that would cost a clock read on every take and every release, on the hottest path the kernel has.
The rows come out of /state/locks, which stands behind CAP_CONTROL: whoever reads it sees the innards of the kernel. Without the right the file stays empty, and then this says one line and ends with 1 instead of showing a table of no rows.
Ticks is how long one take that waited stood, in ticks of the TSC (R12-RT-08). Wait beside it says how **often** a take had to wait and cannot tell a short wait on a queue of three entries from a long one; this says which of the two it was. Measured under thirty threads on eight cores: every fifth take of a run queue waits and every wait is eight hundred ticks, which over the whole run is one per cent.
--tui takes the whole screen and keeps the rows live, with a bar over the share; the arrows and the two page keys move, q leaves.
EXAMPLE
$ locks 87 listed, 87 name their holder, 89 stand alone in the tree Lock Held by Taken Waited Wait Ticks Domains Hold HoldMax tty - 10307 304 2.9% 4266 - 1610 24404 thread-fine - 121158 2547 2.1% 1611 c 541 49468 cmos - 2001 31 1.5% 41841 - 38291 45582 serial - 90247 848 0.9% 241428 - 8755 1657130 keys - 4198 37 0.8% 355 - 93 708 ahci - 119469 156 0.1% 10636 - 22931 203530 provider-gesperrt - 2798 3 0.1% 378 - 71 104 heap - 41389 29 0.0% 4488 - 323 29344 frame - 43445 19 0.0% 566 - 85 1572 pfs-zugriff - 15299 12 0.0% 300 - 100 1136 provider - 229530 11 0.0% 369 - 24 1490 thread-ring - 47801 8 0.0% 713 - 641 10518 lauf2 - 119827 6 0.0% 416 - 132 17208 lauf5 - 113846 6 0.0% 484 - 133 1860 pcid - 30195 5 0.0% 478 - 174 1230 lauf1 - 112374 5 0.0% 745 - 143 17136 lauf4 - 104963 4 0.0% 311 - 120 17408 lauf3 - 117920 3 0.0% 271 - 121 2344 lauf7 - 90317 3 0.0% 1045 - 117 1820 tabellen - 42152 3 0.0% 283 - 699 308818 lauf6 - 103511 1 0.0% 306 - 148 17268 lauf0 - 112520 1 0.0% 512 - 241 15396 wait tree: nothing waits on a sleeping lock