Skip to content

Commit 7f1b8e0

Browse files
committed
x86/mce: Remove the tolerance level control
This is pretty much unused and not really useful. What is more, all relevant MCA hardware has recoverable machine checks support so there's no real need to tweak MCA tolerance levels in order to *maybe* extend machine lifetime. So rip it out. Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lore.kernel.org/r/YcDq8PxvKtTENl/e@zn.tnic
1 parent 8ca9781 commit 7f1b8e0

File tree

7 files changed

+68
-89
lines changed

7 files changed

+68
-89
lines changed

Documentation/ABI/removed/sysfs-mce

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
What: /sys/devices/system/machinecheck/machinecheckX/tolerant
2+
Contact: Borislav Petkov <bp@suse.de>
3+
Date: Dec, 2021
4+
Description:
5+
Unused and obsolete after the advent of recoverable machine
6+
checks (see last sentence below) and those are present since
7+
2010 (Nehalem).
8+
9+
Original description:
10+
11+
The entries appear for each CPU, but they are truly shared
12+
between all CPUs.
13+
14+
Tolerance level. When a machine check exception occurs for a
15+
non corrected machine check the kernel can take different
16+
actions.
17+
18+
Since machine check exceptions can happen any time it is
19+
sometimes risky for the kernel to kill a process because it
20+
defies normal kernel locking rules. The tolerance level
21+
configures how hard the kernel tries to recover even at some
22+
risk of deadlock. Higher tolerant values trade potentially
23+
better uptime with the risk of a crash or even corruption
24+
(for tolerant >= 3).
25+
26+
== ===========================================================
27+
0 always panic on uncorrected errors, log corrected errors
28+
1 panic or SIGBUS on uncorrected errors, log corrected errors
29+
2 SIGBUS or log uncorrected errors, log corrected errors
30+
3 never panic or SIGBUS, log all errors (for testing only)
31+
== ===========================================================
32+
33+
Default: 1
34+
35+
Note this only makes a difference if the CPU allows recovery
36+
from a machine check exception. Current x86 CPUs generally
37+
do not.

Documentation/ABI/testing/sysfs-mce

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -53,38 +53,6 @@ Description:
5353
(but some corrected errors might be still reported
5454
in other ways)
5555

56-
What: /sys/devices/system/machinecheck/machinecheckX/tolerant
57-
Contact: Andi Kleen <ak@linux.intel.com>
58-
Date: Feb, 2007
59-
Description:
60-
The entries appear for each CPU, but they are truly shared
61-
between all CPUs.
62-
63-
Tolerance level. When a machine check exception occurs for a
64-
non corrected machine check the kernel can take different
65-
actions.
66-
67-
Since machine check exceptions can happen any time it is
68-
sometimes risky for the kernel to kill a process because it
69-
defies normal kernel locking rules. The tolerance level
70-
configures how hard the kernel tries to recover even at some
71-
risk of deadlock. Higher tolerant values trade potentially
72-
better uptime with the risk of a crash or even corruption
73-
(for tolerant >= 3).
74-
75-
== ===========================================================
76-
0 always panic on uncorrected errors, log corrected errors
77-
1 panic or SIGBUS on uncorrected errors, log corrected errors
78-
2 SIGBUS or log uncorrected errors, log corrected errors
79-
3 never panic or SIGBUS, log all errors (for testing only)
80-
== ===========================================================
81-
82-
Default: 1
83-
84-
Note this only makes a difference if the CPU allows recovery
85-
from a machine check exception. Current x86 CPUs generally
86-
do not.
87-
8856
What: /sys/devices/system/machinecheck/machinecheckX/trigger
8957
Contact: Andi Kleen <ak@linux.intel.com>
9058
Date: Feb, 2007

Documentation/vm/hwpoison.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ There are two (actually three) modes memory failure recovery can be in:
6060

6161
vm.memory_failure_recovery sysctl set to zero:
6262
All memory failures cause a panic. Do not attempt recovery.
63-
(on x86 this can be also affected by the tolerant level of the
64-
MCE subsystem)
6563

6664
early kill
6765
(can be controlled globally and per process)

Documentation/x86/x86_64/boot-options.rst

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,7 @@ Please see Documentation/x86/x86_64/machinecheck.rst for sysfs runtime tunables.
4747
in a reboot. On Intel systems it is enabled by default.
4848
mce=nobootlog
4949
Disable boot machine check logging.
50-
mce=tolerancelevel[,monarchtimeout] (number,number)
51-
tolerance levels:
52-
0: always panic on uncorrected errors, log corrected errors
53-
1: panic or SIGBUS on uncorrected errors, log corrected errors
54-
2: SIGBUS or log uncorrected errors, log corrected errors
55-
3: never panic or SIGBUS, log all errors (for testing only)
56-
Default is 1
57-
Can be also set using sysfs which is preferable.
50+
mce=monarchtimeout (number)
5851
monarchtimeout:
5952
Sets the time in us to wait for other CPUs on machine checks. 0
6053
to disable.

arch/x86/kernel/cpu/mce/core.c

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,6 @@ struct mce_vendor_flags mce_flags __read_mostly;
8686

8787
struct mca_config mca_cfg __read_mostly = {
8888
.bootlog = -1,
89-
/*
90-
* Tolerant levels:
91-
* 0: always panic on uncorrected errors, log corrected errors
92-
* 1: panic or SIGBUS on uncorrected errors, log corrected errors
93-
* 2: SIGBUS or log uncorrected errors (if possible), log corr. errors
94-
* 3: never panic or SIGBUS, log all errors (for testing only)
95-
*/
96-
.tolerant = 1,
9789
.monarch_timeout = -1
9890
};
9991

@@ -753,7 +745,7 @@ bool machine_check_poll(enum mcp_flags flags, mce_banks_t *b)
753745
goto clear_it;
754746

755747
mce_read_aux(&m, i);
756-
m.severity = mce_severity(&m, NULL, mca_cfg.tolerant, NULL, false);
748+
m.severity = mce_severity(&m, NULL, NULL, false);
757749
/*
758750
* Don't get the IP here because it's unlikely to
759751
* have anything to do with the actual error location.
@@ -887,7 +879,7 @@ static __always_inline int mce_no_way_out(struct mce *m, char **msg, unsigned lo
887879
quirk_sandybridge_ifu(i, m, regs);
888880

889881
m->bank = i;
890-
if (mce_severity(m, regs, mca_cfg.tolerant, &tmp, true) >= MCE_PANIC_SEVERITY) {
882+
if (mce_severity(m, regs, &tmp, true) >= MCE_PANIC_SEVERITY) {
891883
mce_read_aux(m, i);
892884
*msg = tmp;
893885
return 1;
@@ -935,12 +927,11 @@ static noinstr int mce_timed_out(u64 *t, const char *msg)
935927
if (!mca_cfg.monarch_timeout)
936928
goto out;
937929
if ((s64)*t < SPINUNIT) {
938-
if (mca_cfg.tolerant <= 1) {
939-
if (cpumask_and(&mce_missing_cpus, cpu_online_mask, &mce_missing_cpus))
940-
pr_emerg("CPUs not responding to MCE broadcast (may include false positives): %*pbl\n",
941-
cpumask_pr_args(&mce_missing_cpus));
942-
mce_panic(msg, NULL, NULL);
943-
}
930+
if (cpumask_and(&mce_missing_cpus, cpu_online_mask, &mce_missing_cpus))
931+
pr_emerg("CPUs not responding to MCE broadcast (may include false positives): %*pbl\n",
932+
cpumask_pr_args(&mce_missing_cpus));
933+
mce_panic(msg, NULL, NULL);
934+
944935
ret = 1;
945936
goto out;
946937
}
@@ -1004,9 +995,9 @@ static void mce_reign(void)
1004995
* This dumps all the mces in the log buffer and stops the
1005996
* other CPUs.
1006997
*/
1007-
if (m && global_worst >= MCE_PANIC_SEVERITY && mca_cfg.tolerant < 3) {
998+
if (m && global_worst >= MCE_PANIC_SEVERITY) {
1008999
/* call mce_severity() to get "msg" for panic */
1009-
mce_severity(m, NULL, mca_cfg.tolerant, &msg, true);
1000+
mce_severity(m, NULL, &msg, true);
10101001
mce_panic("Fatal machine check", m, msg);
10111002
}
10121003

@@ -1020,7 +1011,7 @@ static void mce_reign(void)
10201011
* No machine check event found. Must be some external
10211012
* source or one CPU is hung. Panic.
10221013
*/
1023-
if (global_worst <= MCE_KEEP_SEVERITY && mca_cfg.tolerant < 3)
1014+
if (global_worst <= MCE_KEEP_SEVERITY)
10241015
mce_panic("Fatal machine check from unknown source", NULL, NULL);
10251016

10261017
/*
@@ -1267,7 +1258,7 @@ __mc_scan_banks(struct mce *m, struct pt_regs *regs, struct mce *final,
12671258
/* Set taint even when machine check was not enabled. */
12681259
taint++;
12691260

1270-
severity = mce_severity(m, regs, cfg->tolerant, NULL, true);
1261+
severity = mce_severity(m, regs, NULL, true);
12711262

12721263
/*
12731264
* When machine check was for corrected/deferred handler don't
@@ -1425,7 +1416,6 @@ noinstr void do_machine_check(struct pt_regs *regs)
14251416
int worst = 0, order, no_way_out, kill_current_task, lmce, taint = 0;
14261417
DECLARE_BITMAP(valid_banks, MAX_NR_BANKS) = { 0 };
14271418
DECLARE_BITMAP(toclear, MAX_NR_BANKS) = { 0 };
1428-
struct mca_config *cfg = &mca_cfg;
14291419
struct mce m, *final;
14301420
char *msg = NULL;
14311421

@@ -1447,7 +1437,7 @@ noinstr void do_machine_check(struct pt_regs *regs)
14471437

14481438
/*
14491439
* If no_way_out gets set, there is no safe way to recover from this
1450-
* MCE. If mca_cfg.tolerant is cranked up, we'll try anyway.
1440+
* MCE.
14511441
*/
14521442
no_way_out = 0;
14531443

@@ -1481,7 +1471,7 @@ noinstr void do_machine_check(struct pt_regs *regs)
14811471
* severity is MCE_AR_SEVERITY we have other options.
14821472
*/
14831473
if (!(m.mcgstatus & MCG_STATUS_RIPV))
1484-
kill_current_task = (cfg->tolerant == 3) ? 0 : 1;
1474+
kill_current_task = 1;
14851475
/*
14861476
* Check if this MCE is signaled to only this logical processor,
14871477
* on Intel, Zhaoxin only.
@@ -1498,7 +1488,7 @@ noinstr void do_machine_check(struct pt_regs *regs)
14981488
* to see it will clear it.
14991489
*/
15001490
if (lmce) {
1501-
if (no_way_out && cfg->tolerant < 3)
1491+
if (no_way_out)
15021492
mce_panic("Fatal local machine check", &m, msg);
15031493
} else {
15041494
order = mce_start(&no_way_out);
@@ -1518,7 +1508,7 @@ noinstr void do_machine_check(struct pt_regs *regs)
15181508
if (!no_way_out)
15191509
no_way_out = worst >= MCE_PANIC_SEVERITY;
15201510

1521-
if (no_way_out && cfg->tolerant < 3)
1511+
if (no_way_out)
15221512
mce_panic("Fatal machine check on current CPU", &m, msg);
15231513
}
15241514
} else {
@@ -1530,8 +1520,8 @@ noinstr void do_machine_check(struct pt_regs *regs)
15301520
* fatal error. We call "mce_severity()" again to
15311521
* make sure we have the right "msg".
15321522
*/
1533-
if (worst >= MCE_PANIC_SEVERITY && mca_cfg.tolerant < 3) {
1534-
mce_severity(&m, regs, cfg->tolerant, &msg, true);
1523+
if (worst >= MCE_PANIC_SEVERITY) {
1524+
mce_severity(&m, regs, &msg, true);
15351525
mce_panic("Local fatal machine check!", &m, msg);
15361526
}
15371527
}
@@ -2267,10 +2257,9 @@ static int __init mcheck_enable(char *str)
22672257
cfg->bios_cmci_threshold = 1;
22682258
else if (!strcmp(str, "recovery"))
22692259
cfg->recovery = 1;
2270-
else if (isdigit(str[0])) {
2271-
if (get_option(&str, &cfg->tolerant) == 2)
2272-
get_option(&str, &(cfg->monarch_timeout));
2273-
} else {
2260+
else if (isdigit(str[0]))
2261+
get_option(&str, &(cfg->monarch_timeout));
2262+
else {
22742263
pr_info("mce argument %s ignored. Please use /sys\n", str);
22752264
return 0;
22762265
}
@@ -2520,7 +2509,6 @@ static ssize_t store_int_with_restart(struct device *s,
25202509
return ret;
25212510
}
25222511

2523-
static DEVICE_INT_ATTR(tolerant, 0644, mca_cfg.tolerant);
25242512
static DEVICE_INT_ATTR(monarch_timeout, 0644, mca_cfg.monarch_timeout);
25252513
static DEVICE_BOOL_ATTR(dont_log_ce, 0644, mca_cfg.dont_log_ce);
25262514
static DEVICE_BOOL_ATTR(print_all, 0644, mca_cfg.print_all);
@@ -2541,7 +2529,6 @@ static struct dev_ext_attribute dev_attr_cmci_disabled = {
25412529
};
25422530

25432531
static struct device_attribute *mce_device_attrs[] = {
2544-
&dev_attr_tolerant.attr,
25452532
&dev_attr_check_interval.attr,
25462533
#ifdef CONFIG_X86_MCELOG_LEGACY
25472534
&dev_attr_trigger,

arch/x86/kernel/cpu/mce/internal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int mce_gen_pool_add(struct mce *mce);
3535
int mce_gen_pool_init(void);
3636
struct llist_node *mce_gen_pool_prepare_records(void);
3737

38-
int mce_severity(struct mce *a, struct pt_regs *regs, int tolerant, char **msg, bool is_excp);
38+
int mce_severity(struct mce *a, struct pt_regs *regs, char **msg, bool is_excp);
3939
struct dentry *mce_get_debugfs_dir(void);
4040

4141
extern mce_banks_t mce_banks_ce_disabled;
@@ -127,7 +127,6 @@ struct mca_config {
127127
bool ignore_ce;
128128
bool print_all;
129129

130-
int tolerant;
131130
int monarch_timeout;
132131
int panic_timeout;
133132
u32 rip_msr;

arch/x86/kernel/cpu/mce/severity.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,7 @@ static __always_inline int mce_severity_amd_smca(struct mce *m, enum context err
330330
* See AMD Error Scope Hierarchy table in a newer BKDG. For example
331331
* 49125_15h_Models_30h-3Fh_BKDG.pdf, section "RAS Features"
332332
*/
333-
static noinstr int mce_severity_amd(struct mce *m, struct pt_regs *regs, int tolerant,
334-
char **msg, bool is_excp)
333+
static noinstr int mce_severity_amd(struct mce *m, struct pt_regs *regs, char **msg, bool is_excp)
335334
{
336335
enum context ctx = error_context(m, regs);
337336

@@ -383,8 +382,7 @@ static noinstr int mce_severity_amd(struct mce *m, struct pt_regs *regs, int tol
383382
return MCE_KEEP_SEVERITY;
384383
}
385384

386-
static noinstr int mce_severity_intel(struct mce *m, struct pt_regs *regs,
387-
int tolerant, char **msg, bool is_excp)
385+
static noinstr int mce_severity_intel(struct mce *m, struct pt_regs *regs, char **msg, bool is_excp)
388386
{
389387
enum exception excp = (is_excp ? EXCP_CONTEXT : NO_EXCP);
390388
enum context ctx = error_context(m, regs);
@@ -412,22 +410,21 @@ static noinstr int mce_severity_intel(struct mce *m, struct pt_regs *regs,
412410
if (msg)
413411
*msg = s->msg;
414412
s->covered = 1;
415-
if (s->sev >= MCE_UC_SEVERITY && ctx == IN_KERNEL) {
416-
if (tolerant < 1)
417-
return MCE_PANIC_SEVERITY;
418-
}
413+
414+
if (s->sev >= MCE_UC_SEVERITY && ctx == IN_KERNEL)
415+
return MCE_PANIC_SEVERITY;
416+
419417
return s->sev;
420418
}
421419
}
422420

423-
int noinstr mce_severity(struct mce *m, struct pt_regs *regs, int tolerant, char **msg,
424-
bool is_excp)
421+
int noinstr mce_severity(struct mce *m, struct pt_regs *regs, char **msg, bool is_excp)
425422
{
426423
if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
427424
boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
428-
return mce_severity_amd(m, regs, tolerant, msg, is_excp);
425+
return mce_severity_amd(m, regs, msg, is_excp);
429426
else
430-
return mce_severity_intel(m, regs, tolerant, msg, is_excp);
427+
return mce_severity_intel(m, regs, msg, is_excp);
431428
}
432429

433430
#ifdef CONFIG_DEBUG_FS

0 commit comments

Comments
 (0)