|
| 1 | +.. SPDX-License-Identifier: GPL-2.0 |
| 2 | +
|
| 3 | +.. include:: <isonum.txt> |
| 4 | + |
| 5 | +=============================== |
| 6 | +Bus lock detection and handling |
| 7 | +=============================== |
| 8 | + |
| 9 | +:Copyright: |copy| 2021 Intel Corporation |
| 10 | +:Authors: - Fenghua Yu < [email protected]> |
| 11 | + |
| 12 | + |
| 13 | +Problem |
| 14 | +======= |
| 15 | + |
| 16 | +A split lock is any atomic operation whose operand crosses two cache lines. |
| 17 | +Since the operand spans two cache lines and the operation must be atomic, |
| 18 | +the system locks the bus while the CPU accesses the two cache lines. |
| 19 | + |
| 20 | +A bus lock is acquired through either split locked access to writeback (WB) |
| 21 | +memory or any locked access to non-WB memory. This is typically thousands of |
| 22 | +cycles slower than an atomic operation within a cache line. It also disrupts |
| 23 | +performance on other cores and brings the whole system to its knees. |
| 24 | + |
| 25 | +Detection |
| 26 | +========= |
| 27 | + |
| 28 | +Intel processors may support either or both of the following hardware |
| 29 | +mechanisms to detect split locks and bus locks. |
| 30 | + |
| 31 | +#AC exception for split lock detection |
| 32 | +-------------------------------------- |
| 33 | + |
| 34 | +Beginning with the Tremont Atom CPU split lock operations may raise an |
| 35 | +Alignment Check (#AC) exception when a split lock operation is attemped. |
| 36 | + |
| 37 | +#DB exception for bus lock detection |
| 38 | +------------------------------------ |
| 39 | + |
| 40 | +Some CPUs have the ability to notify the kernel by an #DB trap after a user |
| 41 | +instruction acquires a bus lock and is executed. This allows the kernel to |
| 42 | +terminate the application or to enforce throttling. |
| 43 | + |
| 44 | +Software handling |
| 45 | +================= |
| 46 | + |
| 47 | +The kernel #AC and #DB handlers handle bus lock based on the kernel |
| 48 | +parameter "split_lock_detect". Here is a summary of different options: |
| 49 | + |
| 50 | ++------------------+----------------------------+-----------------------+ |
| 51 | +|split_lock_detect=|#AC for split lock |#DB for bus lock | |
| 52 | ++------------------+----------------------------+-----------------------+ |
| 53 | +|off |Do nothing |Do nothing | |
| 54 | ++------------------+----------------------------+-----------------------+ |
| 55 | +|warn |Kernel OOPs |Warn once per task and | |
| 56 | +|(default) |Warn once per task and |and continues to run. | |
| 57 | +| |disable future checking | | |
| 58 | +| |When both features are | | |
| 59 | +| |supported, warn in #AC | | |
| 60 | ++------------------+----------------------------+-----------------------+ |
| 61 | +|fatal |Kernel OOPs |Send SIGBUS to user. | |
| 62 | +| |Send SIGBUS to user | | |
| 63 | +| |When both features are | | |
| 64 | +| |supported, fatal in #AC | | |
| 65 | ++------------------+----------------------------+-----------------------+ |
| 66 | + |
| 67 | +Usages |
| 68 | +====== |
| 69 | + |
| 70 | +Detecting and handling bus lock may find usages in various areas: |
| 71 | + |
| 72 | +It is critical for real time system designers who build consolidated real |
| 73 | +time systems. These systems run hard real time code on some cores and run |
| 74 | +"untrusted" user processes on other cores. The hard real time cannot afford |
| 75 | +to have any bus lock from the untrusted processes to hurt real time |
| 76 | +performance. To date the designers have been unable to deploy these |
| 77 | +solutions as they have no way to prevent the "untrusted" user code from |
| 78 | +generating split lock and bus lock to block the hard real time code to |
| 79 | +access memory during bus locking. |
| 80 | + |
| 81 | +It's also useful for general computing to prevent guests or user |
| 82 | +applications from slowing down the overall system by executing instructions |
| 83 | +with bus lock. |
| 84 | + |
| 85 | + |
| 86 | +Guidance |
| 87 | +======== |
| 88 | +off |
| 89 | +--- |
| 90 | + |
| 91 | +Disable checking for split lock and bus lock. This option can be useful if |
| 92 | +there are legacy applications that trigger these events at a low rate so |
| 93 | +that mitigation is not needed. |
| 94 | + |
| 95 | +warn |
| 96 | +---- |
| 97 | + |
| 98 | +A warning is emitted when a bus lock is detected which allows to identify |
| 99 | +the offending application. This is the default behavior. |
| 100 | + |
| 101 | +fatal |
| 102 | +----- |
| 103 | + |
| 104 | +In this case, the bus lock is not tolerated and the process is killed. |
0 commit comments