xref: /openbmc/docs/designs/dump-manager.md (revision b38b0a4c)
1# Dump Manager Design
2
3Author:
4  Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
5
6Primary assignee:
7  Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
8
9Other contributors:
10
11Created: 12/12/2019
12
13## Problem Description
14During a crash or a host failure, an event monitor mechanism generates an error
15log, but the size of the error log is limited to few kilobytes, so all the data
16from the crash or failure may not fit into an error log. The additional data
17required for the debugging needs to be collected as a dump.
18The existing OpenBMC dump interfaces support only the dumps generated on
19the BMC and dump manager doesn't support download operations.
20
21## Glossary
22
23- **System Dump**: A dump of the Host's main memory and processor registers.
24    [Read More](https://en.wikipedia.org/wiki/Core_dump)
25- **Memory Preserving Reboot(MPR)**: A method of reboot with preserving the
26    contents of the volatile memory
27- **PLDM**: An interface and data model to access low-level platform inventory,
28    monitoring, control, event, and data/parameters transfer functions.
29    [ReadMore](https://github.com/openbmc/docs/blob/master/designs/pldm-stack.md)
30- **Machine Check Exception**: A severe error inside a processor core that
31    causes a processor core to stop all processing activities.
32- **BMCWeb**: An embedded webserver for OpenBMC. [More Info](https://github.com/openbmc/bmcweb/blob/master/README.md)
33
34## Background and References
35Various types of dumps are created based on the type and source of failure.
36The dump manager, which is orchestrating the collection and offload, needs to
37provide methods to create, store the dump details, and offload it. Additionally,
38some sources allow the dump to be extracted manually without a failure to
39understand the current state or analyze a suspected problems.
40
41### Type of dumps supported.
42These are some of the dumps supported by dump manager.
43
44#### BMC Dump
45A dump collected when there is a failure in the BMC with various debug
46information. This type of dump can be generated by user too to get the current
47state of the BMC. This dump gets collected on BMC and stored on BMC
48
49#### System Dump
50A system dump is a collection of debugging information from the host, this may
51include host memory and/or register data. This dump can be initiated by BMC and
52there can be system reboots while collecting the dump. Dump gets stored in the
53host memory and offloaded through the BMC or get collected directly to BMC based
54on the size of dump contents and the available space on the BMC to store the
55dump.
56
57#### Resource dump
58A special type of host dump is initiated and collected by the host based on the
59request from a user. No system state change may be necessary during the
60collection of this kind of a dump. A resource indicator may be used to indicate
61what data to be collected. The content of the dump can be decided by the host.
62This dump can be stored in host memory and offloaded through BMC or host can
63send this dump down to BMC once the collection is completed based on the size
64of the dump and the availability of space on the BMC.
65
66#### Hostboot dump
67A dump that can be collected during the boot failure of the host. This dump may
68or may not include the contents of the main memory and/or the processor registers.
69
70#### Hardware dump
71This dump can be collected during a critical failure on the hardware
72components like the processor while the host is booted and running. The host may
73stop during this dump and may collect various processor states and/or memory
74contents to help to debug the failure.
75
76## Requirements
77
78![Dump use cases - Users are examples, not a mandatory part of implementation](https://user-images.githubusercontent.com/16666879/70888651-d8f44080-2006-11ea-8596-ed4c321cfaa6.png)
79#### Dump manager needs to provide interfaces for
80- Create a dump: Initiate the creation of the dump, based on an error condition
81  or a user request.
82- List the dumps: List all dumps present in the BMC.
83- Get a dump: Offload the dump to an external entity.
84- Notify: Notify the dump manager that a new dump is created.
85- Delete the dump.
86- Mark a dump as offloaded to an external entity.
87- Set the dump policies like disabling a type of dump or dump overwriting policy.
88
89## Proposed Design
90There are various types of dumps; interfaces are standard for most of the dumps,
91but huge dumps which cannot be stored on the BMC needs additional support.
92This document will explain the design of different types of dumps. The dumps are
93classified based on where it is collected, stored, and how it is extracted. Two
94major types are
95
96- Collected by BMC and stored on BMC.
97- Collected and stored on an attached entity but offloaded through BMC.
98
99This proposal focuses on re-using the existing [phosphor-debug-collector](https://github.com/openbmc/phosphor-debug-collector), which
100collects the dumps from BMC.
101
102
103![phosphor-debug-collector](https://user-images.githubusercontent.com/16666879/72070844-7b56c980-3310-11ea-8d26-07d33b84b980.jpeg)
104
105#### Brief design points of existing phosphor-debug-collector
106- A create interface which assumes the type is BMC dump and returns an ID to the
107  caller for the user-initiated dumps.
108- An external request of dump is considered as a user-initiated BMC dump and
109  initiate BMC dump collection with a tool named dreport with type manual dump
110- The dreport create dump file in the dump path provided by the dump manager code.
111- A watch process is forked by the dump manager to catch the signal for the file
112  close on that path and assume the dump collection is completed.
113- The watch process calls an internal dbus interface to create the dump entry
114  with size and timestamp.
115- The path of dump is based on the predefined base path and the id of the dump.
116- When the request comes for offload, the file is downloaded from the dump base
117  path +id, no update in the entry whether dump is offloaded
118- Deleting a dump by deleting the entry and internal file also will be deleted.
119- There are system generated dumps based on error log or core dump, which works
120  similar to user-initiated dumps with the following difference.
121- No external create D-Bus interface is needed, but a monitor application will
122  monitor for specific conditions like the existence of a core file or a signal
123  for new error log creation of a few selected types.
124- Once the event occurred, the monitor will call an internal D-Bus interface
125  dump manager to create the dump with the type of dump.
126- The dump manager calls dreport with a dump type got from the monitor and write
127  data to a path based on dump id.
128
129#### Updates proposed to the existing phosphor-debug-collector.
130- External D-Bus interface needs to specify the type of the dump since a user
131  can request multiple types of dumps
132- Create will be returning an id which can be mapped to the actual dump once it
133  is created.
134- A Notify interface is provided for notifying the creation of a dump outside
135  the BMC but offloaded through BMC.
136- The InitiateOffload function will be implemented to download the dump.
137- Status of the dump, whether offloaded or not, will be added to the dump entry.
138
139### Dump manager interfaces.
140- Dump Manager DBus object provides interfaces for creating and managing dump
141
142- Interfaces
143    - **Create**: The interface to create a dump, called by clients to initiate
144      user-initiated dump.
145        - Type: Type of the dump needs to be created
146
147    - **Notify**: Notify the dump manager that a new dump is created.
148        - ID: ID of the dump, if not 0 this will be the external id of the dump
149        - Type: Type of dump that was created.
150        - Size: Size of the dump
151
152 ### Dump entry interfaces
153    -  **InitiateOffload**: Initiate the offload of the dump.
154        - OffloadUri: The URI where the dump should be offloaded.
155
156#### The properties common to all dumps
157There will be a base dump entry with properties common to all types of dumps
158- ID: Id of the dump
159- Timestamp: Dump creation timestamp
160- Size: Total size of the dump
161- OffloadComplete: Set to true when offload is completed
162- OffloadURI: The URI for offloading the dump, set while initiating the offload.
163Specific types need to inherit from this common dump entry class
164and add specific properties.
165
166#### Additional propertries based on dump types
167
168##### BMC Dump
169- No Additional properties
170
171##### System Dump
172- External Source ID: ID provided by the Host, this id will be used for all
173  communication to the source of the dump, in this case, Host.
174
175
176### Flow of dumps collected and stored in the Host
177PLDM is provided as an example dump transport and notification mechanism
178between Host and BMC.
179
180- Create: Initiate methods to create the dump in Host.
181- Generating the dump in Host
182- Host notifies the creation of dump through PLDM to BMC.
183- PLDM call Notify to create the dump entry
184- InitiateOffload: Dump manager request Host to start offload
185- The Host sends the dump through PLDM, and PLDM on BMC sends it out.
186
187
188## Alternatives Considered
189- Offloading Host dumps through Host instead of BMC, but considered BMC option
190  due to following reasons
191        - The BMC is considered the "management path" of most servers and often
192          the Host is not connected to the desired network for the offload
193          location.
194        - BMC provides one common point for all dumps generated in the system
195          for external management appliance.
196
197## Impacts
198- The existing BMC dump interface needs to be re-used.  The current interface is
199  not accepting a dump type, so a new interface to create the dump with type
200  will be provided for BMC dump also without changing the existing interface.
201- Modifying the BMC dump infrastructure to support additional dumps.
202- openpower-proc-control will be updated to call memory preserving chip-ops and
203  to handle memory preserving reboot on POWER platforms.
204- Additional system state to indicate the system is collecting debug data
205  While performing memory preserving reboot.
206
207
208## Testing
209- Unit tests to make sure the dump manager interfaces are working.
210- Following integration tests will be executed to make sure the dump manager
211is working as expected.
212        - Test creating host dumps and offloading it.
213        - Test deleting host dumps
214        - Create/List/Offload/Delete BMC dumps to make sure existing
215          dump manager functions are not broken.
216- Automated tests for dump Create/List/Offload/Delete to avoid regression.
217