* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <string.h>
#include <stdio.h>
#include "ras-mce-handler.h"
#include "bitfield.h"
-unsigned int bitfield_msg(char *buf, size_t len, const char **bitarray,
+unsigned int bitfield_msg(char *buf, size_t len, const char * const *bitarray,
unsigned int array_len,
unsigned int bit_offset, unsigned int ignore_bits,
uint64_t status)
continue;
mce_snprintf(e->error_msg, "<%u:%llx>",
f->start_bit, (long long)v);
- } else
+ } else {
mce_snprintf(e->error_msg, "%s", s);
+ }
}
}
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <stdint.h>
/* Ancillary routines */
-unsigned int bitfield_msg(char *buf, size_t len, const char **bitarray,
+unsigned int bitfield_msg(char *buf, size_t len, const char * const *bitarray,
unsigned int array_len,
unsigned int bit_offset, unsigned int ignore_bits,
uint64_t status);
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <stdio.h>
#include <string.h>
#define K8_MCELOG_THRESHOLD_L3_CACHE (4 * 9 + 2)
#define K8_MCELOG_THRESHOLD_FBDIMM (4 * 9 + 3)
-static const char *k8bank[] = {
+static const char * const k8bank[] = {
"data cache",
"instruction cache",
"bus unit",
"fixed-issue reoder"
};
-static const char *k8threshold[] = {
+static const char * const k8threshold[] = {
[0 ... K8_MCELOG_THRESHOLD_DRAM_ECC - 1] = "Unknown threshold counter",
[K8_MCELOG_THRESHOLD_DRAM_ECC] = "MC4_MISC0 DRAM threshold",
[K8_MCELOG_THRESHOLD_LINK] = "MC4_MISC1 Link threshold",
"Unknown threshold counter",
};
-static const char *transaction[] = {
+static const char * const transaction[] = {
"instruction", "data", "generic", "reserved"
};
-static const char *cachelevel[] = {
+static const char * const cachelevel[] = {
"0", "1", "2", "generic"
};
-static const char *memtrans[] = {
+static const char * const memtrans[] = {
"generic error", "generic read", "generic write", "data read",
"data write", "instruction fetch", "prefetch", "evict", "snoop",
"?", "?", "?", "?", "?", "?", "?"
};
-static const char *partproc[] = {
+static const char * const partproc[] = {
"local node origin", "local node response",
"local node observed", "generic participation"
};
-static const char *timeout[] = {
+static const char * const timeout[] = {
"request didn't time out",
"request timed out"
};
-static const char *memoryio[] = {
+static const char * const memoryio[] = {
"memory", "res.", "i/o", "generic"
};
-static const char *nbextendederr[] = {
+static const char * const nbextendederr[] = {
"RAM ECC error",
"CRC error",
"Sync error",
"L3 Cache LRU Error"
};
-static const char *highbits[32] = {
+static const char * const highbits[32] = {
[31] = "valid",
[30] = "error overflow (multiple errors)",
[29] = "error uncorrected",
if (e->bank == 4) {
unsigned short exterrcode = (e->status >> 16) & 0x0f;
- if (exterrcode == 5 && (e->status & (1ULL << 61))) {
+ if (exterrcode == 5 && (e->status & (1ULL << 61)))
return -1;
- }
}
bank_name(e);
"Uncorrected, software restartable error.");
strcpy(e->error_msg,
"Uncorrected, software containable error.");
- } else if (e->status & MCI_STATUS_DEFERRED)
+ } else if (e->status & MCI_STATUS_DEFERRED) {
strcpy(e->error_msg, "Deferred error, no action required.");
- else
+ } else {
strcpy(e->error_msg, "Corrected error, no action required.");
+ }
if (!(e->status & MCI_STATUS_VAL))
mce_snprintf(e->mcistatus_msg, "MCE_INVALID");
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <string.h>
#include <stdio.h>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <string.h>
#include <stdio.h>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <string.h>
#include <stdio.h>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <string.h>
#include <stdio.h>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <inttypes.h>
#include <stdio.h>
uint32_t eccmode = EXTRACT(e->misc, 59, 62);
uint32_t transient = EXTRACT(e->misc, 63, 63);
- mce_snprintf(e->error_msg, "bank: 0x%x bankgroup: 0x%x row: 0x%x column: 0x%x", bank, bankgroup, row, column);
+ mce_snprintf(e->error_msg,
+ "bank: 0x%x bankgroup: 0x%x row: 0x%x column: 0x%x",
+ bank, bankgroup, row, column);
if (!transient && !EXTRACT(e->status, 61, 61))
mce_snprintf(e->error_msg, "failed device: 0x%x", fdevice);
mce_snprintf(e->error_msg, "rank: 0x%x subrank: 0x%x", rank, subrank);
mce_snprintf(e->error_msg, "ecc mode: ");
switch (eccmode) {
- case 0: mce_snprintf(e->error_msg, "SDDC memory mode"); break;
- case 1: mce_snprintf(e->error_msg, "SDDC"); break;
- case 4: mce_snprintf(e->error_msg, "ADDDC memory mode"); break;
- case 5: mce_snprintf(e->error_msg, "ADDDC"); break;
- case 8: mce_snprintf(e->error_msg, "DDRT read"); break;
- default: mce_snprintf(e->error_msg, "unknown"); break;
+ case 0:
+ mce_snprintf(e->error_msg, "SDDC memory mode");
+ break;
+ case 1:
+ mce_snprintf(e->error_msg, "SDDC");
+ break;
+ case 4:
+ mce_snprintf(e->error_msg, "ADDDC memory mode");
+ break;
+ case 5:
+ mce_snprintf(e->error_msg, "ADDDC");
+ break;
+ case 8:
+ mce_snprintf(e->error_msg, "DDRT read");
+ break;
+ default:
+ mce_snprintf(e->error_msg, "unknown");
+ break;
}
if (transient)
mce_snprintf(e->error_msg, "transient");
[13 ... 20] = BT_IMC,
};
-void i10nm_memerr_misc(struct mce_event *e, int *channel);
+static void i10nm_memerr_misc(struct mce_event *e, int *channel);
void i10nm_decode_model(enum cputype cputype, struct ras_events *ras,
struct mce_event *e)
mce_snprintf(e->error_msg, "MemCtrl: ");
f = EXTRACT(status, 16, 23);
switch (EXTRACT(status, 24, 31)) {
- case 0: decode_bitfield(e, f, imc0); break;
- case 1: decode_bitfield(e, f, imc1); break;
- case 2: decode_bitfield(e, f, imc2); break;
- case 4: decode_bitfield(e, f, imc4); break;
- case 8: decode_bitfield(e, f, imc8); break;
- case 0x10: decode_bitfield(e, f, imc10); break;
+ case 0:
+ decode_bitfield(e, f, imc0);
+ break;
+ case 1:
+ decode_bitfield(e, f, imc1);
+ break;
+ case 2:
+ decode_bitfield(e, f, imc2);
+ break;
+ case 4:
+ decode_bitfield(e, f, imc4);
+ break;
+ case 8:
+ decode_bitfield(e, f, imc8);
+ break;
+ case 0x10:
+ decode_bitfield(e, f, imc10);
+ break;
}
i10nm_imc_misc(e);
break;
* we can derive the channel from the bank number.
* There can be four memory controllers with two channels each.
*/
-void i10nm_memerr_misc(struct mce_event *e, int *channel)
+static void i10nm_memerr_misc(struct mce_event *e, int *channel)
{
uint64_t status = e->status;
unsigned int chan, imc;
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <string.h>
#include <stdio.h>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <string.h>
#include <stdio.h>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <string.h>
#include <stdio.h>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <string.h>
#include <stdio.h>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <string.h>
#include <stdio.h>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <string.h>
#include <stdio.h>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <string.h>
#include <stdio.h>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <errno.h>
#include <fcntl.h>
static void decode_termal_bank(struct mce_event *e)
{
if (e->status & 1) {
- mce_snprintf(e->mcgstatus_msg, "Processor %d heated above trip temperature. Throttling enabled.", e->cpu);
- mce_snprintf(e->user_action, "Please check your system cooling. Performance will be impacted");
+ mce_snprintf(e->mcgstatus_msg,
+ "Processor %d heated above trip temperature. Throttling enabled.",
+ e->cpu);
+ mce_snprintf(e->user_action,
+ "Please check your system cooling. Performance will be impacted");
} else {
- mce_snprintf(e->error_msg, "Processor %d below trip temperature. Throttling disabled", e->cpu);
+ mce_snprintf(e->error_msg,
+ "Processor %d below trip temperature. Throttling disabled",
+ e->cpu);
}
}
unsigned int i;
for (i = 0; i < ARRAY_SIZE(RRRR); i++) {
- if (RRRR[i].value == rrrr) {
+ if (RRRR[i].value == rrrr)
return RRRR[i].str;
- }
}
return "UNKNOWN";
} else if (test_prefix(7, mca)) {
decode_memory_controller(e, mca);
*ismemerr = 1;
- } else
+ } else {
mce_snprintf(e->mcastatus_msg, "Unknown Error %x", mca);
+ }
}
static void decode_tracking(struct mce_event *e, uint64_t track)
} else if (payload_type == PAYLOAD_TYPE_3) {
db_tab = amp_payload3_event_tab;
id = AMP_PAYLOAD3_FIELD_TIMESTAMP;
- } else
+ } else {
return -1;
+ }
if (!ev_decoder->stmt_dec_record) {
if (ras_mc_add_vendor_table(ras, &ev_decoder->stmt_dec_record,
#include "ras-events.h"
#include <traceevent/event-parse.h>
-#define SOCKET_NUM(x) ((x >> 14) & 0x3)
-#define PAYLOAD_TYPE(x) ((x >> 6) & 0x3)
-#define TYPE(x) (x & 0x3f)
-#define INSTANCE(x) (x & 0x3fff)
+#define SOCKET_NUM(x) (((x) >> 14) & 0x3)
+#define PAYLOAD_TYPE(x) (((x) >> 6) & 0x3)
+#define TYPE(x) ((x) & 0x3f)
+#define INSTANCE(x) ((x) & 0x3fff)
#define AMP_PAYLOAD0_BUF_LEN 1024
#define PAYLOAD_TYPE_0 0x00
#define PAYLOAD_TYPE_1 0x01
struct hisi_module_info {
int id;
const char *name;
- const char **sub;
+ const char * const *sub;
int sub_num;
};
-static const char *pll_submodule_name[] = {
+static const char * const pll_submodule_name[] = {
"TB_PLL0",
"TB_PLL1",
"TB_PLL2",
"NIMBUS_PLL4",
};
-static const char *sllc_submodule_name[] = {
+static const char * const sllc_submodule_name[] = {
"TB_SLLC0",
"TB_SLLC1",
"TB_SLLC2",
"NIMBUS_SLLC1",
};
-static const char *sioe_submodule_name[] = {
+static const char * const sioe_submodule_name[] = {
"TB_SIOE0",
"TB_SIOE1",
"TB_SIOE2",
"NIMBUS_SIOE1",
};
-static const char *poe_submodule_name[] = {
+static const char * const poe_submodule_name[] = {
"TB_POE",
"TA_POE",
};
-static const char *disp_submodule_name[] = {
+static const char * const disp_submodule_name[] = {
"TB_PERI_DISP",
"TB_POE_DISP",
"TB_GIC_DISP",
"NETWORK_DISP",
};
-static const char *sas_submodule_name[] = {
+static const char * const sas_submodule_name[] = {
"SAS0",
"SAS1",
};
}
};
-static const char *smmu_submodule_name[] = {
+static const char * const smmu_submodule_name[] = {
"HAC_SMMU",
"PCIE_SMMU",
"MGMT_SMMU",
"NIC_SMMU",
};
-static const char *hllc_submodule_name[] = {
+static const char * const hllc_submodule_name[] = {
"HLLC0",
"HLLC1",
"HLLC2",
};
-static const char *hha_submodule_name[] = {
+static const char * const hha_submodule_name[] = {
"TB_HHA0",
"TB_HHA1",
"TA_HHA0",
"TA_HHA1"
};
-static const char *ddrc_submodule_name[] = {
+static const char * const ddrc_submodule_name[] = {
"TB_DDRC0",
"TB_DDRC1",
"TB_DDRC2",
"TA_DDRC3",
};
-static const char *l3tag_submodule_name[] = {
+static const char * const l3tag_submodule_name[] = {
"TB_PARTITION0",
"TB_PARTITION1",
"TB_PARTITION2",
"TA_PARTITION7",
};
-static const char *l3data_submodule_name[] = {
+static const char * const l3data_submodule_name[] = {
"TB_BANK0",
"TB_BANK1",
"TB_BANK2",
}
};
-static const char *oem_module_name(const struct hisi_module_info *info,
- uint8_t module_id)
+static const char * const oem_module_name(const struct hisi_module_info *info,
+ uint8_t module_id)
{
const struct hisi_module_info *module = &info[0];
return "unknown";
}
-static const char *oem_submodule_name(const struct hisi_module_info *info,
- uint8_t module_id, uint8_t sub_module_id)
+static const char * const oem_submodule_name(const struct hisi_module_info *info,
+ uint8_t module_id, uint8_t sub_module_id)
{
const struct hisi_module_info *module = &info[0];
for (; module->name; module++) {
- const char **submodule = module->sub;
+ const char * const *submodule = module->sub;
if (module->id != module_id)
continue;
};
#endif
-static const char *soc_desc[] = {
+static const char * const soc_desc[] = {
"Kunpeng916",
"Kunpeng920",
"Kunpeng930",
};
-static const char *module_name[] = {
+static const char * const module_name[] = {
"MN",
"PLL",
"SLLC",
"HBMC",
};
-static const char *get_soc_desc(uint8_t soc_id)
+static const char * const get_soc_desc(uint8_t soc_id)
{
if (soc_id >= sizeof(soc_desc) / sizeof(char *))
return "unknown";
static inline char *jm_err_severity(uint8_t err_sev)
{
switch (err_sev) {
- case JM_ERR_SEVERITY_NFE: return "recoverable";
- case JM_ERR_SEVERITY_FE: return "fatal";
- case JM_ERR_SEVERITY_CE: return "corrected";
- case JM_ERR_SEVERITY_NONE: return "none";
+ case JM_ERR_SEVERITY_NFE:
+ return "recoverable";
+ case JM_ERR_SEVERITY_FE:
+ return "fatal";
+ case JM_ERR_SEVERITY_CE:
+ return "corrected";
+ case JM_ERR_SEVERITY_NONE:
+ return "none";
default:
break;
}
if (err->val_bits & BIT(JM_COMMON_VALID_SUBMODULE_ID)) {
JM_SNPRINTF(event->error_msg, " sub module=%s",
- get_jm_submod_desc(err->subsystem_id, err->module_id, err->submodule_id));
+ get_jm_submod_desc(err->subsystem_id,
+ err->module_id, err->submodule_id));
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_TEXT,
JM_PAYLOAD_FIELD_SUB_MODULE,
0,
- get_jm_submod_desc(err->subsystem_id, err->module_id, err->submodule_id));
+ get_jm_submod_desc(err->subsystem_id,
+ err->module_id, err->submodule_id));
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_INT,
JM_PAYLOAD_FIELD_MODULE_ID,
err->submodule_id, NULL);
if (err->val_bits & BIT(JM_COMMON_VALID_DEV_ID)) {
JM_SNPRINTF(event->error_msg, " dev=%s",
- get_jm_dev_desc(err->subsystem_id, err->module_id, err->submodule_id));
+ get_jm_dev_desc(err->subsystem_id,
+ err->module_id, err->submodule_id));
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_TEXT,
JM_PAYLOAD_FIELD_DEV,
- 0, get_jm_dev_desc(err->subsystem_id, err->module_id, err->submodule_id));
+ 0, get_jm_dev_desc(err->subsystem_id,
+ err->module_id, err->submodule_id));
record_jm_data(ev_decoder, JM_OEM_DATA_TYPE_INT,
JM_PAYLOAD_FIELD_DEV_ID,
err->dev_id, NULL);
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#ifndef __RAS_AER_HANDLER_H
#define __RAS_AER_HANDLER_H
if (++line_count == 4) {
trace_seq_printf(s, "\n %08x: ", i);
line_count = 0;
- } else
+ } else {
trace_seq_printf(s, " ");
+ }
}
}
char real_path[PATH_MAX] = "";
snprintf(path, sizeof(path), format, cpu);
- if (strlen(path) > PATH_MAX || realpath(path, real_path) == NULL) {
+ if (strlen(path) > PATH_MAX || !realpath(path, real_path)) {
log(TERM, LOG_ERR, "[%s]:open file: %s failed\n", __func__, path);
return -1;
}
return -1;
}
*value = DEC_CHECK * (*value) + (env[i] - '0');
- } else
+ } else {
return -1;
+ }
}
if (!has_unit)
}
ret = error_handler(cpu, err_info);
- if (ret == HANDLE_NOTHING)
+ if (ret == HANDLE_NOTHING) {
log(TERM, LOG_WARNING, "Doing nothing in the cpu%d\n", cpu);
- else if (ret == HANDLE_SUCCEED) {
+ } else if (ret == HANDLE_SUCCEED) {
log(TERM, LOG_INFO, "Offline cpu%d succeed, the state is %s\n",
cpu, cpu_state[cpu_infos[cpu].state]);
clear_queue(cpu_infos[cpu].ce_queue);
cpu_infos[cpu].ce_nums = 0;
cpu_infos[cpu].uce_nums = 0;
- } else
+ } else {
log(TERM, LOG_WARNING, "Offline cpu%d fail, the state is %s\n",
cpu, cpu_state[cpu_infos[cpu].state]);
+ }
}
return uuid;
}
-static const char *get_cxl_type_str(const char **type_array, uint8_t num_elems, uint8_t type)
+static const char * const get_cxl_type_str(const char * const *type_array,
+ uint8_t num_elems, uint8_t type)
{
if (type >= num_elems)
return "Unknown";
if (tep_get_field_val(s, event, "overflow_ts", record, &val, 1) < 0)
return -1;
convert_timestamp(val, ev.overflow_ts, sizeof(ev.overflow_ts));
- } else
- strncpy(ev.overflow_ts, "1970-01-01 00:00:00 +0000", sizeof(ev.overflow_ts));
+ } else {
+ strncpy(ev.overflow_ts, "1970-01-01 00:00:00 +0000",
+ sizeof(ev.overflow_ts));
+ }
+
if (trace_seq_printf(s, "overflow timestamp:%s\n", ev.overflow_ts) <= 0)
return -1;
#define CXL_GMER_VALID_DEVICE BIT(2)
#define CXL_GMER_VALID_COMPONENT BIT(3)
-static const char *cxl_gmer_mem_event_type[] = {
+static const char * const cxl_gmer_mem_event_type[] = {
"ECC Error",
"Invalid Address",
"Data Path Error",
};
-static const char *cxl_gmer_trans_type[] = {
+static const char * const cxl_gmer_trans_type[] = {
"Unknown",
"Host Read",
"Host Write",
if (tep_get_field_val(s, event, "type", record, &val, 1) < 0)
return -1;
ev.type = val;
- if (trace_seq_printf(s, "type:%s ", get_cxl_type_str(cxl_gmer_mem_event_type,
- ARRAY_SIZE(cxl_gmer_mem_event_type), ev.type)) <= 0)
+ if (trace_seq_printf(s, "type:%s ",
+ get_cxl_type_str(cxl_gmer_mem_event_type,
+ ARRAY_SIZE(cxl_gmer_mem_event_type), ev.type)) <= 0)
return -1;
if (tep_get_field_val(s, event, "transaction_type", record, &val, 1) < 0)
ev.dpa_flags = val;
if (trace_seq_printf(s, "dpa_flags:") <= 0)
return -1;
- if (decode_cxl_event_flags(s, ev.dpa_flags, cxl_dpa_flags, ARRAY_SIZE(cxl_dpa_flags)) < 0)
+ if (decode_cxl_event_flags(s, ev.dpa_flags, cxl_dpa_flags,
+ ARRAY_SIZE(cxl_dpa_flags)) < 0)
return -1;
if (tep_get_field_val(s, event, "descriptor", record, &val, 1) < 0)
if (tep_get_field_val(s, event, "type", record, &val, 1) < 0)
return -1;
ev.type = val;
- if (trace_seq_printf(s, "type:%s ", get_cxl_type_str(cxl_gmer_mem_event_type,
- ARRAY_SIZE(cxl_gmer_mem_event_type), ev.type)) <= 0)
+ if (trace_seq_printf(s, "type:%s ",
+ get_cxl_type_str(cxl_gmer_mem_event_type,
+ ARRAY_SIZE(cxl_gmer_mem_event_type),
+ ev.type)) <= 0)
return -1;
if (tep_get_field_val(s, event, "transaction_type", record, &val, 1) < 0)
*
* CXL res 3.0 section 8.2.9.2.1.3; Table 8-45
*/
-static const char *cxl_dev_evt_type[] = {
+static const char * const cxl_dev_evt_type[] = {
"Health Status Change",
"Media Status Change",
"Life Used Change",
{ .bit = CXL_DHI_HS_HW_REPLACEMENT_NEEDED, .flag = "REPLACEMENT_NEEDED" },
};
-static const char *cxl_media_status[] = {
+static const char * const cxl_media_status[] = {
"Normal",
"Not Ready",
"Write Persistency Lost",
"All Data Loss Imminent",
};
-static const char *cxl_two_bit_status[] = {
+static const char * const cxl_two_bit_status[] = {
"Normal",
"Warning",
"Critical",
};
-static const char *cxl_one_bit_status[] = {
+static const char * const cxl_one_bit_status[] = {
"Normal",
"Warning",
};
-#define CXL_DHI_AS_LIFE_USED(as) (as & 0x3)
-#define CXL_DHI_AS_DEV_TEMP(as) ((as & 0xC) >> 2)
-#define CXL_DHI_AS_COR_VOL_ERR_CNT(as) ((as & 0x10) >> 4)
-#define CXL_DHI_AS_COR_PER_ERR_CNT(as) ((as & 0x20) >> 5)
+#define CXL_DHI_AS_LIFE_USED(as) ((as) & 0x3)
+#define CXL_DHI_AS_DEV_TEMP(as) (((as) & 0xC) >> 2)
+#define CXL_DHI_AS_COR_VOL_ERR_CNT(as) (((as) & 0x10) >> 4)
+#define CXL_DHI_AS_COR_PER_ERR_CNT(as) (((as) & 0x20) >> 5)
int ras_cxl_memory_module_event_handler(struct trace_seq *s,
struct tep_record *record,
if (tep_get_field_val(s, event, "event_type", record, &val, 1) < 0)
return -1;
ev.event_type = val;
- if (trace_seq_printf(s, "event_type:%s ", get_cxl_type_str(cxl_dev_evt_type,
- ARRAY_SIZE(cxl_dev_evt_type), ev.event_type)) <= 0)
+ if (trace_seq_printf(s, "event_type:%s ",
+ get_cxl_type_str(cxl_dev_evt_type,
+ ARRAY_SIZE(cxl_dev_evt_type),
+ ev.event_type)) <= 0)
return -1;
if (tep_get_field_val(s, event, "health_status", record, &val, 1) < 0)
if (tep_get_field_val(s, event, "media_status", record, &val, 1) < 0)
return -1;
ev.media_status = val;
- if (trace_seq_printf(s, "media_status:%s ", get_cxl_type_str(cxl_media_status,
- ARRAY_SIZE(cxl_media_status), ev.media_status)) <= 0)
+ if (trace_seq_printf(s, "media_status:%s ",
+ get_cxl_type_str(cxl_media_status,
+ ARRAY_SIZE(cxl_media_status),
+ ev.media_status)) <= 0)
return -1;
if (tep_get_field_val(s, event, "add_status", record, &val, 1) < 0)
return -1;
ev.add_status = val;
- if (trace_seq_printf(s, "as_life_used:%s ", get_cxl_type_str(cxl_two_bit_status,
- ARRAY_SIZE(cxl_two_bit_status),
+ if (trace_seq_printf(s, "as_life_used:%s ",
+ get_cxl_type_str(cxl_two_bit_status,
+ ARRAY_SIZE(cxl_two_bit_status),
CXL_DHI_AS_LIFE_USED(ev.add_status))) <= 0)
return -1;
- if (trace_seq_printf(s, "as_dev_temp:%s ", get_cxl_type_str(cxl_two_bit_status,
- ARRAY_SIZE(cxl_two_bit_status),
+ if (trace_seq_printf(s, "as_dev_temp:%s ",
+ get_cxl_type_str(cxl_two_bit_status,
+ ARRAY_SIZE(cxl_two_bit_status),
CXL_DHI_AS_DEV_TEMP(ev.add_status))) <= 0)
return -1;
- if (trace_seq_printf(s, "as_cor_vol_err_cnt:%s ", get_cxl_type_str(cxl_one_bit_status,
- ARRAY_SIZE(cxl_one_bit_status),
+ if (trace_seq_printf(s, "as_cor_vol_err_cnt:%s ",
+ get_cxl_type_str(cxl_one_bit_status,
+ ARRAY_SIZE(cxl_one_bit_status),
CXL_DHI_AS_COR_VOL_ERR_CNT(ev.add_status))) <= 0)
return -1;
- if (trace_seq_printf(s, "as_cor_per_err_cnt:%s ", get_cxl_type_str(cxl_one_bit_status,
- ARRAY_SIZE(cxl_one_bit_status),
+ if (trace_seq_printf(s, "as_cor_per_err_cnt:%s ",
+ get_cxl_type_str(cxl_one_bit_status,
+ ARRAY_SIZE(cxl_one_bit_status),
CXL_DHI_AS_COR_PER_ERR_CNT(ev.add_status))) <= 0)
return -1;
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
+
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#ifndef __RAS_DEVLINK_HANDLER_H
#define __RAS_DEVLINK_HANDLER_H
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
+
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#ifndef __RAS_DISKERROR_HANDLER_H
#define __RAS_DISKERROR_HANDLER_H
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
+
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
#include <sys/poll.h>
-#include <signal.h>
#include <sys/signalfd.h>
-#include <traceevent/kbuffer.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <traceevent/event-parse.h>
-#include "ras-mc-handler.h"
+#include <traceevent/kbuffer.h>
+#include <unistd.h>
+
#include "ras-aer-handler.h"
-#include "ras-non-standard-handler.h"
#include "ras-arm-handler.h"
-#include "ras-mce-handler.h"
-#include "ras-extlog-handler.h"
+#include "ras-cpu-isolation.h"
+#include "ras-cxl-handler.h"
#include "ras-devlink-handler.h"
#include "ras-diskerror-handler.h"
-#include "ras-memory-failure-handler.h"
-#include "ras-cxl-handler.h"
-#include "ras-record.h"
+#include "ras-extlog-handler.h"
#include "ras-logger.h"
+#include "ras-mce-handler.h"
+#include "ras-mc-handler.h"
+#include "ras-memory-failure-handler.h"
+#include "ras-non-standard-handler.h"
#include "ras-page-isolation.h"
-#include "ras-cpu-isolation.h"
+#include "ras-record.h"
#include "trigger.h"
/*
fclose(fp);
log(ALL, LOG_INFO, "Can't find debugfs\n");
- return ENOENT;
+ return -ENOENT;
}
static int open_trace(struct ras_events *ras, char *name, int flags)
snprintf(ras_event_name, sizeof(ras_event_name), "%s:%s",
group, event);
- if (choices_disable && strlen(choices_disable) != 0 && strstr(choices_disable, ras_event_name)) {
+ if (choices_disable && strlen(choices_disable) != 0 &&
+ strstr(choices_disable, ras_event_name)) {
return 1;
}
return 0;
do {
ready = poll(fds, (n_cpus + 1), -1);
- if (ready < 0) {
+ if (ready < 0)
log(TERM, LOG_WARNING, "poll\n");
- }
/* check for the signal */
if (fds[n_cpus].revents & POLLIN) {
goto err;
}
- data = calloc(sizeof(*data), cpus);
+ data = calloc(cpus, sizeof(*data));
if (!data)
goto err;
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#ifndef __RAS_EVENTS_H
#define __RAS_EVENTS_H
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
+
#include <ctype.h>
#include <errno.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <stdint.h>
#include <traceevent/kbuffer.h>
+
#include "ras-extlog-handler.h"
-#include "ras-record.h"
#include "ras-logger.h"
+#include "ras-record.h"
#include "ras-report.h"
static char *err_type(int etype)
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#ifndef __RAS_EXTLOG_HANDLER_H
#define __RAS_EXTLOG_HANDLER_H
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#ifndef __RAS_LOGGER_H
#define ALL (SYSLOG | TERM)
/* TODO: global logging limit mask */
-#define log(where, level, fmt, args...) do {\
- if (where & SYSLOG)\
- syslog(level, fmt, ##args);\
- if (where & TERM) {\
- fprintf(stderr, "%s: ", TOOL_NAME);\
- fprintf(stderr, fmt, ##args);\
- fflush(stderr);\
- }\
+#define log(where, level, fmt, args...) do { \
+ if ((where) & SYSLOG) \
+ syslog(level, fmt, ##args); \
+ if ((where) & TERM) { \
+ fprintf(stderr, "%s: ", TOOL_NAME); \
+ fprintf(stderr, fmt, ##args); \
+ fflush(stderr); \
+ } \
} while (0)
#define __RAS_LOGGER_H
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
+
#define _GNU_SOURCE
#include <assert.h>
#include <stdio.h>
case HW_EVENT_ERR_FATAL:
ev.error_type = "Fatal";
break;
- default:
case HW_EVENT_ERR_INFO:
+ default:
ev.error_type = "Info";
}
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#ifndef __RAS_MC_HANDLER_H
#define __RAS_MC_HANDLER_H
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
+
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
#include <traceevent/kbuffer.h>
+
#include "ras-mce-handler.h"
#include "ras-record.h"
#include "ras-logger.h"
f = fopen("/proc/cpuinfo", "r");
if (!f) {
log(ALL, LOG_INFO, "Can't open /proc/cpuinfo\n");
- return errno;
+ return -errno;
}
while (seen != CPU_ALL && getdelim(&line, &linelen, '\n', f) > 0) {
- if (sscanf(line, "vendor_id : %63[^\n]",
- (char *)&mce->vendor) == 1)
+ if (sscanf(line, "vendor_id : %63[^\n]", (char *)&mce->vendor) == 1) {
seen |= CPU_VENDOR;
- else if (sscanf(line, "cpu family : %d", &mce->family) == 1)
+ } else if (sscanf(line, "cpu family : %d", &mce->family) == 1) {
seen |= CPU_FAMILY;
- else if (sscanf(line, "model : %d", &mce->model) == 1)
+ } else if (sscanf(line, "model : %d", &mce->model) == 1) {
seen |= CPU_MODEL;
- else if (sscanf(line, "cpu MHz : %lf", &mce->mhz) == 1)
+ } else if (sscanf(line, "cpu MHz : %lf", &mce->mhz) == 1) {
seen |= CPU_MHZ;
- else if (!strncmp(line, "flags", 5) && isspace(line[6])) {
+ } else if (!strncmp(line, "flags", 5) && isspace(line[6])) {
if (mce->processor_flags)
free(mce->processor_flags);
mce->processor_flags = line;
}
}
if (!seen) {
- log(ALL, LOG_INFO, "Can't find a x86 CPU at /proc/cpuinfo. Disabling MCE handler.\n");
+ log(ALL, LOG_INFO,
+ "Can't find a x86 CPU at /proc/cpuinfo. Disabling MCE handler.\n");
ret = -ENOENT;
goto ret;
}
(seen & CPU_MODEL) ? "" : " [model]",
(seen & CPU_MHZ) ? "" : " [cpu MHz]",
(seen & CPU_FLAGS) ? "" : " [flags]");
- ret = EINVAL;
+ ret = -EINVAL;
goto ret;
}
log(ALL, LOG_INFO,
"Can't parse MCE for this AMD CPU yet %d\n",
mce->family);
- ret = EINVAL;
+ ret = -EINVAL;
}
goto ret;
} else if (!strcmp(mce->vendor, "HygonGenuine")) {
- if (mce->family == 24) {
+ if (mce->family == 24)
mce->cputype = CPU_DHYANA;
- }
+
goto ret;
} else if (!strcmp(mce->vendor, "GenuineIntel")) {
mce->cputype = select_intel_cputype(mce);
} else {
- ret = EINVAL;
+ ret = -EINVAL;
}
ret:
free(mce->processor_flags);
free(ras->mce_priv);
ras->mce_priv = NULL;
- return (rc);
+ return rc;
}
switch (mce->cputype) {
case CPU_SANDY_BRIDGE_EP:
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#ifndef __RAS_MCE_HANDLER_H
#define __RAS_MCE_HANDLER_H
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*/
+ */
#ifndef __RAS_MEMORY_FAILURE_HANDLER_H
#define __RAS_MEMORY_FAILURE_HANDLER_H
void print_le_hex(struct trace_seq *s, const uint8_t *buf, int index)
{
- trace_seq_printf(s, "%02x%02x%02x%02x", buf[index + 3], buf[index + 2], buf[index + 1], buf[index]);
+ trace_seq_printf(s, "%02x%02x%02x%02x",
+ buf[index + 3], buf[index + 2],
+ buf[index + 1], buf[index]);
}
static char *uuid_le(const char *uu)
if (++line_count == 4) {
trace_seq_printf(s, "\n %08x: ", i);
line_count = 0;
- } else
+ } else {
trace_seq_printf(s, " ");
+ }
}
}
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*/
+ */
#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
+#include <stdlib.h>
#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
+#include <unistd.h>
+
#include "ras-logger.h"
#include "ras-page-isolation.h"
.unit = "h",
};
-static const char *kernel_offline[] = {
+static const char * const kernel_offline[] = {
[OFFLINE_SOFT] = "/sys/devices/system/memory/soft_offline_page",
[OFFLINE_HARD] = "/sys/devices/system/memory/hard_offline_page",
[OFFLINE_SOFT_THEN_HARD] = "/sys/devices/system/memory/soft_offline_page",
{}
};
-static const char *page_state[] = {
+static const char * const page_state[] = {
[PAGE_ONLINE] = "online",
[PAGE_OFFLINE] = "offlined",
[PAGE_OFFLINE_FAILED] = "offline-failed",
if (!no_unit)
config->unit = unit;
} else {
- log(TERM, LOG_INFO, "Improper %s, set to default %s.\n",
- config->name, config->env);
+ log(TERM, LOG_INFO, "Improper %s, set to default %s.\n",
+ config->name, config->env);
}
/* if env value string is greater than ulong_max, truncate the last digit */
fd = open(kernel_offline[type], O_WRONLY);
if (fd == -1) {
- log(TERM, LOG_ERR, "[%s]:open file: %s failed\n", __func__, kernel_offline[type]);
+ log(TERM, LOG_ERR, "[%s]:open file: %s failed\n", __func__,
+ kernel_offline[type]);
return -1;
}
sprintf(buf, "%#llx", addr);
rc = write(fd, buf, strlen(buf));
- if (rc < 0) {
- log(TERM, LOG_ERR, "page offline addr(%s) by %s failed, errno:%d\n", buf, kernel_offline[type], errno);
- }
+ if (rc < 0)
+ log(TERM, LOG_ERR,
+ "page offline addr(%s) by %s failed, errno:%d\n",
+ buf, kernel_offline[type], errno);
+
close(fd);
return rc;
}
while (*entry) {
parent = *entry;
pr = rb_entry(parent, struct page_record, entry);
- if (addr == pr->addr) {
+ if (addr == pr->addr)
return pr;
- } else if (addr < pr->addr) {
+ else if (addr < pr->addr)
entry = &(*entry)->rb_left;
- } else {
+ else
entry = &(*entry)->rb_right;
- }
}
find = calloc(1, sizeof(struct page_record));
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-*/
+ */
#ifndef __RAS_PAGE_ISOLATION_H
#define __RAS_PAGE_ISOLATION_H
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
/*
* BuildRequires: sqlite-devel
.num_fields = ARRAY_SIZE(cxl_general_media_event_fields),
};
-int ras_store_cxl_general_media_event(struct ras_events *ras, struct ras_cxl_general_media_event *ev)
+int ras_store_cxl_general_media_event(struct ras_events *ras,
+ struct ras_cxl_general_media_event *ev)
{
int rc;
struct sqlite3_priv *priv = ras->db_priv;
.num_fields = ARRAY_SIZE(cxl_memory_module_event_fields),
};
-int ras_store_cxl_memory_module_event(struct ras_events *ras, struct ras_cxl_memory_module_event *ev)
+int ras_store_cxl_memory_module_event(struct ras_events *ras,
+ struct ras_cxl_memory_module_event *ev)
{
int rc;
struct sqlite3_priv *priv = ras->db_priv;
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ */
#ifndef __RAS_RECORD_H
#define __RAS_RECORD_H
int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev);
int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev);
int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev);
-int ras_store_extlog_mem_record(struct ras_events *ras, struct ras_extlog_event *ev);
-int ras_store_non_standard_record(struct ras_events *ras, struct ras_non_standard_event *ev);
+int ras_store_extlog_mem_record(struct ras_events *ras,
+ struct ras_extlog_event *ev);
+int ras_store_non_standard_record(struct ras_events *ras,
+ struct ras_non_standard_event *ev);
int ras_store_arm_record(struct ras_events *ras, struct ras_arm_event *ev);
int ras_store_devlink_event(struct ras_events *ras, struct devlink_event *ev);
-int ras_store_diskerror_event(struct ras_events *ras, struct diskerror_event *ev);
+int ras_store_diskerror_event(struct ras_events *ras,
+ struct diskerror_event *ev);
int ras_store_mf_event(struct ras_events *ras, struct ras_mf_event *ev);
-int ras_store_cxl_poison_event(struct ras_events *ras, struct ras_cxl_poison_event *ev);
-int ras_store_cxl_aer_ue_event(struct ras_events *ras, struct ras_cxl_aer_ue_event *ev);
-int ras_store_cxl_aer_ce_event(struct ras_events *ras, struct ras_cxl_aer_ce_event *ev);
-int ras_store_cxl_overflow_event(struct ras_events *ras, struct ras_cxl_overflow_event *ev);
-int ras_store_cxl_generic_event(struct ras_events *ras, struct ras_cxl_generic_event *ev);
-int ras_store_cxl_general_media_event(struct ras_events *ras, struct ras_cxl_general_media_event *ev);
-int ras_store_cxl_dram_event(struct ras_events *ras, struct ras_cxl_dram_event *ev);
-int ras_store_cxl_memory_module_event(struct ras_events *ras, struct ras_cxl_memory_module_event *ev);
+int ras_store_cxl_poison_event(struct ras_events *ras,
+ struct ras_cxl_poison_event *ev);
+int ras_store_cxl_aer_ue_event(struct ras_events *ras,
+ struct ras_cxl_aer_ue_event *ev);
+int ras_store_cxl_aer_ce_event(struct ras_events *ras,
+ struct ras_cxl_aer_ce_event *ev);
+int ras_store_cxl_overflow_event(struct ras_events *ras,
+ struct ras_cxl_overflow_event *ev);
+int ras_store_cxl_generic_event(struct ras_events *ras,
+ struct ras_cxl_generic_event *ev);
+int ras_store_cxl_general_media_event(struct ras_events *ras,
+ struct ras_cxl_general_media_event *ev);
+int ras_store_cxl_dram_event(struct ras_events *ras,
+ struct ras_cxl_dram_event *ev);
+int ras_store_cxl_memory_module_event(struct ras_events *ras,
+ struct ras_cxl_memory_module_event *ev);
#else
-static inline int ras_mc_event_opendb(unsigned int cpu, struct ras_events *ras) { return 0; };
-static inline int ras_mc_event_closedb(unsigned int cpu, struct ras_events *ras) { return 0; };
-static inline int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev) { return 0; };
-static inline int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev) { return 0; };
-static inline int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev) { return 0; };
-static inline int ras_store_extlog_mem_record(struct ras_events *ras, struct ras_extlog_event *ev) { return 0; };
-static inline int ras_store_non_standard_record(struct ras_events *ras, struct ras_non_standard_event *ev) { return 0; };
-static inline int ras_store_arm_record(struct ras_events *ras, struct ras_arm_event *ev) { return 0; };
-static inline int ras_store_devlink_event(struct ras_events *ras, struct devlink_event *ev) { return 0; };
-static inline int ras_store_diskerror_event(struct ras_events *ras, struct diskerror_event *ev) { return 0; };
-static inline int ras_store_mf_event(struct ras_events *ras, struct ras_mf_event *ev) { return 0; };
-static inline int ras_store_cxl_poison_event(struct ras_events *ras, struct ras_cxl_poison_event *ev) { return 0; };
-static inline int ras_store_cxl_aer_ue_event(struct ras_events *ras, struct ras_cxl_aer_ue_event *ev) { return 0; };
-static inline int ras_store_cxl_aer_ce_event(struct ras_events *ras, struct ras_cxl_aer_ce_event *ev) { return 0; };
-static inline int ras_store_cxl_overflow_event(struct ras_events *ras, struct ras_cxl_overflow_event *ev) { return 0; };
-static inline int ras_store_cxl_generic_event(struct ras_events *ras, struct ras_cxl_generic_event *ev) { return 0; };
-static inline int ras_store_cxl_general_media_event(struct ras_events *ras, struct ras_cxl_general_media_event *ev) { return 0; };
-static inline int ras_store_cxl_dram_event(struct ras_events *ras, struct ras_cxl_dram_event *ev) { return 0; };
-static inline int ras_store_cxl_memory_module_event(struct ras_events *ras, struct ras_cxl_memory_module_event *ev) { return 0; };
+static inline int ras_mc_event_opendb(unsigned int cpu,
+ struct ras_events *ras) { return 0; };
+static inline int ras_mc_event_closedb(unsigned int cpu,
+ struct ras_events *ras) { return 0; };
+static inline int ras_store_mc_event(struct ras_events *ras,
+ struct ras_mc_event *ev) { return 0; };
+static inline int ras_store_aer_event(struct ras_events *ras,
+ struct ras_aer_event *ev) { return 0; };
+static inline int ras_store_mce_record(struct ras_events *ras,
+ struct mce_event *ev) { return 0; };
+static inline int ras_store_extlog_mem_record(struct ras_events *ras,
+ struct ras_extlog_event *ev) { return 0; };
+static inline int ras_store_non_standard_record(struct ras_events *ras,
+ struct ras_non_standard_event *ev) { return 0; };
+static inline int ras_store_arm_record(struct ras_events *ras,
+ struct ras_arm_event *ev) { return 0; };
+static inline int ras_store_devlink_event(struct ras_events *ras,
+ struct devlink_event *ev) { return 0; };
+static inline int ras_store_diskerror_event(struct ras_events *ras,
+ struct diskerror_event *ev) { return 0; };
+static inline int ras_store_mf_event(struct ras_events *ras,
+ struct ras_mf_event *ev) { return 0; };
+static inline int ras_store_cxl_poison_event(struct ras_events *ras,
+ struct ras_cxl_poison_event *ev) { return 0; };
+static inline int ras_store_cxl_aer_ue_event(struct ras_events *ras,
+ struct ras_cxl_aer_ue_event *ev) { return 0; };
+static inline int ras_store_cxl_aer_ce_event(struct ras_events *ras,
+ struct ras_cxl_aer_ce_event *ev) { return 0; };
+static inline int ras_store_cxl_overflow_event(struct ras_events *ras,
+ struct ras_cxl_overflow_event *ev) { return 0; };
+static inline int ras_store_cxl_generic_event(struct ras_events *ras,
+ struct ras_cxl_generic_event *ev) { return 0; };
+static inline int ras_store_cxl_general_media_event(struct ras_events *ras,
+ struct ras_cxl_general_media_event *ev) { return 0; };
+static inline int ras_store_cxl_dram_event(struct ras_events *ras,
+ struct ras_cxl_dram_event *ev) { return 0; };
+static inline int ras_store_cxl_memory_module_event(struct ras_events *ras,
+ struct ras_cxl_memory_module_event *ev) { return 0; };
#endif
struct sockaddr_un addr;
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (sockfd < 0) {
+ if (sockfd < 0)
return -1;
- }
memset(&addr, 0, sizeof(struct sockaddr_un));
addr.sun_family = AF_UNIX;
struct utsname un;
int rc = -1;
- if (sockfd < 0) {
+ if (sockfd < 0)
return rc;
- }
memset(buf, 0, INPUT_BUFFER_SIZE);
memset(&un, 0, sizeof(struct utsname));
rc = uname(&un);
- if (rc < 0) {
+ if (rc < 0)
return rc;
- }
/*
* ABRT server protocol
*/
sprintf(buf, "PUT / HTTP/1.1\r\n\r\n");
rc = write(sockfd, buf, strlen(buf));
- if (rc < strlen(buf)) {
+ if (rc < strlen(buf))
return -1;
- }
sprintf(buf, "PID=%d", (int)getpid());
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
return -1;
- }
sprintf(buf, "EXECUTABLE=/boot/vmlinuz-%s", un.release);
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
return -1;
- }
sprintf(buf, "TYPE=%s", "ras");
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
return -1;
- }
return 0;
}
if (!buf || !ev)
return -1;
- sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "error_count=%d\n" \
- "error_type=%s\n" \
- "msg=%s\n" \
- "label=%s\n" \
- "mc_index=%c\n" \
- "top_layer=%c\n" \
- "middle_layer=%c\n" \
- "lower_layer=%c\n" \
- "address=%llu\n" \
- "grain=%llu\n" \
- "syndrome=%llu\n" \
- "driver_detail=%s\n", \
- ev->timestamp, \
- ev->error_count, \
- ev->error_type, \
- ev->msg, \
- ev->label, \
- ev->mc_index, \
- ev->top_layer, \
- ev->middle_layer, \
- ev->lower_layer, \
- ev->address, \
- ev->grain, \
- ev->syndrome, \
- ev->driver_detail);
+ sprintf(bt_buf, "BACKTRACE="
+ "timestamp=%s\n"
+ "error_count=%d\n"
+ "error_type=%s\n"
+ "msg=%s\n"
+ "label=%s\n"
+ "mc_index=%c\n"
+ "top_layer=%c\n"
+ "middle_layer=%c\n"
+ "lower_layer=%c\n"
+ "address=%llu\n"
+ "grain=%llu\n"
+ "syndrome=%llu\n"
+ "driver_detail=%s\n",
+ ev->timestamp,
+ ev->error_count,
+ ev->error_type,
+ ev->msg,
+ ev->label,
+ ev->mc_index,
+ ev->top_layer,
+ ev->middle_layer,
+ ev->lower_layer,
+ ev->address,
+ ev->grain,
+ ev->syndrome,
+ ev->driver_detail);
strcat(buf, bt_buf);
if (!buf || !ev)
return -1;
- sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "bank_name=%s\n" \
- "error_msg=%s\n" \
- "mcgstatus_msg=%s\n" \
- "mcistatus_msg=%s\n" \
- "mcastatus_msg=%s\n" \
- "user_action=%s\n" \
- "mc_location=%s\n" \
- "mcgcap=%lu\n" \
- "mcgstatus=%lu\n" \
- "status=%lu\n" \
- "addr=%lu\n" \
- "misc=%lu\n" \
- "ip=%lu\n" \
- "tsc=%lu\n" \
- "walltime=%lu\n" \
- "cpu=%u\n" \
- "cpuid=%u\n" \
- "apicid=%u\n" \
- "socketid=%u\n" \
- "cs=%d\n" \
- "bank=%d\n" \
- "cpuvendor=%d\n", \
- ev->timestamp, \
- ev->bank_name, \
- ev->error_msg, \
- ev->mcgstatus_msg, \
- ev->mcistatus_msg, \
- ev->mcastatus_msg, \
- ev->user_action, \
- ev->mc_location, \
- ev->mcgcap, \
- ev->mcgstatus, \
- ev->status, \
- ev->addr, \
- ev->misc, \
- ev->ip, \
- ev->tsc, \
- ev->walltime, \
- ev->cpu, \
- ev->cpuid, \
- ev->apicid, \
- ev->socketid, \
- ev->cs, \
- ev->bank, \
- ev->cpuvendor);
+ sprintf(bt_buf, "BACKTRACE="
+ "timestamp=%s\n"
+ "bank_name=%s\n"
+ "error_msg=%s\n"
+ "mcgstatus_msg=%s\n"
+ "mcistatus_msg=%s\n"
+ "mcastatus_msg=%s\n"
+ "user_action=%s\n"
+ "mc_location=%s\n"
+ "mcgcap=%lu\n"
+ "mcgstatus=%lu\n"
+ "status=%lu\n"
+ "addr=%lu\n"
+ "misc=%lu\n"
+ "ip=%lu\n"
+ "tsc=%lu\n"
+ "walltime=%lu\n"
+ "cpu=%u\n"
+ "cpuid=%u\n"
+ "apicid=%u\n"
+ "socketid=%u\n"
+ "cs=%d\n"
+ "bank=%d\n"
+ "cpuvendor=%d\n",
+ ev->timestamp,
+ ev->bank_name,
+ ev->error_msg,
+ ev->mcgstatus_msg,
+ ev->mcistatus_msg,
+ ev->mcastatus_msg,
+ ev->user_action,
+ ev->mc_location,
+ ev->mcgcap,
+ ev->mcgstatus,
+ ev->status,
+ ev->addr,
+ ev->misc,
+ ev->ip,
+ ev->tsc,
+ ev->walltime,
+ ev->cpu,
+ ev->cpuid,
+ ev->apicid,
+ ev->socketid,
+ ev->cs,
+ ev->bank,
+ ev->cpuvendor);
strcat(buf, bt_buf);
if (!buf || !ev)
return -1;
- sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "error_type=%s\n" \
- "dev_name=%s\n" \
- "msg=%s\n", \
- ev->timestamp, \
- ev->error_type, \
- ev->dev_name, \
- ev->msg);
+ sprintf(bt_buf, "BACKTRACE="
+ "timestamp=%s\n"
+ "error_type=%s\n"
+ "dev_name=%s\n"
+ "msg=%s\n",
+ ev->timestamp,
+ ev->error_type,
+ ev->dev_name,
+ ev->msg);
strcat(buf, bt_buf);
if (!buf || !ev)
return -1;
- sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "severity=%s\n" \
- "length=%d\n", \
- ev->timestamp, \
- ev->severity, \
- ev->length);
+ sprintf(bt_buf, "BACKTRACE="
+ "timestamp=%s\n"
+ "severity=%s\n"
+ "length=%d\n",
+ ev->timestamp,
+ ev->severity,
+ ev->length);
strcat(buf, bt_buf);
if (!buf || !ev)
return -1;
- sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "error_count=%d\n" \
- "affinity=%d\n" \
- "mpidr=0x%lx\n" \
- "midr=0x%lx\n" \
- "running_state=%d\n" \
- "psci_state=%d\n", \
- ev->timestamp, \
- ev->error_count, \
- ev->affinity, \
- ev->mpidr, \
- ev->midr, \
- ev->running_state, \
- ev->psci_state);
+ sprintf(bt_buf, "BACKTRACE="
+ "timestamp=%s\n"
+ "error_count=%d\n"
+ "affinity=%d\n"
+ "mpidr=0x%lx\n"
+ "midr=0x%lx\n"
+ "running_state=%d\n"
+ "psci_state=%d\n",
+ ev->timestamp,
+ ev->error_count,
+ ev->affinity,
+ ev->mpidr,
+ ev->midr,
+ ev->running_state,
+ ev->psci_state);
strcat(buf, bt_buf);
if (!buf || !ev)
return -1;
- sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "bus_name=%s\n" \
- "dev_name=%s\n" \
- "driver_name=%s\n" \
- "reporter_name=%s\n" \
- "msg=%s\n", \
- ev->timestamp, \
- ev->bus_name, \
- ev->dev_name, \
- ev->driver_name, \
- ev->reporter_name, \
- ev->msg);
+ sprintf(bt_buf, "BACKTRACE="
+ "timestamp=%s\n"
+ "bus_name=%s\n"
+ "dev_name=%s\n"
+ "driver_name=%s\n"
+ "reporter_name=%s\n"
+ "msg=%s\n",
+ ev->timestamp,
+ ev->bus_name,
+ ev->dev_name,
+ ev->driver_name,
+ ev->reporter_name,
+ ev->msg);
strcat(buf, bt_buf);
if (!buf || !ev)
return -1;
- sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "dev=%s\n" \
- "sector=%llu\n" \
- "nr_sector=%u\n" \
- "error=%s\n" \
- "rwbs=%s\n" \
- "cmd=%s\n", \
- ev->timestamp, \
- ev->dev, \
- ev->sector, \
- ev->nr_sector, \
- ev->error, \
- ev->rwbs, \
- ev->cmd);
+ sprintf(bt_buf, "BACKTRACE="
+ "timestamp=%s\n"
+ "dev=%s\n"
+ "sector=%llu\n"
+ "nr_sector=%u\n"
+ "error=%s\n"
+ "rwbs=%s\n"
+ "cmd=%s\n",
+ ev->timestamp,
+ ev->dev,
+ ev->sector,
+ ev->nr_sector,
+ ev->error,
+ ev->rwbs,
+ ev->cmd);
strcat(buf, bt_buf);
if (!buf || !ev)
return -1;
- sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "pfn=%s\n" \
- "page_type=%s\n" \
- "action_result=%s\n", \
- ev->timestamp, \
- ev->pfn, \
- ev->page_type, \
- ev->action_result);
+ sprintf(bt_buf, "BACKTRACE="
+ "timestamp=%s\n"
+ "pfn=%s\n"
+ "page_type=%s\n"
+ "action_result=%s\n",
+ ev->timestamp,
+ ev->pfn,
+ ev->page_type,
+ ev->action_result);
strcat(buf, bt_buf);
if (!buf || !ev)
return -1;
- sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "memdev=%s\n" \
- "host=%s\n" \
- "serial=0x%lx\n" \
- "trace_type=%s\n" \
- "region=%s\n" \
- "region_uuid=%s\n" \
- "hpa=0x%lx\n" \
- "dpa=0x%lx\n" \
- "dpa_length=0x%x\n" \
- "source=%s\n" \
- "flags=%u\n" \
- "overflow_timestamp=%s\n", \
- ev->timestamp, \
- ev->memdev, \
- ev->host, \
- ev->serial, \
- ev->trace_type, \
- ev->region, \
- ev->uuid, \
- ev->hpa, \
- ev->dpa, \
- ev->dpa_length, \
- ev->source, \
- ev->flags, \
- ev->overflow_ts);
+ sprintf(bt_buf, "BACKTRACE="
+ "timestamp=%s\n"
+ "memdev=%s\n"
+ "host=%s\n"
+ "serial=0x%lx\n"
+ "trace_type=%s\n"
+ "region=%s\n"
+ "region_uuid=%s\n"
+ "hpa=0x%lx\n"
+ "dpa=0x%lx\n"
+ "dpa_length=0x%x\n"
+ "source=%s\n"
+ "flags=%u\n"
+ "overflow_timestamp=%s\n",
+ ev->timestamp,
+ ev->memdev,
+ ev->host,
+ ev->serial,
+ ev->trace_type,
+ ev->region,
+ ev->uuid,
+ ev->hpa,
+ ev->dpa,
+ ev->dpa_length,
+ ev->source,
+ ev->flags,
+ ev->overflow_ts);
strcat(buf, bt_buf);
if (!buf || !ev)
return -1;
- sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "memdev=%s\n" \
- "host=%s\n" \
- "serial=0x%lx\n" \
- "error_status=%u\n" \
- "first_error=%u\n", \
- ev->timestamp, \
- ev->memdev, \
- ev->host, \
- ev->serial, \
- ev->error_status, \
- ev->first_error);
+ sprintf(bt_buf, "BACKTRACE="
+ "timestamp=%s\n"
+ "memdev=%s\n"
+ "host=%s\n"
+ "serial=0x%lx\n"
+ "error_status=%u\n"
+ "first_error=%u\n",
+ ev->timestamp,
+ ev->memdev,
+ ev->host,
+ ev->serial,
+ ev->error_status,
+ ev->first_error);
strcat(buf, bt_buf);
if (!buf || !ev)
return -1;
- sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "memdev=%s\n" \
- "host=%s\n" \
- "serial=0x%lx\n" \
- "error_status=%u\n", \
- ev->timestamp, \
- ev->memdev, \
- ev->host, \
- ev->serial, \
- ev->error_status);
+ sprintf(bt_buf, "BACKTRACE="
+ "timestamp=%s\n"
+ "memdev=%s\n"
+ "host=%s\n"
+ "serial=0x%lx\n"
+ "error_status=%u\n",
+ ev->timestamp,
+ ev->memdev,
+ ev->host,
+ ev->serial,
+ ev->error_status);
strcat(buf, bt_buf);
if (!buf || !ev)
return -1;
- sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "memdev=%s\n" \
- "host=%s\n" \
- "serial=0x%lx\n" \
- "log_type=%s\n" \
- "count=%u\n" \
- "first_ts=%s\n" \
- "last_ts=%s\n", \
- ev->timestamp, \
- ev->memdev, \
- ev->host, \
- ev->serial, \
- ev->log_type, \
- ev->count, \
- ev->first_ts, \
- ev->last_ts);
+ sprintf(bt_buf, "BACKTRACE="
+ "timestamp=%s\n"
+ "memdev=%s\n"
+ "host=%s\n"
+ "serial=0x%lx\n"
+ "log_type=%s\n"
+ "count=%u\n"
+ "first_ts=%s\n"
+ "last_ts=%s\n",
+ ev->timestamp,
+ ev->memdev,
+ ev->host,
+ ev->serial,
+ ev->log_type,
+ ev->count,
+ ev->first_ts,
+ ev->last_ts);
strcat(buf, bt_buf);
if (!buf || !ev)
return -1;
- sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "memdev=%s\n" \
- "host=%s\n" \
- "serial=0x%lx\n" \
- "log_type=%s\n" \
- "hdr_uuid=%s\n" \
- "hdr_flags=0x%x\n" \
- "hdr_handle=0x%x\n" \
- "hdr_related_handle=0x%x\n" \
- "hdr_timestamp=%s\n" \
- "hdr_length=%u\n" \
- "hdr_maint_op_class=%u\n", \
- ev->hdr.timestamp, \
- ev->hdr.memdev, \
- ev->hdr.host, \
- ev->hdr.serial, \
- ev->hdr.log_type, \
- ev->hdr.hdr_uuid, \
- ev->hdr.hdr_flags, \
- ev->hdr.hdr_handle, \
- ev->hdr.hdr_related_handle, \
- ev->hdr.hdr_timestamp, \
- ev->hdr.hdr_length, \
- ev->hdr.hdr_maint_op_class);
+ sprintf(bt_buf, "BACKTRACE="
+ "timestamp=%s\n"
+ "memdev=%s\n"
+ "host=%s\n"
+ "serial=0x%lx\n"
+ "log_type=%s\n"
+ "hdr_uuid=%s\n"
+ "hdr_flags=0x%x\n"
+ "hdr_handle=0x%x\n"
+ "hdr_related_handle=0x%x\n"
+ "hdr_timestamp=%s\n"
+ "hdr_length=%u\n"
+ "hdr_maint_op_class=%u\n",
+ ev->hdr.timestamp,
+ ev->hdr.memdev,
+ ev->hdr.host,
+ ev->hdr.serial,
+ ev->hdr.log_type,
+ ev->hdr.hdr_uuid,
+ ev->hdr.hdr_flags,
+ ev->hdr.hdr_handle,
+ ev->hdr.hdr_related_handle,
+ ev->hdr.hdr_timestamp,
+ ev->hdr.hdr_length,
+ ev->hdr.hdr_maint_op_class);
strcat(buf, bt_buf);
if (!buf || !ev)
return -1;
- sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "memdev=%s\n" \
- "host=%s\n" \
- "serial=0x%lx\n" \
- "log_type=%s\n" \
- "hdr_uuid=%s\n" \
- "hdr_flags=0x%x\n" \
- "hdr_handle=0x%x\n" \
- "hdr_related_handle=0x%x\n" \
- "hdr_timestamp=%s\n" \
- "hdr_length=%u\n" \
- "hdr_maint_op_class=%u\n" \
- "dpa=0x%lx\n" \
- "dpa_flags=%u\n" \
- "descriptor=%u\n" \
- "type=%u\n" \
- "transaction_type=%u\n" \
- "channel=%u\n" \
- "rank=%u\n" \
- "device=0x%x\n", \
- ev->hdr.timestamp, \
- ev->hdr.memdev, \
- ev->hdr.host, \
- ev->hdr.serial, \
- ev->hdr.log_type, \
- ev->hdr.hdr_uuid, \
- ev->hdr.hdr_flags, \
- ev->hdr.hdr_handle, \
- ev->hdr.hdr_related_handle, \
- ev->hdr.hdr_timestamp, \
- ev->hdr.hdr_length, \
- ev->hdr.hdr_maint_op_class, \
- ev->dpa, \
- ev->dpa_flags, \
- ev->descriptor, \
- ev->type, \
- ev->transaction_type, \
- ev->channel, \
- ev->rank, \
- ev->device);
+ sprintf(bt_buf, "BACKTRACE="
+ "timestamp=%s\n"
+ "memdev=%s\n"
+ "host=%s\n"
+ "serial=0x%lx\n"
+ "log_type=%s\n"
+ "hdr_uuid=%s\n"
+ "hdr_flags=0x%x\n"
+ "hdr_handle=0x%x\n"
+ "hdr_related_handle=0x%x\n"
+ "hdr_timestamp=%s\n"
+ "hdr_length=%u\n"
+ "hdr_maint_op_class=%u\n"
+ "dpa=0x%lx\n"
+ "dpa_flags=%u\n"
+ "descriptor=%u\n"
+ "type=%u\n"
+ "transaction_type=%u\n"
+ "channel=%u\n"
+ "rank=%u\n"
+ "device=0x%x\n",
+ ev->hdr.timestamp,
+ ev->hdr.memdev,
+ ev->hdr.host,
+ ev->hdr.serial,
+ ev->hdr.log_type,
+ ev->hdr.hdr_uuid,
+ ev->hdr.hdr_flags,
+ ev->hdr.hdr_handle,
+ ev->hdr.hdr_related_handle,
+ ev->hdr.hdr_timestamp,
+ ev->hdr.hdr_length,
+ ev->hdr.hdr_maint_op_class,
+ ev->dpa,
+ ev->dpa_flags,
+ ev->descriptor,
+ ev->type,
+ ev->transaction_type,
+ ev->channel,
+ ev->rank,
+ ev->device);
strcat(buf, bt_buf);
if (!buf || !ev)
return -1;
- sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "memdev=%s\n" \
- "host=%s\n" \
- "serial=0x%lx\n" \
- "log_type=%s\n" \
- "hdr_uuid=%s\n" \
- "hdr_flags=0x%x\n" \
- "hdr_handle=0x%x\n" \
- "hdr_related_handle=0x%x\n" \
- "hdr_timestamp=%s\n" \
- "hdr_length=%u\n" \
- "hdr_maint_op_class=%u\n" \
- "dpa=0x%lx\n" \
- "dpa_flags=%u\n" \
- "descriptor=%u\n" \
- "type=%u\n" \
- "transaction_type=%u\n" \
- "channel=%u\n" \
- "rank=%u\n" \
- "nibble_mask=%u\n" \
- "bank_group=%u\n" \
- "bank=%u\n" \
- "row=%u\n" \
- "column=%u\n", \
- ev->hdr.timestamp, \
- ev->hdr.memdev, \
- ev->hdr.host, \
- ev->hdr.serial, \
- ev->hdr.log_type, \
- ev->hdr.hdr_uuid, \
- ev->hdr.hdr_flags, \
- ev->hdr.hdr_handle, \
- ev->hdr.hdr_related_handle, \
- ev->hdr.hdr_timestamp, \
- ev->hdr.hdr_length, \
- ev->hdr.hdr_maint_op_class, \
- ev->dpa, \
- ev->dpa_flags, \
- ev->descriptor, \
- ev->type, \
- ev->transaction_type, \
- ev->channel, \
- ev->rank, \
- ev->nibble_mask, \
- ev->bank_group, \
- ev->bank, \
- ev->row, \
- ev->column);
+ sprintf(bt_buf, "BACKTRACE="
+ "timestamp=%s\n"
+ "memdev=%s\n"
+ "host=%s\n"
+ "serial=0x%lx\n"
+ "log_type=%s\n"
+ "hdr_uuid=%s\n"
+ "hdr_flags=0x%x\n"
+ "hdr_handle=0x%x\n"
+ "hdr_related_handle=0x%x\n"
+ "hdr_timestamp=%s\n"
+ "hdr_length=%u\n"
+ "hdr_maint_op_class=%u\n"
+ "dpa=0x%lx\n"
+ "dpa_flags=%u\n"
+ "descriptor=%u\n"
+ "type=%u\n"
+ "transaction_type=%u\n"
+ "channel=%u\n"
+ "rank=%u\n"
+ "nibble_mask=%u\n"
+ "bank_group=%u\n"
+ "bank=%u\n"
+ "row=%u\n"
+ "column=%u\n",
+ ev->hdr.timestamp,
+ ev->hdr.memdev,
+ ev->hdr.host,
+ ev->hdr.serial,
+ ev->hdr.log_type,
+ ev->hdr.hdr_uuid,
+ ev->hdr.hdr_flags,
+ ev->hdr.hdr_handle,
+ ev->hdr.hdr_related_handle,
+ ev->hdr.hdr_timestamp,
+ ev->hdr.hdr_length,
+ ev->hdr.hdr_maint_op_class,
+ ev->dpa,
+ ev->dpa_flags,
+ ev->descriptor,
+ ev->type,
+ ev->transaction_type,
+ ev->channel,
+ ev->rank,
+ ev->nibble_mask,
+ ev->bank_group,
+ ev->bank,
+ ev->row,
+ ev->column);
strcat(buf, bt_buf);
if (!buf || !ev)
return -1;
- sprintf(bt_buf, "BACKTRACE=" \
- "timestamp=%s\n" \
- "memdev=%s\n" \
- "host=%s\n" \
- "serial=0x%lx\n" \
- "log_type=%s\n" \
- "hdr_uuid=%s\n" \
- "hdr_flags=0x%x\n" \
- "hdr_handle=0x%x\n" \
- "hdr_related_handle=0x%x\n" \
- "hdr_timestamp=%s\n" \
- "hdr_length=%u\n" \
- "hdr_maint_op_class=%u\n" \
- "event_type=%u\n" \
- "health_status=%u\n" \
- "media_status=%u\n" \
- "life_used=%u\n" \
- "dirty_shutdown_cnt=%u\n" \
- "cor_vol_err_cnt=%u\n" \
- "cor_per_err_cnt=%u\n" \
- "device_temp=%d\n" \
- "add_status=%u\n", \
- ev->hdr.timestamp, \
- ev->hdr.memdev, \
- ev->hdr.host, \
- ev->hdr.serial, \
- ev->hdr.log_type, \
- ev->hdr.hdr_uuid, \
- ev->hdr.hdr_flags, \
- ev->hdr.hdr_handle, \
- ev->hdr.hdr_related_handle, \
- ev->hdr.hdr_timestamp, \
- ev->hdr.hdr_length, \
- ev->hdr.hdr_maint_op_class, \
- ev->event_type, \
- ev->health_status, \
- ev->media_status, \
- ev->life_used, \
- ev->dirty_shutdown_cnt, \
- ev->cor_vol_err_cnt, \
- ev->cor_per_err_cnt, \
- ev->device_temp, \
- ev->add_status);
+ sprintf(bt_buf, "BACKTRACE="
+ "timestamp=%s\n"
+ "memdev=%s\n"
+ "host=%s\n"
+ "serial=0x%lx\n"
+ "log_type=%s\n"
+ "hdr_uuid=%s\n"
+ "hdr_flags=0x%x\n"
+ "hdr_handle=0x%x\n"
+ "hdr_related_handle=0x%x\n"
+ "hdr_timestamp=%s\n"
+ "hdr_length=%u\n"
+ "hdr_maint_op_class=%u\n"
+ "event_type=%u\n"
+ "health_status=%u\n"
+ "media_status=%u\n"
+ "life_used=%u\n"
+ "dirty_shutdown_cnt=%u\n"
+ "cor_vol_err_cnt=%u\n"
+ "cor_per_err_cnt=%u\n"
+ "device_temp=%d\n"
+ "add_status=%u\n",
+ ev->hdr.timestamp,
+ ev->hdr.memdev,
+ ev->hdr.host,
+ ev->hdr.serial,
+ ev->hdr.log_type,
+ ev->hdr.hdr_uuid,
+ ev->hdr.hdr_flags,
+ ev->hdr.hdr_handle,
+ ev->hdr.hdr_related_handle,
+ ev->hdr.hdr_timestamp,
+ ev->hdr.hdr_length,
+ ev->hdr.hdr_maint_op_class,
+ ev->event_type,
+ ev->health_status,
+ ev->media_status,
+ ev->life_used,
+ ev->dirty_shutdown_cnt,
+ ev->cor_vol_err_cnt,
+ ev->cor_per_err_cnt,
+ ev->device_temp,
+ ev->add_status);
strcat(buf, bt_buf);
int rc = -1;
int buf_len = 0;
- if (sockfd < 0 || !ev) {
+ if (sockfd < 0 || !ev)
return -1;
- }
memset(buf, 0, MAX_BACKTRACE_SIZE);
switch (type) {
case MC_EVENT:
- rc = set_mc_event_backtrace(buf, (struct ras_mc_event *)ev);
+ rc = set_mc_event_backtrace(buf,
+ (struct ras_mc_event *)ev);
break;
case AER_EVENT:
- rc = set_aer_event_backtrace(buf, (struct ras_aer_event *)ev);
+ rc = set_aer_event_backtrace(buf,
+ (struct ras_aer_event *)ev);
break;
case MCE_EVENT:
- rc = set_mce_event_backtrace(buf, (struct mce_event *)ev);
+ rc = set_mce_event_backtrace(buf,
+ (struct mce_event *)ev);
break;
case NON_STANDARD_EVENT:
- rc = set_non_standard_event_backtrace(buf, (struct ras_non_standard_event *)ev);
+ rc = set_non_standard_event_backtrace(buf,
+ (struct ras_non_standard_event *)ev);
break;
case ARM_EVENT:
- rc = set_arm_event_backtrace(buf, (struct ras_arm_event *)ev);
+ rc = set_arm_event_backtrace(buf,
+ (struct ras_arm_event *)ev);
break;
case DEVLINK_EVENT:
- rc = set_devlink_event_backtrace(buf, (struct devlink_event *)ev);
+ rc = set_devlink_event_backtrace(buf,
+ (struct devlink_event *)ev);
break;
case DISKERROR_EVENT:
- rc = set_diskerror_event_backtrace(buf, (struct diskerror_event *)ev);
+ rc = set_diskerror_event_backtrace(buf,
+ (struct diskerror_event *)ev);
break;
case MF_EVENT:
- rc = set_mf_event_backtrace(buf, (struct ras_mf_event *)ev);
+ rc = set_mf_event_backtrace(buf,
+ (struct ras_mf_event *)ev);
break;
case CXL_POISON_EVENT:
- rc = set_cxl_poison_event_backtrace(buf, (struct ras_cxl_poison_event *)ev);
+ rc = set_cxl_poison_event_backtrace(buf,
+ (struct ras_cxl_poison_event *)ev);
break;
case CXL_AER_UE_EVENT:
- rc = set_cxl_aer_ue_event_backtrace(buf, (struct ras_cxl_aer_ue_event *)ev);
+ rc = set_cxl_aer_ue_event_backtrace(buf,
+ (struct ras_cxl_aer_ue_event *)ev);
break;
case CXL_AER_CE_EVENT:
- rc = set_cxl_aer_ce_event_backtrace(buf, (struct ras_cxl_aer_ce_event *)ev);
+ rc = set_cxl_aer_ce_event_backtrace(buf,
+ (struct ras_cxl_aer_ce_event *)ev);
break;
case CXL_OVERFLOW_EVENT:
- rc = set_cxl_overflow_event_backtrace(buf, (struct ras_cxl_overflow_event *)ev);
+ rc = set_cxl_overflow_event_backtrace(buf,
+ (struct ras_cxl_overflow_event *)ev);
break;
case CXL_GENERIC_EVENT:
- rc = set_cxl_generic_event_backtrace(buf, (struct ras_cxl_generic_event *)ev);
+ rc = set_cxl_generic_event_backtrace(buf,
+ (struct ras_cxl_generic_event *)ev);
break;
case CXL_GENERAL_MEDIA_EVENT:
- rc = set_cxl_general_media_event_backtrace(buf, (struct ras_cxl_general_media_event *)ev);
+ rc = set_cxl_general_media_event_backtrace(buf,
+ (struct ras_cxl_general_media_event *)ev);
break;
case CXL_DRAM_EVENT:
- rc = set_cxl_dram_event_backtrace(buf, (struct ras_cxl_dram_event *)ev);
+ rc = set_cxl_dram_event_backtrace(buf,
+ (struct ras_cxl_dram_event *)ev);
break;
case CXL_MEMORY_MODULE_EVENT:
- rc = set_cxl_memory_module_event_backtrace(buf, (struct ras_cxl_memory_module_event *)ev);
+ rc = set_cxl_memory_module_event_backtrace(buf,
+ (struct ras_cxl_memory_module_event *)ev);
break;
default:
return -1;
}
- if (rc < 0) {
+ if (rc < 0)
return -1;
- }
buf_len = strlen(buf);
for (; buf_len > INPUT_BUFFER_SIZE - 1; buf_len -= (INPUT_BUFFER_SIZE - 1)) {
rc = write(sockfd, pbuf, INPUT_BUFFER_SIZE - 1);
- if (rc < INPUT_BUFFER_SIZE - 1) {
+ if (rc < INPUT_BUFFER_SIZE - 1)
return -1;
- }
pbuf = pbuf + INPUT_BUFFER_SIZE - 1;
}
rc = write(sockfd, pbuf, buf_len + 1);
- if (rc < buf_len) {
+ if (rc < buf_len)
return -1;
- }
return 0;
}
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if (sockfd < 0) {
+ if (sockfd < 0)
return -1;
- }
rc = commit_report_basic(sockfd);
- if (rc < 0) {
+ if (rc < 0)
goto mc_fail;
- }
rc = commit_report_backtrace(sockfd, MC_EVENT, ev);
- if (rc < 0) {
+ if (rc < 0)
goto mc_fail;
- }
sprintf(buf, "ANALYZER=%s", "rasdaemon-mc");
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
goto mc_fail;
- }
sprintf(buf, "REASON=%s", "EDAC driver report problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
goto mc_fail;
- }
done = 1;
mc_fail:
-
- if (sockfd >= 0) {
+ if (sockfd >= 0)
close(sockfd);
- }
- if (done) {
+ if (done)
return 0;
- } else {
- return -1;
- }
+
+ return -1;
}
int ras_report_aer_event(struct ras_events *ras, struct ras_aer_event *ev)
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if (sockfd < 0) {
+ if (sockfd < 0)
return -1;
- }
rc = commit_report_basic(sockfd);
- if (rc < 0) {
+ if (rc < 0)
goto aer_fail;
- }
rc = commit_report_backtrace(sockfd, AER_EVENT, ev);
- if (rc < 0) {
+ if (rc < 0)
goto aer_fail;
- }
sprintf(buf, "ANALYZER=%s", "rasdaemon-aer");
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
goto aer_fail;
- }
sprintf(buf, "REASON=%s", "PCIe AER driver report problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
goto aer_fail;
- }
done = 1;
aer_fail:
- if (sockfd >= 0) {
+ if (sockfd >= 0)
close(sockfd);
- }
- if (done) {
+ if (done)
return 0;
- } else {
- return -1;
- }
+
+ return -1;
}
int ras_report_non_standard_event(struct ras_events *ras, struct ras_non_standard_event *ev)
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if (sockfd < 0) {
+ if (sockfd < 0)
return rc;
- }
rc = commit_report_basic(sockfd);
- if (rc < 0) {
+ if (rc < 0)
goto non_standard_fail;
- }
rc = commit_report_backtrace(sockfd, NON_STANDARD_EVENT, ev);
- if (rc < 0) {
+ if (rc < 0)
goto non_standard_fail;
- }
sprintf(buf, "ANALYZER=%s", "rasdaemon-non-standard");
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
goto non_standard_fail;
- }
sprintf(buf, "REASON=%s", "Unknown CPER section problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
goto non_standard_fail;
- }
rc = 0;
non_standard_fail:
- if (sockfd >= 0) {
+ if (sockfd >= 0)
close(sockfd);
- }
return rc;
}
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if (sockfd < 0) {
+ if (sockfd < 0)
return rc;
- }
rc = commit_report_basic(sockfd);
- if (rc < 0) {
+ if (rc < 0)
goto arm_fail;
- }
rc = commit_report_backtrace(sockfd, ARM_EVENT, ev);
- if (rc < 0) {
+ if (rc < 0)
goto arm_fail;
- }
sprintf(buf, "ANALYZER=%s", "rasdaemon-arm");
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
goto arm_fail;
- }
sprintf(buf, "REASON=%s", "ARM CPU report problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
goto arm_fail;
- }
rc = 0;
arm_fail:
- if (sockfd >= 0) {
+ if (sockfd >= 0)
close(sockfd);
- }
return rc;
}
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if (sockfd < 0) {
+ if (sockfd < 0)
return -1;
- }
rc = commit_report_basic(sockfd);
- if (rc < 0) {
+ if (rc < 0)
goto mce_fail;
- }
rc = commit_report_backtrace(sockfd, MCE_EVENT, ev);
- if (rc < 0) {
+ if (rc < 0)
goto mce_fail;
- }
sprintf(buf, "ANALYZER=%s", "rasdaemon-mce");
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
goto mce_fail;
- }
sprintf(buf, "REASON=%s", "Machine Check driver report problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
goto mce_fail;
- }
done = 1;
mce_fail:
- if (sockfd >= 0) {
+ if (sockfd >= 0)
close(sockfd);
- }
- if (done) {
+ if (done)
return 0;
- } else {
- return -1;
- }
+
+ return -1;
}
int ras_report_devlink_event(struct ras_events *ras, struct devlink_event *ev)
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if (sockfd < 0) {
+ if (sockfd < 0)
return -1;
- }
rc = commit_report_basic(sockfd);
- if (rc < 0) {
+ if (rc < 0)
goto devlink_fail;
- }
rc = commit_report_backtrace(sockfd, DEVLINK_EVENT, ev);
- if (rc < 0) {
+ if (rc < 0)
goto devlink_fail;
- }
sprintf(buf, "ANALYZER=%s", "rasdaemon-devlink");
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
goto devlink_fail;
- }
sprintf(buf, "REASON=%s", "devlink health report problem");
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
goto devlink_fail;
- }
done = 1;
devlink_fail:
- if (sockfd >= 0) {
+ if (sockfd >= 0)
close(sockfd);
- }
- if (done) {
+ if (done)
return 0;
- } else {
- return -1;
- }
+
+ return -1;
}
int ras_report_diskerror_event(struct ras_events *ras, struct diskerror_event *ev)
memset(buf, 0, sizeof(buf));
sockfd = setup_report_socket();
- if (sockfd < 0) {
+ if (sockfd < 0)
return -1;
- }
rc = commit_report_basic(sockfd);
- if (rc < 0) {
+ if (rc < 0)
goto diskerror_fail;
- }
rc = commit_report_backtrace(sockfd, DISKERROR_EVENT, ev);
- if (rc < 0) {
+ if (rc < 0)
goto diskerror_fail;
- }
sprintf(buf, "ANALYZER=%s", "rasdaemon-diskerror");
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
goto diskerror_fail;
- }
sprintf(buf, "REASON=%s", "disk I/O error");
rc = write(sockfd, buf, strlen(buf) + 1);
- if (rc < strlen(buf) + 1) {
+ if (rc < strlen(buf) + 1)
goto diskerror_fail;
- }
done = 1;
diskerror_fail:
- if (sockfd >= 0) {
+ if (sockfd >= 0)
close(sockfd);
- }
- if (done) {
+ if (done)
return 0;
- } else {
- return -1;
- }
+
+ return -1;
}
int ras_report_mf_event(struct ras_events *ras, struct ras_mf_event *ev)
if (done)
return 0;
- else
- return -1;
+
+ return -1;
}
int ras_report_cxl_aer_ue_event(struct ras_events *ras, struct ras_cxl_aer_ue_event *ev)
if (done)
return 0;
- else
- return -1;
+
+ return -1;
}
int ras_report_cxl_aer_ce_event(struct ras_events *ras, struct ras_cxl_aer_ce_event *ev)
if (done)
return 0;
- else
- return -1;
+
+ return -1;
}
int ras_report_cxl_overflow_event(struct ras_events *ras, struct ras_cxl_overflow_event *ev)
if (done)
return 0;
- else
- return -1;
+
+ return -1;
}
int ras_report_cxl_generic_event(struct ras_events *ras, struct ras_cxl_generic_event *ev)
if (done)
return 0;
- else
- return -1;
+
+ return -1;
}
int ras_report_cxl_general_media_event(struct ras_events *ras, struct ras_cxl_general_media_event *ev)
if (done)
return 0;
- else
- return -1;
+
+ return -1;
}
int ras_report_cxl_dram_event(struct ras_events *ras, struct ras_cxl_dram_event *ev)
if (done)
return 0;
- else
- return -1;
+
+ return -1;
}
int ras_report_cxl_memory_module_event(struct ras_events *ras, struct ras_cxl_memory_module_event *ev)
if (done)
return 0;
- else
- return -1;
+
+ return -1;
}
/*
- Red Black Trees
- (C) 1999 Andrea Arcangeli <andrea@suse.de>
- (C) 2002 David Woodhouse <dwmw2@infradead.org>
- Taken from the Linux 2.6.30 source with some minor modificatons.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- linux/lib/rbtree.c
-*/
+ * Red Black Trees
+ * (C) 1999 Andrea Arcangeli <andrea@suse.de>
+ * (C) 2002 David Woodhouse <dwmw2@infradead.org>
+ * Taken from the Linux 2.6.30 source with some minor modificatons.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
#include "rbtree.h"
rb_set_parent(right, parent);
- if (parent)
- {
+ if (parent) {
if (node == parent->rb_left)
parent->rb_left = right;
else
parent->rb_right = right;
- } else
+ } else {
root->rb_node = right;
+ }
rb_set_parent(node, right);
}
rb_set_parent(left, parent);
- if (parent)
- {
+ if (parent) {
if (node == parent->rb_right)
parent->rb_right = left;
else
parent->rb_left = left;
- } else
+ } else {
root->rb_node = left;
+ }
rb_set_parent(node, left);
}
{
struct rb_node *parent, *gparent;
- while ((parent = rb_parent(node)) && rb_is_red(parent))
- {
+ while ((parent = rb_parent(node)) && rb_is_red(parent)) {
gparent = rb_parent(parent);
- if (parent == gparent->rb_left)
- {
- {
- register struct rb_node *uncle = gparent->rb_right;
-
- if (uncle && rb_is_red(uncle))
- {
- rb_set_black(uncle);
- rb_set_black(parent);
- rb_set_red(gparent);
- node = gparent;
- continue;
- }
+ if (parent == gparent->rb_left) {
+ register struct rb_node *uncle = gparent->rb_right;
+
+ if (uncle && rb_is_red(uncle)) {
+ rb_set_black(uncle);
+ rb_set_black(parent);
+ rb_set_red(gparent);
+ node = gparent;
+ continue;
}
- if (parent->rb_right == node)
- {
+ if (parent->rb_right == node) {
struct rb_node *tmp;
__rb_rotate_left(parent, root);
rb_set_red(gparent);
__rb_rotate_right(gparent, root);
} else {
- {
- struct rb_node *uncle = gparent->rb_left;
-
- if (uncle && rb_is_red(uncle))
- {
- rb_set_black(uncle);
- rb_set_black(parent);
- rb_set_red(gparent);
- node = gparent;
- continue;
- }
+ struct rb_node *uncle = gparent->rb_left;
+
+ if (uncle && rb_is_red(uncle)) {
+ rb_set_black(uncle);
+ rb_set_black(parent);
+ rb_set_red(gparent);
+ node = gparent;
+ continue;
}
- if (parent->rb_left == node)
- {
+ if (parent->rb_left == node) {
struct rb_node *tmp;
__rb_rotate_right(parent, root);
{
struct rb_node *other;
- while ((!node || rb_is_black(node)) && node != root->rb_node)
- {
- if (parent->rb_left == node)
- {
+ while ((!node || rb_is_black(node)) && node != root->rb_node) {
+ if (parent->rb_left == node) {
other = parent->rb_right;
- if (rb_is_red(other))
- {
+ if (rb_is_red(other)) {
rb_set_black(other);
rb_set_red(parent);
__rb_rotate_left(parent, root);
other = parent->rb_right;
}
if ((!other->rb_left || rb_is_black(other->rb_left)) &&
- (!other->rb_right || rb_is_black(other->rb_right)))
- {
+ (!other->rb_right || rb_is_black(other->rb_right))) {
rb_set_red(other);
node = parent;
parent = rb_parent(node);
- } else
- {
- if (!other->rb_right || rb_is_black(other->rb_right))
- {
+ } else {
+ if (!other->rb_right || rb_is_black(other->rb_right)) {
rb_set_black(other->rb_left);
rb_set_red(other);
__rb_rotate_right(other, root);
node = root->rb_node;
break;
}
- } else
- {
+ } else {
other = parent->rb_left;
- if (rb_is_red(other))
- {
+ if (rb_is_red(other)) {
rb_set_black(other);
rb_set_red(parent);
__rb_rotate_right(parent, root);
other = parent->rb_left;
}
if ((!other->rb_left || rb_is_black(other->rb_left)) &&
- (!other->rb_right || rb_is_black(other->rb_right)))
- {
+ (!other->rb_right || rb_is_black(other->rb_right))) {
rb_set_red(other);
node = parent;
parent = rb_parent(node);
- } else
- {
- if (!other->rb_left || rb_is_black(other->rb_left))
- {
+ } else {
+ if (!other->rb_left || rb_is_black(other->rb_left)) {
rb_set_black(other->rb_right);
rb_set_red(other);
__rb_rotate_left(other, root);
struct rb_node *child, *parent;
int color;
- if (!node->rb_left)
+ if (!node->rb_left) {
child = node->rb_right;
- else if (!node->rb_right)
+ } else if (!node->rb_right) {
child = node->rb_left;
- else
- {
+ } else {
struct rb_node *old = node, *left;
node = node->rb_right;
if (parent == old) {
parent->rb_right = child;
parent = node;
- } else
+ } else {
parent->rb_left = child;
+ }
node->rb_parent_color = old->rb_parent_color;
node->rb_right = old->rb_right;
node->rb_left = old->rb_left;
- if (rb_parent(old))
- {
+ if (rb_parent(old)) {
if (rb_parent(old)->rb_left == old)
rb_parent(old)->rb_left = node;
else
rb_parent(old)->rb_right = node;
- } else
+ } else {
root->rb_node = node;
+ }
rb_set_parent(old->rb_left, node);
if (old->rb_right)
if (child)
rb_set_parent(child, parent);
- if (parent)
- {
+ if (parent) {
if (parent->rb_left == node)
parent->rb_left = child;
else
parent->rb_right = child;
- } else
+ } else {
root->rb_node = child;
+ }
color:
if (color == RB_BLACK)
if (rb_parent(node) == node)
return NULL;
- /* If we have a right-hand child, go down and then left as far
- as we can. */
+ /*
+ * If we have a right-hand child, go down and then left as far
+ * as we can.
+ */
if (node->rb_right) {
node = node->rb_right;
while (node->rb_left)
return (struct rb_node *)node;
}
- /* No right-hand children. Everything down and left is
- smaller than us, so any 'next' node must be in the general
- direction of our parent. Go up the tree; any time the
- ancestor is a right-hand child of its parent, keep going
- up. First time it's a left-hand child of its parent, said
- parent is our 'next' node. */
+ /*
+ * No right-hand children. Everything down and left is
+ * smaller than us, so any 'next' node must be in the general
+ * direction of our parent. Go up the tree; any time the
+ * ancestor is a right-hand child of its parent, keep going
+ * up. First time it's a left-hand child of its parent, said
+ * parent is our 'next' node.
+ */
while ((parent = rb_parent(node)) && node == parent->rb_right)
node = parent;
if (rb_parent(node) == node)
return NULL;
- /* If we have a left-hand child, go down and then right as far
- as we can. */
+ /*
+ * If we have a left-hand child, go down and then right as far
+ * as we can.
+ */
if (node->rb_left) {
node = node->rb_left;
while (node->rb_right)
return (struct rb_node *)node;
}
- /* No left-hand children. Go up till we find an ancestor which
- is a right-hand child of its parent */
+ /*
+ * No left-hand children. Go up till we find an ancestor which
+ * is a right-hand child of its parent
+ */
while ((parent = rb_parent(node)) && node == parent->rb_left)
node = parent;
/*
- Red Black Trees
- (C) 1999 Andrea Arcangeli <andrea@suse.de>
- Taken from the Linux 2.6.30 source.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- linux/include/linux/rbtree.h
-
- To use rbtrees you'll have to implement your own insert and search cores.
- This will avoid us to use callbacks and to drop drammatically performances.
- I know it's not the cleaner way, but in C (not in C++) to get
- performances and genericity...
-
- Some example of insert and search follows here. The search is a plain
- normal search over an ordered tree. The insert instead must be implemented
- int two steps: as first thing the code must insert the element in
- order as a red leaf in the tree, then the support library function
- rb_insert_color() must be called. Such function will do the
- not trivial work to rebalance the rbtree if necessary.
-
------------------------------------------------------------------------
-static inline struct page * rb_search_page_cache(struct inode * inode,
- unsigned long offset)
-{
- struct rb_node * n = inode->i_rb_page_cache.rb_node;
- struct page * page;
-
- while (n)
- {
- page = rb_entry(n, struct page, rb_page_cache);
-
- if (offset < page->offset)
- n = n->rb_left;
- else if (offset > page->offset)
- n = n->rb_right;
- else
- return page;
- }
- return NULL;
-}
-
-static inline struct page * __rb_insert_page_cache(struct inode * inode,
- unsigned long offset,
- struct rb_node * node)
-{
- struct rb_node ** p = &inode->i_rb_page_cache.rb_node;
- struct rb_node * parent = NULL;
- struct page * page;
-
- while (*p)
- {
- parent = *p;
- page = rb_entry(parent, struct page, rb_page_cache);
-
- if (offset < page->offset)
- p = &(*p)->rb_left;
- else if (offset > page->offset)
- p = &(*p)->rb_right;
- else
- return page;
- }
-
- rb_link_node(node, parent, p);
-
- return NULL;
-}
+ * Red Black Trees
+ * (C) 1999 Andrea Arcangeli <andrea@suse.de>
+ * Taken from the Linux 2.6.30 source.
+
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
-static inline struct page * rb_insert_page_cache(struct inode * inode,
- unsigned long offset,
- struct rb_node * node)
-{
- struct page * ret;
- if ((ret = __rb_insert_page_cache(inode, offset, node)))
- goto out;
- rb_insert_color(node, &inode->i_rb_page_cache);
- out:
- return ret;
-}
------------------------------------------------------------------------
-*/
+/*
+ * To use rbtrees you'll have to implement your own insert and search cores.
+ * This will avoid us to use callbacks and to drop drammatically performances.
+ * I know it's not the cleaner way, but in C (not in C++) to get
+ * performances and genericity...
+ *
+ * Some example of insert and search follows here. The search is a plain
+ * normal search over an ordered tree. The insert instead must be implemented
+ * int two steps: as first thing the code must insert the element in
+ * order as a red leaf in the tree, then the support library function
+ * rb_insert_color() must be called. Such function will do the
+ * not trivial work to rebalance the rbtree if necessary.
+ *
+ * -----------------------------------------------------------------------
+ *
+ * static inline struct page * rb_search_page_cache(struct inode * inode,
+ * unsigned long offset)
+ * {
+ * struct rb_node * n = inode->i_rb_page_cache.rb_node;
+ * struct page * page;
+ *
+ * while (n)
+ * {
+ * page = rb_entry(n, struct page, rb_page_cache);
+ *
+ * if (offset < page->offset)
+ * n = n->rb_left;
+ * else if (offset > page->offset)
+ * n = n->rb_right;
+ * else
+ * return page;
+ * }
+ * return NULL;
+ * }
+ *
+ * static inline struct page * __rb_insert_page_cache(struct inode * inode,
+ * unsigned long offset,
+ * struct rb_node * node)
+ * {
+ * struct rb_node ** p = &inode->i_rb_page_cache.rb_node;
+ * struct rb_node * parent = NULL;
+ * struct page * page;
+ *
+ * while (*p)
+ * {
+ * parent = *p;
+ * page = rb_entry(parent, struct page, rb_page_cache);
+ *
+ * if (offset < page->offset)
+ * p = &(*p)->rb_left;
+ * else if (offset > page->offset)
+ * p = &(*p)->rb_right;
+ * else
+ * return page;
+ * }
+ *
+ * rb_link_node(node, parent, p);
+ *
+ * return NULL;
+ * }
+ *
+ * static inline struct page * rb_insert_page_cache(struct inode * inode,
+ * unsigned long offset,
+ * struct rb_node * node)
+ * {
+ * struct page * ret;
+ * if ((ret = __rb_insert_page_cache(inode, offset, node)))
+ * goto out;
+ * rb_insert_color(node, &inode->i_rb_page_cache);
+ * out:
+ * return ret;
+ * }
+ */
#ifndef _LINUX_RBTREE_H
#define _LINUX_RBTREE_H
#include <stddef.h>
#define container_of(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
+ const typeof(((type *)0)->member) *__mptr = (ptr); \
+ (type *)((char *)__mptr - offsetof(type, member)); \
+})
struct rb_node {
unsigned long rb_parent_color;