|
| 1 | +.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.2-no-invariants-or-later |
| 2 | +
|
| 3 | +============= |
| 4 | +Scrub Control |
| 5 | +============= |
| 6 | + |
| 7 | +Copyright (c) 2024-2025 HiSilicon Limited. |
| 8 | + |
| 9 | +:Author: Shiju Jose <shiju.jose@huawei.com> |
| 10 | +:License: The GNU Free Documentation License, Version 1.2 without |
| 11 | + Invariant Sections, Front-Cover Texts nor Back-Cover Texts. |
| 12 | + (dual licensed under the GPL v2) |
| 13 | + |
| 14 | +- Written for: 6.15 |
| 15 | + |
| 16 | +Introduction |
| 17 | +------------ |
| 18 | + |
| 19 | +Increasing DRAM size and cost have made memory subsystem reliability an |
| 20 | +important concern. These modules are used where potentially corrupted data |
| 21 | +could cause expensive or fatal issues. Memory errors are among the top |
| 22 | +hardware failures that cause server and workload crashes. |
| 23 | + |
| 24 | +Memory scrubbing is a feature where an ECC (Error-Correcting Code) engine |
| 25 | +reads data from each memory media location, corrects if necessary and writes |
| 26 | +the corrected data back to the same memory media location. |
| 27 | + |
| 28 | +DIMMs can be scrubbed at a configurable rate to detect uncorrected memory |
| 29 | +errors and attempt recovery from detected errors, providing the following |
| 30 | +benefits: |
| 31 | + |
| 32 | +1. Proactively scrubbing DIMMs reduces the chance of a correctable error |
| 33 | + becoming uncorrectable. |
| 34 | + |
| 35 | +2. When detected, uncorrected errors caught in unallocated memory pages are |
| 36 | + isolated and prevented from being allocated to an application or the OS. |
| 37 | + |
| 38 | +3. This reduces the likelihood of software or hardware products encountering |
| 39 | + memory errors. |
| 40 | + |
| 41 | +4. The additional data on failures in memory may be used to build up |
| 42 | + statistics that are later used to decide whether to use memory repair |
| 43 | + technologies such as Post Package Repair or Sparing. |
| 44 | + |
| 45 | +There are 2 types of memory scrubbing: |
| 46 | + |
| 47 | +1. Background (patrol) scrubbing while the DRAM is otherwise idle. |
| 48 | + |
| 49 | +2. On-demand scrubbing for a specific address range or region of memory. |
| 50 | + |
| 51 | +Several types of interfaces to hardware memory scrubbers have been |
| 52 | +identified, such as CXL memory device patrol scrub, CXL DDR5 ECS, ACPI |
| 53 | +RAS2 memory scrubbing, and ACPI NVDIMM ARS (Address Range Scrub). |
| 54 | + |
| 55 | +The control mechanisms vary across different memory scrubbers. To enable |
| 56 | +standardized userspace tooling, there is a need to present these controls |
| 57 | +through a standardized ABI. |
| 58 | + |
| 59 | +A generic memory EDAC scrub control allows users to manage underlying |
| 60 | +scrubbers in the system through a standardized sysfs control interface. It |
| 61 | +abstracts the management of various scrubbing functionalities into a unified |
| 62 | +set of functions. |
| 63 | + |
| 64 | +Use cases of common scrub control feature |
| 65 | +----------------------------------------- |
| 66 | + |
| 67 | +1. Several types of interfaces for hardware memory scrubbers have been |
| 68 | + identified, including the CXL memory device patrol scrub, CXL DDR5 ECS, |
| 69 | + ACPI RAS2 memory scrubbing features, ACPI NVDIMM ARS (Address Range Scrub), |
| 70 | + and software-based memory scrubbers. |
| 71 | + |
| 72 | + Of the identified interfaces to hardware memory scrubbers some support |
| 73 | + control over patrol (background) scrubbing (e.g., ACPI RAS2, CXL) and/or |
| 74 | + on-demand scrubbing (e.g., ACPI RAS2, ACPI ARS). However, the scrub control |
| 75 | + interfaces vary between memory scrubbers, highlighting the need for |
| 76 | + a standardized, generic sysfs scrub control interface that is accessible to |
| 77 | + userspace for administration and use by scripts/tools. |
| 78 | + |
| 79 | +2. User-space scrub controls allow users to disable scrubbing if necessary, |
| 80 | + for example, to disable background patrol scrubbing or adjust the scrub |
| 81 | + rate for performance-aware operations where background activities need to |
| 82 | + be minimized or disabled. |
| 83 | + |
| 84 | +3. User-space tools enable on-demand scrubbing for specific address ranges, |
| 85 | + provided that the scrubber supports this functionality. |
| 86 | + |
| 87 | +4. User-space tools can also control memory DIMM scrubbing at a configurable |
| 88 | + scrub rate via sysfs scrub controls. This approach offers several benefits: |
| 89 | + |
| 90 | + 4.1. Detects uncorrectable memory errors early, before user access to affected |
| 91 | + memory, helping facilitate recovery. |
| 92 | + |
| 93 | + 4.2. Reduces the likelihood of correctable errors developing into uncorrectable |
| 94 | + errors. |
| 95 | + |
| 96 | +5. Policy control for hotplugged memory is necessary because there may not |
| 97 | + be a system-wide BIOS or similar control to manage scrub settings for a CXL |
| 98 | + device added after boot. Determining these settings is a policy decision, |
| 99 | + balancing reliability against performance, so userspace should control it. |
| 100 | + Therefore, a unified interface is recommended for handling this function in |
| 101 | + a way that aligns with other similar interfaces, rather than creating a |
| 102 | + separate one. |
| 103 | + |
| 104 | +Scrubbing features |
| 105 | +------------------ |
| 106 | + |
| 107 | +CXL Memory Scrubbing features |
| 108 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 109 | + |
| 110 | +CXL spec r3.1 [1]_ section 8.2.9.9.11.1 describes the memory device patrol |
| 111 | +scrub control feature. The device patrol scrub proactively locates and makes |
| 112 | +corrections to errors in regular cycle. The patrol scrub control allows the |
| 113 | +userspace request to change CXL patrol scrubber's configurations. |
| 114 | + |
| 115 | +The patrol scrub control allows the requester to specify the number of |
| 116 | +hours in which the patrol scrub cycles must be completed, provided that |
| 117 | +the requested scrub rate must be within the supported range of the |
| 118 | +scrub rate that the device is capable of. In the CXL driver, the |
| 119 | +number of seconds per scrub cycles, which user requests via sysfs, is |
| 120 | +rescaled to hours per scrub cycles. |
| 121 | + |
| 122 | +In addition, they allow the host to disable the feature in case it interferes |
| 123 | +with performance-aware operations which require the background operations to |
| 124 | +be turned off. |
| 125 | + |
| 126 | +Error Check Scrub (ECS) |
| 127 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 128 | + |
| 129 | +CXL spec r3.1 [1]_ section 8.2.9.9.11.2 describes Error Check Scrub (ECS) |
| 130 | +- a feature defined in the JEDEC DDR5 SDRAM Specification (JESD79-5) and |
| 131 | +allowing DRAM to internally read, correct single-bit errors, and write back |
| 132 | +corrected data bits to the DRAM array while providing transparency to error |
| 133 | +counts. |
| 134 | + |
| 135 | +The DDR5 device contains number of memory media Field Replaceable Units (FRU) |
| 136 | +per device. The DDR5 ECS feature and thus the ECS control driver supports |
| 137 | +configuring the ECS parameters per FRU. |
| 138 | + |
| 139 | +ACPI RAS2 Hardware-based Memory Scrubbing |
| 140 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 141 | + |
| 142 | +ACPI spec 6.5 [2]_ section 5.2.21 ACPI RAS2 describes an ACPI RAS2 table |
| 143 | +which provides interfaces for platform RAS features and supports independent |
| 144 | +RAS controls and capabilities for a given RAS feature for multiple instances |
| 145 | +of the same component in a given system. |
| 146 | + |
| 147 | +Memory RAS features apply to RAS capabilities, controls and operations that |
| 148 | +are specific to memory. RAS2 PCC sub-spaces for memory-specific RAS features |
| 149 | +have a Feature Type of 0x00 (Memory). |
| 150 | + |
| 151 | +The platform can use the hardware-based memory scrubbing feature to expose |
| 152 | +controls and capabilities associated with hardware-based memory scrub |
| 153 | +engines. The RAS2 memory scrubbing feature supports as per spec, |
| 154 | + |
| 155 | +1. Independent memory scrubbing controls for each NUMA domain, identified |
| 156 | + using its proximity domain. |
| 157 | + |
| 158 | +2. Provision for background (patrol) scrubbing of the entire memory system, |
| 159 | + as well as on-demand scrubbing for a specific region of memory. |
| 160 | + |
| 161 | +ACPI Address Range Scrubbing (ARS) |
| 162 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 163 | + |
| 164 | +ACPI spec 6.5 [2]_ section 9.19.7.2 describes Address Range Scrubbing (ARS). |
| 165 | +ARS allows the platform to communicate memory errors to system software. |
| 166 | +This capability allows system software to prevent accesses to addresses with |
| 167 | +uncorrectable errors in memory. ARS functions manage all NVDIMMs present in |
| 168 | +the system. Only one scrub can be in progress system wide at any given time. |
| 169 | + |
| 170 | +The following functions are supported as per the specification: |
| 171 | + |
| 172 | +1. Query ARS Capabilities for a given address range, indicates platform |
| 173 | + supports the ACPI NVDIMM Root Device Unconsumed Error Notification. |
| 174 | + |
| 175 | +2. Start ARS triggers an Address Range Scrub for the given memory range. |
| 176 | + Address scrubbing can be done for volatile or persistent memory, or both. |
| 177 | + |
| 178 | +3. Query ARS Status command allows software to get the status of ARS, |
| 179 | + including the progress of ARS and ARS error record. |
| 180 | + |
| 181 | +4. Clear Uncorrectable Error. |
| 182 | + |
| 183 | +5. Translate SPA |
| 184 | + |
| 185 | +6. ARS Error Inject etc. |
| 186 | + |
| 187 | +The kernel supports an existing control for ARS and ARS is currently not |
| 188 | +supported in EDAC. |
| 189 | + |
| 190 | +.. [1] https://computeexpresslink.org/cxl-specification/ |
| 191 | +
|
| 192 | +.. [2] https://uefi.org/specs/ACPI/6.5/ |
| 193 | +
|
| 194 | +Comparison of various scrubbing features |
| 195 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 196 | + |
| 197 | + +--------------+-----------+-----------+-----------+-----------+ |
| 198 | + | | ACPI | CXL patrol| CXL ECS | ARS | |
| 199 | + | Name | RAS2 | scrub | | | |
| 200 | + +--------------+-----------+-----------+-----------+-----------+ |
| 201 | + | | | | | | |
| 202 | + | On-demand | Supported | No | No | Supported | |
| 203 | + | Scrubbing | | | | | |
| 204 | + | | | | | | |
| 205 | + +--------------+-----------+-----------+-----------+-----------+ |
| 206 | + | | | | | | |
| 207 | + | Background | Supported | Supported | Supported | No | |
| 208 | + | scrubbing | | | | | |
| 209 | + | | | | | | |
| 210 | + +--------------+-----------+-----------+-----------+-----------+ |
| 211 | + | | | | | | |
| 212 | + | Mode of | Scrub ctrl| per device| per memory| Unknown | |
| 213 | + | scrubbing | per NUMA | | media | | |
| 214 | + | | domain. | | | | |
| 215 | + +--------------+-----------+-----------+-----------+-----------+ |
| 216 | + | | | | | | |
| 217 | + | Query scrub | Supported | Supported | Supported | Supported | |
| 218 | + | capabilities | | | | | |
| 219 | + | | | | | | |
| 220 | + +--------------+-----------+-----------+-----------+-----------+ |
| 221 | + | | | | | | |
| 222 | + | Setting | Supported | No | No | Supported | |
| 223 | + | address range| | | | | |
| 224 | + | | | | | | |
| 225 | + +--------------+-----------+-----------+-----------+-----------+ |
| 226 | + | | | | | | |
| 227 | + | Setting | Supported | Supported | No | No | |
| 228 | + | scrub rate | | | | | |
| 229 | + | | | | | | |
| 230 | + +--------------+-----------+-----------+-----------+-----------+ |
| 231 | + | | | | | | |
| 232 | + | Unit for | Not | in hours | No | No | |
| 233 | + | scrub rate | Defined | | | | |
| 234 | + | | | | | | |
| 235 | + +--------------+-----------+-----------+-----------+-----------+ |
| 236 | + | | Supported | | | | |
| 237 | + | Scrub | on-demand | No | No | Supported | |
| 238 | + | status/ | scrubbing | | | | |
| 239 | + | Completion | only | | | | |
| 240 | + +--------------+-----------+-----------+-----------+-----------+ |
| 241 | + | UC error | |CXL general|CXL general| ACPI UCE | |
| 242 | + | reporting | Exception |media/DRAM |media/DRAM | notify and| |
| 243 | + | | |event/media|event/media| query | |
| 244 | + | | |scan? |scan? | ARS status| |
| 245 | + +--------------+-----------+-----------+-----------+-----------+ |
| 246 | + | | | | | | |
| 247 | + | Support for | Supported | Supported | Supported | No | |
| 248 | + | EDAC control | | | | | |
| 249 | + | | | | | | |
| 250 | + +--------------+-----------+-----------+-----------+-----------+ |
| 251 | + |
| 252 | +The File System |
| 253 | +--------------- |
| 254 | + |
| 255 | +The control attributes of a registered scrubber instance could be |
| 256 | +accessed in: |
| 257 | + |
| 258 | +/sys/bus/edac/devices/<dev-name>/scrubX/ |
| 259 | + |
| 260 | +sysfs |
| 261 | +----- |
| 262 | + |
| 263 | +Sysfs files are documented in |
| 264 | +`Documentation/ABI/testing/sysfs-edac-scrub` |
0 commit comments