main.rst 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223
  1. .. SPDX-License-Identifier: GPL-2.0
  2. .. include:: <isonum.txt>
  3. ==================================================
  4. Reliability, Availability and Serviceability (RAS)
  5. ==================================================
  6. This documents different aspects of the RAS functionality present in the
  7. kernel.
  8. RAS concepts
  9. ************
  10. Reliability, Availability and Serviceability (RAS) is a concept used on
  11. servers meant to measure their robustness.
  12. Reliability
  13. is the probability that a system will produce correct outputs.
  14. * Generally measured as Mean Time Between Failures (MTBF)
  15. * Enhanced by features that help to avoid, detect and repair hardware faults
  16. Availability
  17. is the probability that a system is operational at a given time
  18. * Generally measured as a percentage of downtime per a period of time
  19. * Often uses mechanisms to detect and correct hardware faults in
  20. runtime;
  21. Serviceability (or maintainability)
  22. is the simplicity and speed with which a system can be repaired or
  23. maintained
  24. * Generally measured on Mean Time Between Repair (MTBR)
  25. Improving RAS
  26. -------------
  27. In order to reduce systems downtime, a system should be capable of detecting
  28. hardware errors, and, when possible correcting them in runtime. It should
  29. also provide mechanisms to detect hardware degradation, in order to warn
  30. the system administrator to take the action of replacing a component before
  31. it causes data loss or system downtime.
  32. Among the monitoring measures, the most usual ones include:
  33. * CPU – detect errors at instruction execution and at L1/L2/L3 caches;
  34. * Memory – add error correction logic (ECC) to detect and correct errors;
  35. * I/O – add CRC checksums for transferred data;
  36. * Storage – RAID, journal file systems, checksums,
  37. Self-Monitoring, Analysis and Reporting Technology (SMART).
  38. By monitoring the number of occurrences of error detections, it is possible
  39. to identify if the probability of hardware errors is increasing, and, on such
  40. case, do a preventive maintenance to replace a degraded component while
  41. those errors are correctable.
  42. Types of errors
  43. ---------------
  44. Most mechanisms used on modern systems use technologies like Hamming
  45. Codes that allow error correction when the number of errors on a bit packet
  46. is below a threshold. If the number of errors is above, those mechanisms
  47. can indicate with a high degree of confidence that an error happened, but
  48. they can't correct.
  49. Also, sometimes an error occur on a component that it is not used. For
  50. example, a part of the memory that it is not currently allocated.
  51. That defines some categories of errors:
  52. * **Correctable Error (CE)** - the error detection mechanism detected and
  53. corrected the error. Such errors are usually not fatal, although some
  54. Kernel mechanisms allow the system administrator to consider them as fatal.
  55. * **Uncorrected Error (UE)** - the amount of errors happened above the error
  56. correction threshold, and the system was unable to auto-correct.
  57. * **Fatal Error** - when an UE error happens on a critical component of the
  58. system (for example, a piece of the Kernel got corrupted by an UE), the
  59. only reliable way to avoid data corruption is to hang or reboot the machine.
  60. * **Non-fatal Error** - when an UE error happens on an unused component,
  61. like a CPU in power down state or an unused memory bank, the system may
  62. still run, eventually replacing the affected hardware by a hot spare,
  63. if available.
  64. Also, when an error happens on a userspace process, it is also possible to
  65. kill such process and let userspace restart it.
  66. The mechanism for handling non-fatal errors is usually complex and may
  67. require the help of some userspace application, in order to apply the
  68. policy desired by the system administrator.
  69. Identifying a bad hardware component
  70. ------------------------------------
  71. Just detecting a hardware flaw is usually not enough, as the system needs
  72. to pinpoint to the minimal replaceable unit (MRU) that should be exchanged
  73. to make the hardware reliable again.
  74. So, it requires not only error logging facilities, but also mechanisms that
  75. will translate the error message to the silkscreen or component label for
  76. the MRU.
  77. Typically, it is very complex for memory, as modern CPUs interlace memory
  78. from different memory modules, in order to provide a better performance. The
  79. DMI BIOS usually have a list of memory module labels, with can be obtained
  80. using the ``dmidecode`` tool. For example, on a desktop machine, it shows::
  81. Memory Device
  82. Total Width: 64 bits
  83. Data Width: 64 bits
  84. Size: 16384 MB
  85. Form Factor: SODIMM
  86. Set: None
  87. Locator: ChannelA-DIMM0
  88. Bank Locator: BANK 0
  89. Type: DDR4
  90. Type Detail: Synchronous
  91. Speed: 2133 MHz
  92. Rank: 2
  93. Configured Clock Speed: 2133 MHz
  94. On the above example, a DDR4 SO-DIMM memory module is located at the
  95. system's memory labeled as "BANK 0", as given by the *bank locator* field.
  96. Please notice that, on such system, the *total width* is equal to the
  97. *data width*. It means that such memory module doesn't have error
  98. detection/correction mechanisms.
  99. Unfortunately, not all systems use the same field to specify the memory
  100. bank. On this example, from an older server, ``dmidecode`` shows::
  101. Memory Device
  102. Array Handle: 0x1000
  103. Error Information Handle: Not Provided
  104. Total Width: 72 bits
  105. Data Width: 64 bits
  106. Size: 8192 MB
  107. Form Factor: DIMM
  108. Set: 1
  109. Locator: DIMM_A1
  110. Bank Locator: Not Specified
  111. Type: DDR3
  112. Type Detail: Synchronous Registered (Buffered)
  113. Speed: 1600 MHz
  114. Rank: 2
  115. Configured Clock Speed: 1600 MHz
  116. There, the DDR3 RDIMM memory module is located at the system's memory labeled
  117. as "DIMM_A1", as given by the *locator* field. Please notice that this
  118. memory module has 64 bits of *data width* and 72 bits of *total width*. So,
  119. it has 8 extra bits to be used by error detection and correction mechanisms.
  120. Such kind of memory is called Error-correcting code memory (ECC memory).
  121. To make things even worse, it is not uncommon that systems with different
  122. labels on their system's board to use exactly the same BIOS, meaning that
  123. the labels provided by the BIOS won't match the real ones.
  124. ECC memory
  125. ----------
  126. As mentioned in the previous section, ECC memory has extra bits to be
  127. used for error correction. In the above example, a memory module has
  128. 64 bits of *data width*, and 72 bits of *total width*. The extra 8
  129. bits which are used for the error detection and correction mechanisms
  130. are referred to as the *syndrome*\ [#f1]_\ [#f2]_.
  131. So, when the cpu requests the memory controller to write a word with
  132. *data width*, the memory controller calculates the *syndrome* in real time,
  133. using Hamming code, or some other error correction code, like SECDED+,
  134. producing a code with *total width* size. Such code is then written
  135. on the memory modules.
  136. At read, the *total width* bits code is converted back, using the same
  137. ECC code used on write, producing a word with *data width* and a *syndrome*.
  138. The word with *data width* is sent to the CPU, even when errors happen.
  139. The memory controller also looks at the *syndrome* in order to check if
  140. there was an error, and if the ECC code was able to fix such error.
  141. If the error was corrected, a Corrected Error (CE) happened. If not, an
  142. Uncorrected Error (UE) happened.
  143. The information about the CE/UE errors is stored on some special registers
  144. at the memory controller and can be accessed by reading such registers,
  145. either by BIOS, by some special CPUs or by Linux EDAC driver. On x86 64
  146. bit CPUs, such errors can also be retrieved via the Machine Check
  147. Architecture (MCA)\ [#f3]_.
  148. .. [#f1] Please notice that several memory controllers allow operation on a
  149. mode called "Lock-Step", where it groups two memory modules together,
  150. doing 128-bit reads/writes. That gives 16 bits for error correction, with
  151. significantly improves the error correction mechanism, at the expense
  152. that, when an error happens, there's no way to know what memory module is
  153. to blame. So, it has to blame both memory modules.
  154. .. [#f2] Some memory controllers also allow using memory in mirror mode.
  155. On such mode, the same data is written to two memory modules. At read,
  156. the system checks both memory modules, in order to check if both provide
  157. identical data. On such configuration, when an error happens, there's no
  158. way to know what memory module is to blame. So, it has to blame both
  159. memory modules (or 4 memory modules, if the system is also on Lock-step
  160. mode).
  161. .. [#f3] For more details about the Machine Check Architecture (MCA),
  162. please read Documentation/arch/x86/x86_64/machinecheck.rst at the Kernel tree.
  163. EDAC - Error Detection And Correction
  164. *************************************
  165. .. note::
  166. "bluesmoke" was the name for this device driver subsystem when it
  167. was "out-of-tree" and maintained at http://bluesmoke.sourceforge.net.
  168. That site is mostly archaic now and can be used only for historical
  169. purposes.
  170. When the subsystem was pushed upstream for the first time, on
  171. Kernel 2.6.16, it was renamed to ``EDAC``.
  172. Purpose
  173. -------
  174. The ``edac`` kernel module's goal is to detect and report hardware errors
  175. that occur within the computer system running under linux.
  176. Memory
  177. ------
  178. Memory Correctable Errors (CE) and Uncorrectable Errors (UE) are the
  179. primary errors being harvested. These types of errors are harvested by
  180. the ``edac_mc`` device.
  181. Detecting CE events, then harvesting those events and reporting them,
  182. **can** but must not necessarily be a predictor of future UE events. With
  183. CE events only, the system can and will continue to operate as no data
  184. has been damaged yet.
  185. However, preventive maintenance and proactive part replacement of memory
  186. modules exhibiting CEs can reduce the likelihood of the dreaded UE events
  187. and system panics.
  188. Other hardware elements
  189. -----------------------
  190. A new feature for EDAC, the ``edac_device`` class of device, was added in
  191. the 2.6.23 version of the kernel.
  192. This new device type allows for non-memory type of ECC hardware detectors
  193. to have their states harvested and presented to userspace via the sysfs
  194. interface.
  195. Some architectures have ECC detectors for L1, L2 and L3 caches,
  196. along with DMA engines, fabric switches, main data path switches,
  197. interconnections, and various other hardware data paths. If the hardware
  198. reports it, then a edac_device device probably can be constructed to
  199. harvest and present that to userspace.
  200. PCI bus scanning
  201. ----------------
  202. In addition, PCI devices are scanned for PCI Bus Parity and SERR Errors
  203. in order to determine if errors are occurring during data transfers.
  204. The presence of PCI Parity errors must be examined with a grain of salt.
  205. There are several add-in adapters that do **not** follow the PCI specification
  206. with regards to Parity generation and reporting. The specification says
  207. the vendor should tie the parity status bits to 0 if they do not intend
  208. to generate parity. Some vendors do not do this, and thus the parity bit
  209. can "float" giving false positives.
  210. There is a PCI device attribute located in sysfs that is checked by
  211. the EDAC PCI scanning code. If that attribute is set, PCI parity/error
  212. scanning is skipped for that device. The attribute is::
  213. broken_parity_status
  214. and is located in ``/sys/devices/pci<XXX>/0000:XX:YY.Z`` directories for
  215. PCI devices.
  216. Versioning
  217. ----------
  218. EDAC is composed of a "core" module (``edac_core.ko``) and several Memory
  219. Controller (MC) driver modules. On a given system, the CORE is loaded
  220. and one MC driver will be loaded. Both the CORE and the MC driver (or
  221. ``edac_device`` driver) have individual versions that reflect current
  222. release level of their respective modules.
  223. Thus, to "report" on what version a system is running, one must report
  224. both the CORE's and the MC driver's versions.
  225. Loading
  226. -------
  227. If ``edac`` was statically linked with the kernel then no loading
  228. is necessary. If ``edac`` was built as modules then simply modprobe
  229. the ``edac`` pieces that you need. You should be able to modprobe
  230. hardware-specific modules and have the dependencies load the necessary
  231. core modules.
  232. Example::
  233. $ modprobe amd76x_edac
  234. loads both the ``amd76x_edac.ko`` memory controller module and the
  235. ``edac_mc.ko`` core module.
  236. Sysfs interface
  237. ---------------
  238. EDAC presents a ``sysfs`` interface for control and reporting purposes. It
  239. lives in the /sys/devices/system/edac directory.
  240. Within this directory there currently reside 2 components:
  241. ======= ==============================
  242. mc memory controller(s) system
  243. pci PCI control and status system
  244. ======= ==============================
  245. Memory Controller (mc) Model
  246. ----------------------------
  247. Each ``mc`` device controls a set of memory modules [#f4]_. These modules
  248. are laid out in a Chip-Select Row (``csrowX``) and Channel table (``chX``).
  249. There can be multiple csrows and multiple channels.
  250. .. [#f4] Nowadays, the term DIMM (Dual In-line Memory Module) is widely
  251. used to refer to a memory module, although there are other memory
  252. packaging alternatives, like SO-DIMM, SIMM, etc. The UEFI
  253. specification (Version 2.7) defines a memory module in the Common
  254. Platform Error Record (CPER) section to be an SMBIOS Memory Device
  255. (Type 17). Along this document, and inside the EDAC subsystem, the term
  256. "dimm" is used for all memory modules, even when they use a
  257. different kind of packaging.
  258. Memory controllers allow for several csrows, with 8 csrows being a
  259. typical value. Yet, the actual number of csrows depends on the layout of
  260. a given motherboard, memory controller and memory module characteristics.
  261. Dual channels allow for dual data length (e. g. 128 bits, on 64 bit systems)
  262. data transfers to/from the CPU from/to memory. Some newer chipsets allow
  263. for more than 2 channels, like Fully Buffered DIMMs (FB-DIMMs) memory
  264. controllers. The following example will assume 2 channels:
  265. +------------+-----------------------+
  266. | CS Rows | Channels |
  267. +------------+-----------+-----------+
  268. | | ``ch0`` | ``ch1`` |
  269. +============+===========+===========+
  270. | |**DIMM_A0**|**DIMM_B0**|
  271. +------------+-----------+-----------+
  272. | ``csrow0`` | rank0 | rank0 |
  273. +------------+-----------+-----------+
  274. | ``csrow1`` | rank1 | rank1 |
  275. +------------+-----------+-----------+
  276. | |**DIMM_A1**|**DIMM_B1**|
  277. +------------+-----------+-----------+
  278. | ``csrow2`` | rank0 | rank0 |
  279. +------------+-----------+-----------+
  280. | ``csrow3`` | rank1 | rank1 |
  281. +------------+-----------+-----------+
  282. In the above example, there are 4 physical slots on the motherboard
  283. for memory DIMMs:
  284. +---------+---------+
  285. | DIMM_A0 | DIMM_B0 |
  286. +---------+---------+
  287. | DIMM_A1 | DIMM_B1 |
  288. +---------+---------+
  289. Labels for these slots are usually silk-screened on the motherboard.
  290. Slots labeled ``A`` are channel 0 in this example. Slots labeled ``B`` are
  291. channel 1. Notice that there are two csrows possible on a physical DIMM.
  292. These csrows are allocated their csrow assignment based on the slot into
  293. which the memory DIMM is placed. Thus, when 1 DIMM is placed in each
  294. Channel, the csrows cross both DIMMs.
  295. Memory DIMMs come single or dual "ranked". A rank is a populated csrow.
  296. In the example above 2 dual ranked DIMMs are similarly placed. Thus,
  297. both csrow0 and csrow1 are populated. On the other hand, when 2 single
  298. ranked DIMMs are placed in slots DIMM_A0 and DIMM_B0, then they will
  299. have just one csrow (csrow0) and csrow1 will be empty. The pattern
  300. repeats itself for csrow2 and csrow3. Also note that some memory
  301. controllers don't have any logic to identify the memory module, see
  302. ``rankX`` directories below.
  303. The representation of the above is reflected in the directory
  304. tree in EDAC's sysfs interface. Starting in directory
  305. ``/sys/devices/system/edac/mc``, each memory controller will be
  306. represented by its own ``mcX`` directory, where ``X`` is the
  307. index of the MC::
  308. ..../edac/mc/
  309. |
  310. |->mc0
  311. |->mc1
  312. |->mc2
  313. ....
  314. Under each ``mcX`` directory each ``csrowX`` is again represented by a
  315. ``csrowX``, where ``X`` is the csrow index::
  316. .../mc/mc0/
  317. |
  318. |->csrow0
  319. |->csrow2
  320. |->csrow3
  321. ....
  322. Notice that there is no csrow1, which indicates that csrow0 is composed
  323. of a single ranked DIMMs. This should also apply in both Channels, in
  324. order to have dual-channel mode be operational. Since both csrow2 and
  325. csrow3 are populated, this indicates a dual ranked set of DIMMs for
  326. channels 0 and 1.
  327. Within each of the ``mcX`` and ``csrowX`` directories are several EDAC
  328. control and attribute files.
  329. ``mcX`` directories
  330. -------------------
  331. In ``mcX`` directories are EDAC control and attribute files for
  332. this ``X`` instance of the memory controllers.
  333. For a description of the sysfs API, please see:
  334. Documentation/ABI/testing/sysfs-devices-edac
  335. ``dimmX`` or ``rankX`` directories
  336. ----------------------------------
  337. The recommended way to use the EDAC subsystem is to look at the information
  338. provided by the ``dimmX`` or ``rankX`` directories [#f5]_.
  339. A typical EDAC system has the following structure under
  340. ``/sys/devices/system/edac/``\ [#f6]_::
  341. /sys/devices/system/edac/
  342. ├── mc
  343. │   ├── mc0
  344. │   │   ├── ce_count
  345. │   │   ├── ce_noinfo_count
  346. │   │   ├── dimm0
  347. │   │   │   ├── dimm_ce_count
  348. │   │   │   ├── dimm_dev_type
  349. │   │   │   ├── dimm_edac_mode
  350. │   │   │   ├── dimm_label
  351. │   │   │   ├── dimm_location
  352. │   │   │   ├── dimm_mem_type
  353. │   │   │   ├── dimm_ue_count
  354. │   │   │   ├── size
  355. │   │   │   └── uevent
  356. │   │   ├── max_location
  357. │   │   ├── mc_name
  358. │   │   ├── reset_counters
  359. │   │   ├── seconds_since_reset
  360. │   │   ├── size_mb
  361. │   │   ├── ue_count
  362. │   │   ├── ue_noinfo_count
  363. │   │   └── uevent
  364. │   ├── mc1
  365. │   │   ├── ce_count
  366. │   │   ├── ce_noinfo_count
  367. │   │   ├── dimm0
  368. │   │   │   ├── dimm_ce_count
  369. │   │   │   ├── dimm_dev_type
  370. │   │   │   ├── dimm_edac_mode
  371. │   │   │   ├── dimm_label
  372. │   │   │   ├── dimm_location
  373. │   │   │   ├── dimm_mem_type
  374. │   │   │   ├── dimm_ue_count
  375. │   │   │   ├── size
  376. │   │   │   └── uevent
  377. │   │   ├── max_location
  378. │   │   ├── mc_name
  379. │   │   ├── reset_counters
  380. │   │   ├── seconds_since_reset
  381. │   │   ├── size_mb
  382. │   │   ├── ue_count
  383. │   │   ├── ue_noinfo_count
  384. │   │   └── uevent
  385. │   └── uevent
  386. └── uevent
  387. In the ``dimmX`` directories are EDAC control and attribute files for
  388. this ``X`` memory module:
  389. - ``size`` - Total memory managed by this csrow attribute file
  390. This attribute file displays, in count of megabytes, the memory
  391. that this csrow contains.
  392. - ``dimm_ue_count`` - Uncorrectable Errors count attribute file
  393. This attribute file displays the total count of uncorrectable
  394. errors that have occurred on this DIMM. If panic_on_ue is set
  395. this counter will not have a chance to increment, since EDAC
  396. will panic the system.
  397. - ``dimm_ce_count`` - Correctable Errors count attribute file
  398. This attribute file displays the total count of correctable
  399. errors that have occurred on this DIMM. This count is very
  400. important to examine. CEs provide early indications that a
  401. DIMM is beginning to fail. This count field should be
  402. monitored for non-zero values and report such information
  403. to the system administrator.
  404. - ``dimm_dev_type`` - Device type attribute file
  405. This attribute file will display what type of DRAM device is
  406. being utilized on this DIMM.
  407. Examples:
  408. - x1
  409. - x2
  410. - x4
  411. - x8
  412. - ``dimm_edac_mode`` - EDAC Mode of operation attribute file
  413. This attribute file will display what type of Error detection
  414. and correction is being utilized.
  415. - ``dimm_label`` - memory module label control file
  416. This control file allows this DIMM to have a label assigned
  417. to it. With this label in the module, when errors occur
  418. the output can provide the DIMM label in the system log.
  419. This becomes vital for panic events to isolate the
  420. cause of the UE event.
  421. DIMM Labels must be assigned after booting, with information
  422. that correctly identifies the physical slot with its
  423. silk screen label. This information is currently very
  424. motherboard specific and determination of this information
  425. must occur in userland at this time.
  426. - ``dimm_location`` - location of the memory module
  427. The location can have up to 3 levels, and describe how the
  428. memory controller identifies the location of a memory module.
  429. Depending on the type of memory and memory controller, it
  430. can be:
  431. - *csrow* and *channel* - used when the memory controller
  432. doesn't identify a single DIMM - e. g. in ``rankX`` dir;
  433. - *branch*, *channel*, *slot* - typically used on FB-DIMM memory
  434. controllers;
  435. - *channel*, *slot* - used on Nehalem and newer Intel drivers.
  436. - ``dimm_mem_type`` - Memory Type attribute file
  437. This attribute file will display what type of memory is currently
  438. on this csrow. Normally, either buffered or unbuffered memory.
  439. Examples:
  440. - Registered-DDR
  441. - Unbuffered-DDR
  442. .. [#f5] On some systems, the memory controller doesn't have any logic
  443. to identify the memory module. On such systems, the directory is called ``rankX`` and works on a similar way as the ``csrowX`` directories.
  444. On modern Intel memory controllers, the memory controller identifies the
  445. memory modules directly. On such systems, the directory is called ``dimmX``.
  446. .. [#f6] There are also some ``power`` directories and ``subsystem``
  447. symlinks inside the sysfs mapping that are automatically created by
  448. the sysfs subsystem. Currently, they serve no purpose.
  449. ``csrowX`` directories
  450. ----------------------
  451. When CONFIG_EDAC_LEGACY_SYSFS is enabled, sysfs will contain the ``csrowX``
  452. directories. As this API doesn't work properly for Rambus, FB-DIMMs and
  453. modern Intel Memory Controllers, this is being deprecated in favor of
  454. ``dimmX`` directories.
  455. In the ``csrowX`` directories are EDAC control and attribute files for
  456. this ``X`` instance of csrow:
  457. - ``ue_count`` - Total Uncorrectable Errors count attribute file
  458. This attribute file displays the total count of uncorrectable
  459. errors that have occurred on this csrow. If panic_on_ue is set
  460. this counter will not have a chance to increment, since EDAC
  461. will panic the system.
  462. - ``ce_count`` - Total Correctable Errors count attribute file
  463. This attribute file displays the total count of correctable
  464. errors that have occurred on this csrow. This count is very
  465. important to examine. CEs provide early indications that a
  466. DIMM is beginning to fail. This count field should be
  467. monitored for non-zero values and report such information
  468. to the system administrator.
  469. - ``size_mb`` - Total memory managed by this csrow attribute file
  470. This attribute file displays, in count of megabytes, the memory
  471. that this csrow contains.
  472. - ``mem_type`` - Memory Type attribute file
  473. This attribute file will display what type of memory is currently
  474. on this csrow. Normally, either buffered or unbuffered memory.
  475. Examples:
  476. - Registered-DDR
  477. - Unbuffered-DDR
  478. - ``edac_mode`` - EDAC Mode of operation attribute file
  479. This attribute file will display what type of Error detection
  480. and correction is being utilized.
  481. - ``dev_type`` - Device type attribute file
  482. This attribute file will display what type of DRAM device is
  483. being utilized on this DIMM.
  484. Examples:
  485. - x1
  486. - x2
  487. - x4
  488. - x8
  489. - ``ch0_ce_count`` - Channel 0 CE Count attribute file
  490. This attribute file will display the count of CEs on this
  491. DIMM located in channel 0.
  492. - ``ch0_ue_count`` - Channel 0 UE Count attribute file
  493. This attribute file will display the count of UEs on this
  494. DIMM located in channel 0.
  495. - ``ch0_dimm_label`` - Channel 0 DIMM Label control file
  496. This control file allows this DIMM to have a label assigned
  497. to it. With this label in the module, when errors occur
  498. the output can provide the DIMM label in the system log.
  499. This becomes vital for panic events to isolate the
  500. cause of the UE event.
  501. DIMM Labels must be assigned after booting, with information
  502. that correctly identifies the physical slot with its
  503. silk screen label. This information is currently very
  504. motherboard specific and determination of this information
  505. must occur in userland at this time.
  506. - ``ch1_ce_count`` - Channel 1 CE Count attribute file
  507. This attribute file will display the count of CEs on this
  508. DIMM located in channel 1.
  509. - ``ch1_ue_count`` - Channel 1 UE Count attribute file
  510. This attribute file will display the count of UEs on this
  511. DIMM located in channel 0.
  512. - ``ch1_dimm_label`` - Channel 1 DIMM Label control file
  513. This control file allows this DIMM to have a label assigned
  514. to it. With this label in the module, when errors occur
  515. the output can provide the DIMM label in the system log.
  516. This becomes vital for panic events to isolate the
  517. cause of the UE event.
  518. DIMM Labels must be assigned after booting, with information
  519. that correctly identifies the physical slot with its
  520. silk screen label. This information is currently very
  521. motherboard specific and determination of this information
  522. must occur in userland at this time.
  523. System Logging
  524. --------------
  525. If logging for UEs and CEs is enabled, then system logs will contain
  526. information indicating that errors have been detected::
  527. EDAC MC0: CE page 0x283, offset 0xce0, grain 8, syndrome 0x6ec3, row 0, channel 1 "DIMM_B1": amd76x_edac
  528. EDAC MC0: CE page 0x1e5, offset 0xfb0, grain 8, syndrome 0xb741, row 0, channel 1 "DIMM_B1": amd76x_edac
  529. The structure of the message is:
  530. +---------------------------------------+-------------+
  531. | Content | Example |
  532. +=======================================+=============+
  533. | The memory controller | MC0 |
  534. +---------------------------------------+-------------+
  535. | Error type | CE |
  536. +---------------------------------------+-------------+
  537. | Memory page | 0x283 |
  538. +---------------------------------------+-------------+
  539. | Offset in the page | 0xce0 |
  540. +---------------------------------------+-------------+
  541. | The byte granularity | grain 8 |
  542. | or resolution of the error | |
  543. +---------------------------------------+-------------+
  544. | The error syndrome | 0xb741 |
  545. +---------------------------------------+-------------+
  546. | Memory row | row 0 |
  547. +---------------------------------------+-------------+
  548. | Memory channel | channel 1 |
  549. +---------------------------------------+-------------+
  550. | DIMM label, if set prior | DIMM B1 |
  551. +---------------------------------------+-------------+
  552. | And then an optional, driver-specific | |
  553. | message that may have additional | |
  554. | information. | |
  555. +---------------------------------------+-------------+
  556. Both UEs and CEs with no info will lack all but memory controller, error
  557. type, a notice of "no info" and then an optional, driver-specific error
  558. message.
  559. PCI Bus Parity Detection
  560. ------------------------
  561. On Header Type 00 devices, the primary status is looked at for any
  562. parity error regardless of whether parity is enabled on the device or
  563. not. (The spec indicates parity is generated in some cases). On Header
  564. Type 01 bridges, the secondary status register is also looked at to see
  565. if parity occurred on the bus on the other side of the bridge.
  566. Sysfs configuration
  567. -------------------
  568. Under ``/sys/devices/system/edac/pci`` are control and attribute files as
  569. follows:
  570. - ``check_pci_parity`` - Enable/Disable PCI Parity checking control file
  571. This control file enables or disables the PCI Bus Parity scanning
  572. operation. Writing a 1 to this file enables the scanning. Writing
  573. a 0 to this file disables the scanning.
  574. Enable::
  575. echo "1" >/sys/devices/system/edac/pci/check_pci_parity
  576. Disable::
  577. echo "0" >/sys/devices/system/edac/pci/check_pci_parity
  578. - ``pci_parity_count`` - Parity Count
  579. This attribute file will display the number of parity errors that
  580. have been detected.
  581. Module parameters
  582. -----------------
  583. - ``edac_mc_panic_on_ue`` - Panic on UE control file
  584. An uncorrectable error will cause a machine panic. This is usually
  585. desirable. It is a bad idea to continue when an uncorrectable error
  586. occurs - it is indeterminate what was uncorrected and the operating
  587. system context might be so mangled that continuing will lead to further
  588. corruption. If the kernel has MCE configured, then EDAC will never
  589. notice the UE.
  590. LOAD TIME::
  591. module/kernel parameter: edac_mc_panic_on_ue=[0|1]
  592. RUN TIME::
  593. echo "1" > /sys/module/edac_core/parameters/edac_mc_panic_on_ue
  594. - ``edac_mc_log_ue`` - Log UE control file
  595. Generate kernel messages describing uncorrectable errors. These errors
  596. are reported through the system message log system. UE statistics
  597. will be accumulated even when UE logging is disabled.
  598. LOAD TIME::
  599. module/kernel parameter: edac_mc_log_ue=[0|1]
  600. RUN TIME::
  601. echo "1" > /sys/module/edac_core/parameters/edac_mc_log_ue
  602. - ``edac_mc_log_ce`` - Log CE control file
  603. Generate kernel messages describing correctable errors. These
  604. errors are reported through the system message log system.
  605. CE statistics will be accumulated even when CE logging is disabled.
  606. LOAD TIME::
  607. module/kernel parameter: edac_mc_log_ce=[0|1]
  608. RUN TIME::
  609. echo "1" > /sys/module/edac_core/parameters/edac_mc_log_ce
  610. - ``edac_mc_poll_msec`` - Polling period control file
  611. The time period, in milliseconds, for polling for error information.
  612. Too small a value wastes resources. Too large a value might delay
  613. necessary handling of errors and might loose valuable information for
  614. locating the error. 1000 milliseconds (once each second) is the current
  615. default. Systems which require all the bandwidth they can get, may
  616. increase this.
  617. LOAD TIME::
  618. module/kernel parameter: edac_mc_poll_msec=[0|1]
  619. RUN TIME::
  620. echo "1000" > /sys/module/edac_core/parameters/edac_mc_poll_msec
  621. - ``panic_on_pci_parity`` - Panic on PCI PARITY Error
  622. This control file enables or disables panicking when a parity
  623. error has been detected.
  624. module/kernel parameter::
  625. edac_panic_on_pci_pe=[0|1]
  626. Enable::
  627. echo "1" > /sys/module/edac_core/parameters/edac_panic_on_pci_pe
  628. Disable::
  629. echo "0" > /sys/module/edac_core/parameters/edac_panic_on_pci_pe
  630. EDAC device type
  631. ----------------
  632. In the header file, edac_pci.h, there is a series of edac_device structures
  633. and APIs for the EDAC_DEVICE.
  634. User space access to an edac_device is through the sysfs interface.
  635. At the location ``/sys/devices/system/edac`` (sysfs) new edac_device devices
  636. will appear.
  637. There is a three level tree beneath the above ``edac`` directory. For example,
  638. the ``test_device_edac`` device (found at the http://bluesmoke.sourceforget.net
  639. website) installs itself as::
  640. /sys/devices/system/edac/test-instance
  641. in this directory are various controls, a symlink and one or more ``instance``
  642. directories.
  643. The standard default controls are:
  644. ============== =======================================================
  645. log_ce boolean to log CE events
  646. log_ue boolean to log UE events
  647. panic_on_ue boolean to ``panic`` the system if an UE is encountered
  648. (default off, can be set true via startup script)
  649. poll_msec time period between POLL cycles for events
  650. ============== =======================================================
  651. The test_device_edac device adds at least one of its own custom control:
  652. ============== ==================================================
  653. test_bits which in the current test driver does nothing but
  654. show how it is installed. A ported driver can
  655. add one or more such controls and/or attributes
  656. for specific uses.
  657. One out-of-tree driver uses controls here to allow
  658. for ERROR INJECTION operations to hardware
  659. injection registers
  660. ============== ==================================================
  661. The symlink points to the 'struct dev' that is registered for this edac_device.
  662. Instances
  663. ---------
  664. One or more instance directories are present. For the ``test_device_edac``
  665. case:
  666. +----------------+
  667. | test-instance0 |
  668. +----------------+
  669. In this directory there are two default counter attributes, which are totals of
  670. counter in deeper subdirectories.
  671. ============== ====================================
  672. ce_count total of CE events of subdirectories
  673. ue_count total of UE events of subdirectories
  674. ============== ====================================
  675. Blocks
  676. ------
  677. At the lowest directory level is the ``block`` directory. There can be 0, 1
  678. or more blocks specified in each instance:
  679. +-------------+
  680. | test-block0 |
  681. +-------------+
  682. In this directory the default attributes are:
  683. ============== ================================================
  684. ce_count which is counter of CE events for this ``block``
  685. of hardware being monitored
  686. ue_count which is counter of UE events for this ``block``
  687. of hardware being monitored
  688. ============== ================================================
  689. The ``test_device_edac`` device adds 4 attributes and 1 control:
  690. ================== ====================================================
  691. test-block-bits-0 for every POLL cycle this counter
  692. is incremented
  693. test-block-bits-1 every 10 cycles, this counter is bumped once,
  694. and test-block-bits-0 is set to 0
  695. test-block-bits-2 every 100 cycles, this counter is bumped once,
  696. and test-block-bits-1 is set to 0
  697. test-block-bits-3 every 1000 cycles, this counter is bumped once,
  698. and test-block-bits-2 is set to 0
  699. ================== ====================================================
  700. ================== ====================================================
  701. reset-counters writing ANY thing to this control will
  702. reset all the above counters.
  703. ================== ====================================================
  704. Use of the ``test_device_edac`` driver should enable any others to create their own
  705. unique drivers for their hardware systems.
  706. The ``test_device_edac`` sample driver is located at the
  707. http://bluesmoke.sourceforge.net project site for EDAC.
  708. Usage of EDAC APIs on Nehalem and newer Intel CPUs
  709. --------------------------------------------------
  710. On older Intel architectures, the memory controller was part of the North
  711. Bridge chipset. Nehalem, Sandy Bridge, Ivy Bridge, Haswell, Sky Lake and
  712. newer Intel architectures integrated an enhanced version of the memory
  713. controller (MC) inside the CPUs.
  714. This chapter will cover the differences of the enhanced memory controllers
  715. found on newer Intel CPUs, such as ``i7core_edac``, ``sb_edac`` and
  716. ``sbx_edac`` drivers.
  717. .. note::
  718. The Xeon E7 processor families use a separate chip for the memory
  719. controller, called Intel Scalable Memory Buffer. This section doesn't
  720. apply for such families.
  721. 1) There is one Memory Controller per Quick Patch Interconnect
  722. (QPI). At the driver, the term "socket" means one QPI. This is
  723. associated with a physical CPU socket.
  724. Each MC have 3 physical read channels, 3 physical write channels and
  725. 3 logic channels. The driver currently sees it as just 3 channels.
  726. Each channel can have up to 3 DIMMs.
  727. The minimum known unity is DIMMs. There are no information about csrows.
  728. As EDAC API maps the minimum unity is csrows, the driver sequentially
  729. maps channel/DIMM into different csrows.
  730. For example, supposing the following layout::
  731. Ch0 phy rd0, wr0 (0x063f4031): 2 ranks, UDIMMs
  732. dimm 0 1024 Mb offset: 0, bank: 8, rank: 1, row: 0x4000, col: 0x400
  733. dimm 1 1024 Mb offset: 4, bank: 8, rank: 1, row: 0x4000, col: 0x400
  734. Ch1 phy rd1, wr1 (0x063f4031): 2 ranks, UDIMMs
  735. dimm 0 1024 Mb offset: 0, bank: 8, rank: 1, row: 0x4000, col: 0x400
  736. Ch2 phy rd3, wr3 (0x063f4031): 2 ranks, UDIMMs
  737. dimm 0 1024 Mb offset: 0, bank: 8, rank: 1, row: 0x4000, col: 0x400
  738. The driver will map it as::
  739. csrow0: channel 0, dimm0
  740. csrow1: channel 0, dimm1
  741. csrow2: channel 1, dimm0
  742. csrow3: channel 2, dimm0
  743. exports one DIMM per csrow.
  744. Each QPI is exported as a different memory controller.
  745. 2) The MC has the ability to inject errors to test drivers. The drivers
  746. implement this functionality via some error injection nodes:
  747. For injecting a memory error, there are some sysfs nodes, under
  748. ``/sys/devices/system/edac/mc/mc?/``:
  749. - ``inject_addrmatch/*``:
  750. Controls the error injection mask register. It is possible to specify
  751. several characteristics of the address to match an error code::
  752. dimm = the affected dimm. Numbers are relative to a channel;
  753. rank = the memory rank;
  754. channel = the channel that will generate an error;
  755. bank = the affected bank;
  756. page = the page address;
  757. column (or col) = the address column.
  758. each of the above values can be set to "any" to match any valid value.
  759. At driver init, all values are set to any.
  760. For example, to generate an error at rank 1 of dimm 2, for any channel,
  761. any bank, any page, any column::
  762. echo 2 >/sys/devices/system/edac/mc/mc0/inject_addrmatch/dimm
  763. echo 1 >/sys/devices/system/edac/mc/mc0/inject_addrmatch/rank
  764. To return to the default behaviour of matching any, you can do::
  765. echo any >/sys/devices/system/edac/mc/mc0/inject_addrmatch/dimm
  766. echo any >/sys/devices/system/edac/mc/mc0/inject_addrmatch/rank
  767. - ``inject_eccmask``:
  768. specifies what bits will have troubles,
  769. - ``inject_section``:
  770. specifies what ECC cache section will get the error::
  771. 3 for both
  772. 2 for the highest
  773. 1 for the lowest
  774. - ``inject_type``:
  775. specifies the type of error, being a combination of the following bits::
  776. bit 0 - repeat
  777. bit 1 - ecc
  778. bit 2 - parity
  779. - ``inject_enable``:
  780. starts the error generation when something different than 0 is written.
  781. All inject vars can be read. root permission is needed for write.
  782. Datasheet states that the error will only be generated after a write on an
  783. address that matches inject_addrmatch. It seems, however, that reading will
  784. also produce an error.
  785. For example, the following code will generate an error for any write access
  786. at socket 0, on any DIMM/address on channel 2::
  787. echo 2 >/sys/devices/system/edac/mc/mc0/inject_addrmatch/channel
  788. echo 2 >/sys/devices/system/edac/mc/mc0/inject_type
  789. echo 64 >/sys/devices/system/edac/mc/mc0/inject_eccmask
  790. echo 3 >/sys/devices/system/edac/mc/mc0/inject_section
  791. echo 1 >/sys/devices/system/edac/mc/mc0/inject_enable
  792. dd if=/dev/mem of=/dev/null seek=16k bs=4k count=1 >& /dev/null
  793. For socket 1, it is needed to replace "mc0" by "mc1" at the above
  794. commands.
  795. The generated error message will look like::
  796. EDAC MC0: UE row 0, channel-a= 0 channel-b= 0 labels "-": NON_FATAL (addr = 0x0075b980, socket=0, Dimm=0, Channel=2, syndrome=0x00000040, count=1, Err=8c0000400001009f:4000080482 (read error: read ECC error))
  797. 3) Corrected Error memory register counters
  798. Those newer MCs have some registers to count memory errors. The driver
  799. uses those registers to report Corrected Errors on devices with Registered
  800. DIMMs.
  801. However, those counters don't work with Unregistered DIMM. As the chipset
  802. offers some counters that also work with UDIMMs (but with a worse level of
  803. granularity than the default ones), the driver exposes those registers for
  804. UDIMM memories.
  805. They can be read by looking at the contents of ``all_channel_counts/``::
  806. $ for i in /sys/devices/system/edac/mc/mc0/all_channel_counts/*; do echo $i; cat $i; done
  807. /sys/devices/system/edac/mc/mc0/all_channel_counts/udimm0
  808. 0
  809. /sys/devices/system/edac/mc/mc0/all_channel_counts/udimm1
  810. 0
  811. /sys/devices/system/edac/mc/mc0/all_channel_counts/udimm2
  812. 0
  813. What happens here is that errors on different csrows, but at the same
  814. dimm number will increment the same counter.
  815. So, in this memory mapping::
  816. csrow0: channel 0, dimm0
  817. csrow1: channel 0, dimm1
  818. csrow2: channel 1, dimm0
  819. csrow3: channel 2, dimm0
  820. The hardware will increment udimm0 for an error at the first dimm at either
  821. csrow0, csrow2 or csrow3;
  822. The hardware will increment udimm1 for an error at the second dimm at either
  823. csrow0, csrow2 or csrow3;
  824. The hardware will increment udimm2 for an error at the third dimm at either
  825. csrow0, csrow2 or csrow3;
  826. 4) Standard error counters
  827. The standard error counters are generated when an mcelog error is received
  828. by the driver. Since, with UDIMM, this is counted by software, it is
  829. possible that some errors could be lost. With RDIMM's, they display the
  830. contents of the registers
  831. Reference documents used on ``amd64_edac``
  832. ------------------------------------------
  833. ``amd64_edac`` module is based on the following documents
  834. (available from http://support.amd.com/en-us/search/tech-docs):
  835. 1. :Title: BIOS and Kernel Developer's Guide for AMD Athlon 64 and AMD
  836. Opteron Processors
  837. :AMD publication #: 26094
  838. :Revision: 3.26
  839. :Link: http://support.amd.com/TechDocs/26094.PDF
  840. 2. :Title: BIOS and Kernel Developer's Guide for AMD NPT Family 0Fh
  841. Processors
  842. :AMD publication #: 32559
  843. :Revision: 3.00
  844. :Issue Date: May 2006
  845. :Link: http://support.amd.com/TechDocs/32559.pdf
  846. 3. :Title: BIOS and Kernel Developer's Guide (BKDG) For AMD Family 10h
  847. Processors
  848. :AMD publication #: 31116
  849. :Revision: 3.00
  850. :Issue Date: September 07, 2007
  851. :Link: http://support.amd.com/TechDocs/31116.pdf
  852. 4. :Title: BIOS and Kernel Developer's Guide (BKDG) for AMD Family 15h
  853. Models 30h-3Fh Processors
  854. :AMD publication #: 49125
  855. :Revision: 3.06
  856. :Issue Date: 2/12/2015 (latest release)
  857. :Link: http://support.amd.com/TechDocs/49125_15h_Models_30h-3Fh_BKDG.pdf
  858. 5. :Title: BIOS and Kernel Developer's Guide (BKDG) for AMD Family 15h
  859. Models 60h-6Fh Processors
  860. :AMD publication #: 50742
  861. :Revision: 3.01
  862. :Issue Date: 7/23/2015 (latest release)
  863. :Link: http://support.amd.com/TechDocs/50742_15h_Models_60h-6Fh_BKDG.pdf
  864. 6. :Title: BIOS and Kernel Developer's Guide (BKDG) for AMD Family 16h
  865. Models 00h-0Fh Processors
  866. :AMD publication #: 48751
  867. :Revision: 3.03
  868. :Issue Date: 2/23/2015 (latest release)
  869. :Link: http://support.amd.com/TechDocs/48751_16h_bkdg.pdf
  870. Credits
  871. =======
  872. * Written by Doug Thompson <dougthompson@xmission.com>
  873. - 7 Dec 2005
  874. - 17 Jul 2007 Updated
  875. * |copy| Mauro Carvalho Chehab
  876. - 05 Aug 2009 Nehalem interface
  877. - 26 Oct 2016 Converted to ReST and cleanups at the Nehalem section
  878. * EDAC authors/maintainers:
  879. - Doug Thompson, Dave Jiang, Dave Peterson et al,
  880. - Mauro Carvalho Chehab
  881. - Borislav Petkov
  882. - original author: Thayne Harbaugh