Skip to contentSkip to conversation

Make mce_timed_out() identify holdout CPUs

RFC PATCH Applied Paul E. McKenney 4 participants 15 messages Jan 6, 2021 – Jan 8, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Make mce_timed_out() identify holdout CPUs

The "Timeout: Not all CPUs entered broadcast exception handler" message will appear from time to time given enough systems, but this message does not identify which CPUs failed to enter the broadcast exception handler. This information would be valuable if available, for example, in order to correlated with other hardware-oriented error messages. This commit therefore maintains a cpumask_t of CPUs that have entered this handler, and prints out which ones failed to enter in the event of a timeout.

Build-tested only.

Cc Tony Luck <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
arch/x86/kernel/cpu/mce/core.c +14 -1
index 13d3f1c..44d2b99 100644
@@ -878,6 +878,12 @@ static atomic_t mce_executing;
 static atomic_t mce_callin;
 
 /*
+ * Track which CPUs entered and not in order to print holdouts.
+ */
+static cpumask_t mce_present_cpus;
+static cpumask_t mce_missing_cpus;
+
+/*
  * Check if a timeout waiting for other CPUs happened.
  */
 static int mce_timed_out(u64 *t, const char *msg)
@@ -894,8 +900,12 @@ static int mce_timed_out(u64 *t, const char *msg)
 	if (!mca_cfg.monarch_timeout)
 		goto out;
 	if ((s64)*t < SPINUNIT) {
-		if (mca_cfg.tolerant <= 1)
+		if (mca_cfg.tolerant <= 1) {
+			if (!cpumask_andnot(&mce_missing_cpus, cpu_online_mask, &mce_present_cpus))
+				pr_info("%s: MCE holdout CPUs: %*pbl\n",
+					__func__, cpumask_pr_args(&mce_missing_cpus));
 			mce_panic(msg, NULL, NULL);
+		}
 		cpu_missing = 1;
 		return 1;
 	}
@@ -1006,6 +1016,7 @@ static int mce_start(int *no_way_out)
 	 * is updated before mce_callin.
 	 */
 	order = atomic_inc_return(&mce_callin);
+	cpumask_set_cpu(smp_processor_id(), &mce_present_cpus);
 
 	/*
 	 * Wait for everyone.
@@ -1114,6 +1125,7 @@ static int mce_end(int order)
 reset:
 	atomic_set(&global_nwo, 0);
 	atomic_set(&mce_callin, 0);
+	cpumask_clear(&mce_present_cpus);
 	barrier();
 
 	/*
@@ -2712,6 +2724,7 @@ static void mce_reset(void)
 	atomic_set(&mce_executing, 0);
 	atomic_set(&mce_callin, 0);
 	atomic_set(&global_nwo, 0);
+	cpumask_clear(&mce_present_cpus);
 }
 
 static int fake_panic_get(void *data, u64 *val)
maintainer
#1 lore raw
Quoted 5 lines · Paul E. McKenney

The "Timeout: Not all CPUs entered broadcast exception handler" message will appear from time to time given enough systems, but this message does not identify which CPUs failed to enter the broadcast exception handler. This information would be valuable if available, for example, in order to correlated with other hardware-oriented error messages.

Because you're expecting that the CPUs which have not entered the exception handler might have stuck earlier and that's the correlation there?

Quoted 1 line

This commit

That's a tautology. :)

Quoted 46 lines

therefore maintains a cpumask_t of CPUs that have entered this handler, and prints out which ones failed to enter in the event of a timeout. Build-tested only.

Cc Tony Luck <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
arch/x86/kernel/cpu/mce/core.c +11 -1
index 13d3f1c..44d2b99 100644
@@ -878,6 +878,12 @@ static atomic_t mce_executing;
 static atomic_t mce_callin;
 
 /*
+ * Track which CPUs entered and not in order to print holdouts.
+ */
+static cpumask_t mce_present_cpus;
+static cpumask_t mce_missing_cpus;
+
+/*
  * Check if a timeout waiting for other CPUs happened.
  */
 static int mce_timed_out(u64 *t, const char *msg)
@@ -894,8 +900,12 @@ static int mce_timed_out(u64 *t, const char *msg)
 	if (!mca_cfg.monarch_timeout)
 		goto out;
 	if ((s64)*t < SPINUNIT) {
-		if (mca_cfg.tolerant <= 1)
+		if (mca_cfg.tolerant <= 1) {
+			if (!cpumask_andnot(&mce_missing_cpus, cpu_online_mask, &mce_present_cpus))
+				pr_info("%s: MCE holdout CPUs: %*pbl\n",
+					__func__, cpumask_pr_args(&mce_missing_cpus));
 			mce_panic(msg, NULL, NULL);
+		}
 		cpu_missing = 1;
 		return 1;
 	}

arch/x86/kernel/cpu/mce/core.c static int mce_start(int *no_way_out) · line 1018

Quoted 3 lines
arch/x86/kernel/cpu/mce/core.c +0 -0
@@ -1006,6 +1016,7 @@ static int mce_start(int *no_way_out)
 	 * is updated before mce_callin.
 	 */
 	order = atomic_inc_return(&mce_callin);

Doesn't a single mce_callin_mask suffice?

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#2 lore raw
Quoted 10 lines · Borislav Petkov
Quoted 5 lines · Paul E. McKenney

The "Timeout: Not all CPUs entered broadcast exception handler" message will appear from time to time given enough systems, but this message does not identify which CPUs failed to enter the broadcast exception handler. This information would be valuable if available, for example, in order to correlated with other hardware-oriented error messages.

Because you're expecting that the CPUs which have not entered the exception handler might have stuck earlier and that's the correlation there?

Or that there might have been any number of other error messages that flagged that CPU. For a few examples, watchdogs, hung tasks, and RCU CPU stall warnings.

Quoted 3 lines
Quoted 1 line

This commit

That's a tautology. :)

Not yet, it isn't! Well, except in -rcu. ;-)

Quoted 43 lines
Quoted 43 lines

therefore maintains a cpumask_t of CPUs that have entered this handler, and prints out which ones failed to enter in the event of a timeout. Build-tested only.

Cc Tony Luck <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
arch/x86/kernel/cpu/mce/core.c +11 -1
index 13d3f1c..44d2b99 100644
@@ -878,6 +878,12 @@ static atomic_t mce_executing;
 static atomic_t mce_callin;
 
 /*
+ * Track which CPUs entered and not in order to print holdouts.
+ */
+static cpumask_t mce_present_cpus;
+static cpumask_t mce_missing_cpus;
+
+/*
  * Check if a timeout waiting for other CPUs happened.
  */
 static int mce_timed_out(u64 *t, const char *msg)
@@ -894,8 +900,12 @@ static int mce_timed_out(u64 *t, const char *msg)
 	if (!mca_cfg.monarch_timeout)
 		goto out;
 	if ((s64)*t < SPINUNIT) {
-		if (mca_cfg.tolerant <= 1)
+		if (mca_cfg.tolerant <= 1) {
+			if (!cpumask_andnot(&mce_missing_cpus, cpu_online_mask, &mce_present_cpus))
+				pr_info("%s: MCE holdout CPUs: %*pbl\n",
+					__func__, cpumask_pr_args(&mce_missing_cpus));
 			mce_panic(msg, NULL, NULL);
+		}
 		cpu_missing = 1;
Quoted 8 lines

arch/x86/kernel/cpu/mce/core.c static int mce_start(int *no_way_out) · line 1018

Quoted 6 lines
arch/x86/kernel/cpu/mce/core.c +0 -0
 		return 1;
 	}
@@ -1006,6 +1016,7 @@ static int mce_start(int *no_way_out)
 	 * is updated before mce_callin.
 	 */
 	order = atomic_inc_return(&mce_callin);

Doesn't a single mce_callin_mask suffice?

You are suggesting dropping mce_missing_cpus and just doing this?

if (!cpumask_andnot(&mce_present_cpus, cpu_online_mask, &mce_present_cpus))

I was worried (perhaps unnecessarily) about the possibility of CPUs checking in during the printout operation, which would set rather than clear the bit. But perhaps the possible false positives that Tony points out make this race not worth worrying about.

Thoughts?

Thanx, Paul

maintainer
#3 lore raw
Quoted 1 line · Paul E. McKenney

Not yet, it isn't! Well, except in -rcu. ;-)

Of course it is - saying "This commit" in this commit's commit message is very much a tautology. :-)

Quoted 3 lines

You are suggesting dropping mce_missing_cpus and just doing this?

if (!cpumask_andnot(&mce_present_cpus, cpu_online_mask, &mce_present_cpus))

Yes.

And pls don't call it "holdout CPUs" and change the order so that it is more user-friendly (yap, you don't need __func__ either):

[   78.946153] mce: Not all CPUs (24-47,120-143) entered the broadcast exception handler.
[   78.946153] Kernel panic - not syncing: Timeout: MCA synchronization.

or so.

And that's fine if it appears twice as long as it is the same info - the MCA code is one complex mess so you can probably guess why I'd like to have new stuff added to it be as simplistic as possible.

Quoted 6 lines

I was worried (perhaps unnecessarily) about the possibility of CPUs checking in during the printout operation, which would set rather than clear the bit. But perhaps the possible false positives that Tony points out make this race not worth worrying about.

Thoughts?

Yah, apparently, it is not going to be a precise report as you wanted it to be but at least it'll tell you which *sockets* you can rule out, if not cores.

:-)

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
author Tested-by Tony Luck
#4 lore raw
Quoted 5 lines · Borislav Petkov
Quoted 1 line · Paul E. McKenney

Not yet, it isn't! Well, except in -rcu. ;-)

Of course it is - saying "This commit" in this commit's commit message is very much a tautology. :-)

Tautology? Maybe self-referential? ;-)

Quoted 5 lines
Quoted 3 lines

You are suggesting dropping mce_missing_cpus and just doing this?

if (!cpumask_andnot(&mce_present_cpus, cpu_online_mask, &mce_present_cpus))

Yes.

I could drop mce_present_cpus, and then initialize mce_missing_cpus to CPU_MASK_ALL, and have each CPU clear its bit on entry using cpumask_clear_cpu(). Then cpumask_and() it with cpu_online_mask and print it out. That allows late-arriving CPUs to be properly accounted for, most of the time, anyway.

Quoted 1 line

And pls don't call it "holdout CPUs"

How about "missing CPUs"? That is what I used in the meantime, please see below. If you have something you would prefer that it be called, please let me know.

Quoted 7 lines

and change the order so that it is
more user-friendly (yap, you don't need __func__ either):

[   78.946153] mce: Not all CPUs (24-47,120-143) entered the broadcast exception handler.
[   78.946153] Kernel panic - not syncing: Timeout: MCA synchronization.

or so.

I removed __func__, but the pr_info() already precedes the mce_panic(). Do I need a udelay() after the pr_info() or some such? If so, how long should is spin?

Quoted 3 lines

And that's fine if it appears twice as long as it is the same info - the MCA code is one complex mess so you can probably guess why I'd like to have new stuff added to it be as simplistic as possible.

Works for me. ;-)

Quoted 5 lines
Quoted 5 lines

I was worried (perhaps unnecessarily) about the possibility of CPUs checking in during the printout operation, which would set rather than clear the bit. But perhaps the possible false positives that Tony points out make this race not worth worrying about.

Quoted 7 lines
Quoted 1 line

Thoughts?

Yah, apparently, it is not going to be a precise report as you wanted it to be but at least it'll tell you which *sockets* you can rule out, if not cores.

:-)

Some information is usually better than none. And I bet that failing hardware is capable of all sorts of tricks at all sorts of levels. ;-)

Updated patch below. Is this what you had in mind?

Thanx, Paul

------------------------------------------------------------------------

commit 4b4b57692fdd3b111098eda94df7529f85c54406

Author: Paul E. McKenney <[email protected]>
Date:   Wed Dec 23 17:04:19 2020 -0800

x86/mce: Make mce_timed_out() identify holdout CPUs

The "Timeout: Not all CPUs entered broadcast exception handler" message will appear from time to time given enough systems, but this message does not identify which CPUs failed to enter the broadcast exception handler. This information would be valuable if available, for example, in order to correlated with other hardware-oriented error messages. This commit therefore maintains a cpumask_t of CPUs that have entered this handler, and prints out which ones failed to enter in the event of a timeout.

Cc Tony Luck <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
[ paulmck: Fix cpumask_andnot() check per Tony Luck testing and feedback. ]
[ paulmck: Apply Borislav Petkov feedback. ]
arch/x86/kernel/cpu/mce/core.c +13 -1
index 13d3f1c..c83331b 100644
@@ -878,6 +878,11 @@ static atomic_t mce_executing;
 static atomic_t mce_callin;
 
 /*
+ * Track which CPUs entered and not in order to print holdouts.
+ */
+static cpumask_t mce_missing_cpus = CPU_MASK_ALL;
+
+/*
  * Check if a timeout waiting for other CPUs happened.
  */
 static int mce_timed_out(u64 *t, const char *msg)
@@ -894,8 +899,12 @@ static int mce_timed_out(u64 *t, const char *msg)
 	if (!mca_cfg.monarch_timeout)
 		goto out;
 	if ((s64)*t < SPINUNIT) {
-		if (mca_cfg.tolerant <= 1)
+		if (mca_cfg.tolerant <= 1) {
+			if (cpumask_and(&mce_missing_cpus, cpu_online_mask, &mce_missing_cpus))
+				pr_info("MCE missing CPUs (may include false positives): %*pbl\n",
+					cpumask_pr_args(&mce_missing_cpus));
 			mce_panic(msg, NULL, NULL);
+		}
 		cpu_missing = 1;
 		return 1;
 	}
@@ -1006,6 +1015,7 @@ static int mce_start(int *no_way_out)
 	 * is updated before mce_callin.
 	 */
 	order = atomic_inc_return(&mce_callin);
+	cpumask_clear_cpu(smp_processor_id(), &mce_missing_cpus);
 
 	/*
 	 * Wait for everyone.
@@ -1114,6 +1124,7 @@ static int mce_end(int order)
 reset:
 	atomic_set(&global_nwo, 0);
 	atomic_set(&mce_callin, 0);
+	cpumask_setall(&mce_missing_cpus);
 	barrier();
 
 	/*
@@ -2712,6 +2723,7 @@ static void mce_reset(void)
 	atomic_set(&mce_executing, 0);
 	atomic_set(&mce_callin, 0);
 	atomic_set(&global_nwo, 0);
+	cpumask_setall(&mce_missing_cpus);
 }
 
 static int fake_panic_get(void *data, u64 *val)
maintainer Tested-by Tony Luck
#5 lore raw
Quoted 2 lines · Paul E. McKenney

Some information is usually better than none. And I bet that failing hardware is capable of all sorts of tricks at all sorts of levels. ;-)

Tell me about it.

Quoted 1 line

Updated patch below. Is this what you had in mind?

Ok, so I've massaged it into the below locally while taking another detailed look. Made the pr_info pr_emerg and poked at the text more, as I do. :)

Lemme know if something else needs to be adjusted, otherwise I'll queue it.

Thx.

---

Author: Paul E. McKenney <[email protected]>
Date:   Wed Dec 23 17:04:19 2020 -0800

x86/mce: Make mce_timed_out() identify holdout CPUs

The

"Timeout: Not all CPUs entered broadcast exception handler"

message will appear from time to time given enough systems, but this message does not identify which CPUs failed to enter the broadcast exception handler. This information would be valuable if available, for example, in order to correlate with other hardware-oriented error messages.

Add a cpumask of CPUs which maintains which CPUs have entered this handler, and print out which ones failed to enter in the event of a timeout.

[ bp: Massage. ]

arch/x86/kernel/cpu/mce/core.c +14 -1
index 13d3f1cbda17..6c81d0998e0a 100644
@@ -877,6 +877,12 @@ static atomic_t mce_executing;
  */
 static atomic_t mce_callin;
 
+/*
+ * Track which CPUs entered the MCA broadcast synchronization and which not in
+ * order to print holdouts.
+ */
+static cpumask_t mce_missing_cpus = CPU_MASK_ALL;
+
 /*
  * Check if a timeout waiting for other CPUs happened.
  */
@@ -894,8 +900,12 @@ static int mce_timed_out(u64 *t, const char *msg)
 	if (!mca_cfg.monarch_timeout)
 		goto out;
 	if ((s64)*t < SPINUNIT) {
-		if (mca_cfg.tolerant <= 1)
+		if (mca_cfg.tolerant <= 1) {
+			if (cpumask_and(&mce_missing_cpus, cpu_online_mask, &mce_missing_cpus))
+				pr_emerg("CPUs not responding to MCE broadcast (may include false positives): %*pbl\n",
+					 cpumask_pr_args(&mce_missing_cpus));
 			mce_panic(msg, NULL, NULL);
+		}
 		cpu_missing = 1;
 		return 1;
 	}
@@ -1006,6 +1016,7 @@ static int mce_start(int *no_way_out)
 	 * is updated before mce_callin.
 	 */
 	order = atomic_inc_return(&mce_callin);
+	cpumask_clear_cpu(smp_processor_id(), &mce_missing_cpus);
 
 	/*
 	 * Wait for everyone.
@@ -1114,6 +1125,7 @@ static int mce_end(int order)
 reset:
 	atomic_set(&global_nwo, 0);
 	atomic_set(&mce_callin, 0);
+	cpumask_setall(&mce_missing_cpus);
 	barrier();
 
 	/*
@@ -2712,6 +2724,7 @@ static void mce_reset(void)
 	atomic_set(&mce_executing, 0);
 	atomic_set(&mce_callin, 0);
 	atomic_set(&global_nwo, 0);
+	cpumask_setall(&mce_missing_cpus);
 }
 
 static int fake_panic_get(void *data, u64 *val)
Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#6 lore raw
Quoted 6 lines · Borislav Petkov
Quoted 2 lines · Paul E. McKenney

Some information is usually better than none. And I bet that failing hardware is capable of all sorts of tricks at all sorts of levels. ;-)

Tell me about it.

Quoted 8 lines
Quoted 1 line

Updated patch below. Is this what you had in mind?

Ok, so I've massaged it into the below locally while taking another detailed look. Made the pr_info pr_emerg and poked at the text more, as I do. :)

Lemme know if something else needs to be adjusted, otherwise I'll queue it.

Looks good to me! I agree that your change to the pr_emerg() string is much better than my original. And good point on your added comment, plus it was fun to see that my original "holdouts" wording has not completely vanished. ;-)

Thank you very much!!!

Thanx, Paul

Quoted 91 lines

Thx.

---

Author: Paul E. McKenney <[email protected]>
Date:   Wed Dec 23 17:04:19 2020 -0800

x86/mce: Make mce_timed_out() identify holdout CPUs

The

"Timeout: Not all CPUs entered broadcast exception handler"

message will appear from time to time given enough systems, but this message does not identify which CPUs failed to enter the broadcast exception handler. This information would be valuable if available, for example, in order to correlate with other hardware-oriented error messages.

Add a cpumask of CPUs which maintains which CPUs have entered this handler, and print out which ones failed to enter in the event of a timeout.

[ bp: Massage. ]

arch/x86/kernel/cpu/mce/core.c +14 -1
index 13d3f1cbda17..6c81d0998e0a 100644
@@ -877,6 +877,12 @@ static atomic_t mce_executing;
  */
 static atomic_t mce_callin;
 
+/*
+ * Track which CPUs entered the MCA broadcast synchronization and which not in
+ * order to print holdouts.
+ */
+static cpumask_t mce_missing_cpus = CPU_MASK_ALL;
+
 /*
  * Check if a timeout waiting for other CPUs happened.
  */
@@ -894,8 +900,12 @@ static int mce_timed_out(u64 *t, const char *msg)
 	if (!mca_cfg.monarch_timeout)
 		goto out;
 	if ((s64)*t < SPINUNIT) {
-		if (mca_cfg.tolerant <= 1)
+		if (mca_cfg.tolerant <= 1) {
+			if (cpumask_and(&mce_missing_cpus, cpu_online_mask, &mce_missing_cpus))
+				pr_emerg("CPUs not responding to MCE broadcast (may include false positives): %*pbl\n",
+					 cpumask_pr_args(&mce_missing_cpus));
 			mce_panic(msg, NULL, NULL);
+		}
 		cpu_missing = 1;
 		return 1;
 	}
@@ -1006,6 +1016,7 @@ static int mce_start(int *no_way_out)
 	 * is updated before mce_callin.
 	 */
 	order = atomic_inc_return(&mce_callin);
+	cpumask_clear_cpu(smp_processor_id(), &mce_missing_cpus);
 
 	/*
 	 * Wait for everyone.
@@ -1114,6 +1125,7 @@ static int mce_end(int order)
 reset:
 	atomic_set(&global_nwo, 0);
 	atomic_set(&mce_callin, 0);
+	cpumask_setall(&mce_missing_cpus);
 	barrier();
 
 	/*
@@ -2712,6 +2724,7 @@ static void mce_reset(void)
 	atomic_set(&mce_executing, 0);
 	atomic_set(&mce_callin, 0);
 	atomic_set(&global_nwo, 0);
+	cpumask_setall(&mce_missing_cpus);
 }
 
 static int fake_panic_get(void *data, u64 *val)
Signature · 5 lines
-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#7 lore raw
Quoted 2 lines · Paul E. McKenney

Looks good to me! I agree that your change to the pr_emerg() string is much better than my original.

Well, the rest of the MCE code uses pr_emerg on that path so...

Quoted 2 lines

And good point on your added comment, plus it was fun to see that my original "holdouts" wording has not completely vanished. ;-)

I had to leave it in seeing how you love that formulation. :-P

Quoted 1 line

Thank you very much!!!

Thanks too Paul!

/me queues.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#8 lore raw
In reply to Paul E. McKenney
Quoted 7 lines

The "Timeout: Not all CPUs entered broadcast exception handler" message will appear from time to time given enough systems, but this message does not identify which CPUs failed to enter the broadcast exception handler. This information would be valuable if available, for example, in order to correlated with other hardware-oriented error messages. This commit therefore maintains a cpumask_t of CPUs that have entered this handler, and prints out which ones failed to enter in the event of a timeout.

I tried doing this a while back, but found that in my test case where I forced an error that would cause both threads from one core to be "missing", the output was highly unpredictable. Some random number of extra CPUs were reported as missing. After I added some extra breadcrumbs it became clear that pretty much all the CPUs (except the missing pair) entered do_machine_check(), but some got hung up at various points beyond the entry point. My only theory was that they were trying to snoop caches from the dead core (or access some other resource held by the dead core) and so they hung too.

Your code is much neater than mine ... and perhaps works in other cases, but maybe the message needs to allow for the fact that some of the cores that are reported missing may just be collateral damage from the initial problem.

If I get time in the next day or two, I'll run my old test against your code to see what happens.

-Tony

#9 lore raw
Quoted 17 lines · Tony
Quoted 7 lines

The "Timeout: Not all CPUs entered broadcast exception handler" message will appear from time to time given enough systems, but this message does not identify which CPUs failed to enter the broadcast exception handler. This information would be valuable if available, for example, in order to correlated with other hardware-oriented error messages. This commit therefore maintains a cpumask_t of CPUs that have entered this handler, and prints out which ones failed to enter in the event of a timeout.

I tried doing this a while back, but found that in my test case where I forced an error that would cause both threads from one core to be "missing", the output was highly unpredictable. Some random number of extra CPUs were reported as missing. After I added some extra breadcrumbs it became clear that pretty much all the CPUs (except the missing pair) entered do_machine_check(), but some got hung up at various points beyond the entry point. My only theory was that they were trying to snoop caches from the dead core (or access some other resource held by the dead core) and so they hung too.

Quoted 3 lines

Your code is much neater than mine ... and perhaps works in other cases, but maybe the message needs to allow for the fact that some of the cores that are reported missing may just be collateral damage from the initial problem.

Understood. The system is probably not in the best shape if this code is ever executed, after all. ;-)

So how about like this?

pr_info("%s: MCE holdout CPUs (may include false positives): %*pbl\n",

Easy enough if so!

Quoted 2 lines

If I get time in the next day or two, I'll run my old test against your code to see what happens.

Thank you very much in advance!

For my own testing, is this still the right thing to use?

https://github.com/andikleen/mce-inject

Thanx, Paul

maintainer
#10 lore raw
Quoted 22 lines · Paul E. McKenney
Quoted 17 lines · Tony
Quoted 7 lines

The "Timeout: Not all CPUs entered broadcast exception handler" message will appear from time to time given enough systems, but this message does not identify which CPUs failed to enter the broadcast exception handler. This information would be valuable if available, for example, in order to correlated with other hardware-oriented error messages. This commit therefore maintains a cpumask_t of CPUs that have entered this handler, and prints out which ones failed to enter in the event of a timeout.

I tried doing this a while back, but found that in my test case where I forced an error that would cause both threads from one core to be "missing", the output was highly unpredictable. Some random number of extra CPUs were reported as missing. After I added some extra breadcrumbs it became clear that pretty much all the CPUs (except the missing pair) entered do_machine_check(), but some got hung up at various points beyond the entry point. My only theory was that they were trying to snoop caches from the dead core (or access some other resource held by the dead core) and so they hung too.

Quoted 3 lines

Your code is much neater than mine ... and perhaps works in other cases, but maybe the message needs to allow for the fact that some of the cores that are reported missing may just be collateral damage from the initial problem.

Quoted 6 lines

Understood. The system is probably not in the best shape if this code is ever executed, after all. ;-)

So how about like this?

pr_info("%s: MCE holdout CPUs (may include false positives): %*pbl\n",

That looks fine.

Quoted 5 lines

Easy enough if so!

Quoted 2 lines

If I get time in the next day or two, I'll run my old test against your code to see what happens.

I got time today (plenty of meetings in which to run experiments in background).

This code:

- if (mca_cfg.tolerant <= 1)
+ if (mca_cfg.tolerant <= 1) {
+ if (!cpumask_andnot(&mce_missing_cpus, cpu_online_mask, &mce_present_cpus))
+ pr_info("%s: MCE holdout CPUs: %*pbl\n",

+                                       __func__, cpumask_pr_args(&mce_missing_cpus));
                        mce_panic(msg, NULL, NULL);

didn't trigger ... so maybe that cpumask_andnot() didn't return the value you expected?

I added a:

+ pr_info("%s: MCE present CPUs: %*pbl\n", __func__, cpumask_pr_args(&mce_present_cpus));

to check that the mask was being set correctly, and saw:

[  219.329767] mce: mce_timed_out: MCE present CPUs: 0-23,48-119,144-191

So the every core of socket 1 failed to show up for this test.

Quoted 3 lines

For my own testing, is this still the right thing to use?

https://github.com/andikleen/mce-inject

That fakes up errors (by hooking into the mce_rdmsr() code to return arbitrary user supplied values). The plus side of this is that you can fake any error signature without needing special h/w or f/w. The downside is that it is all fake and you can't create situations where some CPUs don't show up in the machine check handler.

-Tony

#11 lore raw
Quoted 30 lines · Tony
Quoted 22 lines · Paul E. McKenney
Quoted 17 lines · Tony
Quoted 7 lines

The "Timeout: Not all CPUs entered broadcast exception handler" message will appear from time to time given enough systems, but this message does not identify which CPUs failed to enter the broadcast exception handler. This information would be valuable if available, for example, in order to correlated with other hardware-oriented error messages. This commit therefore maintains a cpumask_t of CPUs that have entered this handler, and prints out which ones failed to enter in the event of a timeout.

I tried doing this a while back, but found that in my test case where I forced an error that would cause both threads from one core to be "missing", the output was highly unpredictable. Some random number of extra CPUs were reported as missing. After I added some extra breadcrumbs it became clear that pretty much all the CPUs (except the missing pair) entered do_machine_check(), but some got hung up at various points beyond the entry point. My only theory was that they were trying to snoop caches from the dead core (or access some other resource held by the dead core) and so they hung too.

Quoted 3 lines

Your code is much neater than mine ... and perhaps works in other cases, but maybe the message needs to allow for the fact that some of the cores that are reported missing may just be collateral damage from the initial problem.

Quoted 6 lines

Understood. The system is probably not in the best shape if this code is ever executed, after all. ;-)

So how about like this?

pr_info("%s: MCE holdout CPUs (may include false positives): %*pbl\n",

Quoted 8 lines

That looks fine.

Quoted 5 lines

Easy enough if so!

Quoted 2 lines

If I get time in the next day or two, I'll run my old test against your code to see what happens.

I got time today (plenty of meetings in which to run experiments in background).

Thank you very much!

Quoted 13 lines

This code:

(quoted diff) +4 -1
-               if (mca_cfg.tolerant <= 1)
+               if (mca_cfg.tolerant <= 1) {
+                       if (!cpumask_andnot(&mce_missing_cpus, cpu_online_mask, &mce_present_cpus))
+                               pr_info("%s: MCE holdout CPUs: %*pbl\n",
+                                       __func__, cpumask_pr_args(&mce_missing_cpus));
                        mce_panic(msg, NULL, NULL);

didn't trigger ... so maybe that cpumask_andnot() didn't return the value you expected?

I added a:

Quoted 7 lines

+ pr_info("%s: MCE present CPUs: %*pbl\n", __func__, cpumask_pr_args(&mce_present_cpus));

to check that the mask was being set correctly, and saw:

[  219.329767] mce: mce_timed_out: MCE present CPUs: 0-23,48-119,144-191

So the every core of socket 1 failed to show up for this test.

I'll say that cpumask_andnot() didn't return the value I expected! Mostly because idiot here somehow interpreted "If *@dstp is empty, returns 0, else returns 1" as "Returns true if *dstp is empty". So the check is backwards.

Please see below for an updated patch.

Quoted 9 lines
Quoted 3 lines

For my own testing, is this still the right thing to use?

https://github.com/andikleen/mce-inject

That fakes up errors (by hooking into the mce_rdmsr() code to return arbitrary user supplied values). The plus side of this is that you can fake any error signature without needing special h/w or f/w. The downside is that it is all fake and you can't create situations where some CPUs don't show up in the machine check handler.

So I would need to modify the code to test the code. I have done worse things, I suppose. ;-)

Thanx, Paul

------------------------------------------------------------------------

x86/mce: Make mce_timed_out() identify holdout CPUs

The "Timeout: Not all CPUs entered broadcast exception handler" message will appear from time to time given enough systems, but this message does not identify which CPUs failed to enter the broadcast exception handler. This information would be valuable if available, for example, in order to correlated with other hardware-oriented error messages. This commit therefore maintains a cpumask_t of CPUs that have entered this handler, and prints out which ones failed to enter in the event of a timeout.

Cc Tony Luck <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
[ paulmck: Fix cpumask_andnot() check + message per Tony Luck feedback. ]
arch/x86/kernel/cpu/mce/core.c +14 -1
index 13d3f1c..7a6e1f3 100644
@@ -878,6 +878,12 @@ static atomic_t mce_executing;
 static atomic_t mce_callin;
 
 /*
+ * Track which CPUs entered and not in order to print holdouts.
+ */
+static cpumask_t mce_present_cpus;
+static cpumask_t mce_missing_cpus;
+
+/*
  * Check if a timeout waiting for other CPUs happened.
  */
 static int mce_timed_out(u64 *t, const char *msg)
@@ -894,8 +900,12 @@ static int mce_timed_out(u64 *t, const char *msg)
 	if (!mca_cfg.monarch_timeout)
 		goto out;
 	if ((s64)*t < SPINUNIT) {
-		if (mca_cfg.tolerant <= 1)
+		if (mca_cfg.tolerant <= 1) {
+			if (cpumask_andnot(&mce_missing_cpus, cpu_online_mask, &mce_present_cpus))
+				pr_info("%s: MCE holdout CPUs (may include false positives): %*pbl\n",
+					__func__, cpumask_pr_args(&mce_missing_cpus));
 			mce_panic(msg, NULL, NULL);
+		}
 		cpu_missing = 1;
 		return 1;
 	}
@@ -1006,6 +1016,7 @@ static int mce_start(int *no_way_out)
 	 * is updated before mce_callin.
 	 */
 	order = atomic_inc_return(&mce_callin);
+	cpumask_set_cpu(smp_processor_id(), &mce_present_cpus);
 
 	/*
 	 * Wait for everyone.
@@ -1114,6 +1125,7 @@ static int mce_end(int order)
 reset:
 	atomic_set(&global_nwo, 0);
 	atomic_set(&mce_callin, 0);
+	cpumask_clear(&mce_present_cpus);
 	barrier();
 
 	/*
@@ -2712,6 +2724,7 @@ static void mce_reset(void)
 	atomic_set(&mce_executing, 0);
 	atomic_set(&mce_callin, 0);
 	atomic_set(&global_nwo, 0);
+	cpumask_clear(&mce_present_cpus);
 }
 
 static int fake_panic_get(void *data, u64 *val)
maintainer Tested-by
#12 lore raw
Quoted 1 line

Please see below for an updated patch.

Yes. That worked:

[   78.946069] mce: mce_timed_out: MCE holdout CPUs (may include false positives): 24-47,120-143
[   78.946151] mce: mce_timed_out: MCE holdout CPUs (may include false positives): 24-47,120-143
[   78.946153] Kernel panic - not syncing: Timeout: Not all CPUs entered broadcast exception handler

I guess that more than one CPU hit the timeout and so your new message was printed twice before the panic code took over?

Once again, the whole of socket 1 is MIA rather than just the pair of threads on one of the cores there. But that's a useful improvement (eliminating the other three sockets on this system).

-Tony

#13 lore raw
Quoted 10 lines · Tony
Quoted 1 line

Please see below for an updated patch.

Yes. That worked:

[   78.946069] mce: mce_timed_out: MCE holdout CPUs (may include false positives): 24-47,120-143
[   78.946151] mce: mce_timed_out: MCE holdout CPUs (may include false positives): 24-47,120-143
[   78.946153] Kernel panic - not syncing: Timeout: Not all CPUs entered broadcast exception handler

I guess that more than one CPU hit the timeout and so your new message was printed twice before the panic code took over?

Could well be.

It would be easy to add a flag that allowed only one CPU to print the message. Does that make sense? (See off-the-cuff probably-broken delta patch below for one approach.)

Quoted 4 lines

Once again, the whole of socket 1 is MIA rather than just the pair of threads on one of the cores there. But that's a useful improvement (eliminating the other three sockets on this system).

Thank you very much! I will apply this.

Thanx, Paul

------------------------------------------------------------------------

arch/x86/kernel/cpu/mce/core.c +5 -1
index 7a6e1f3..b46ac56 100644
@@ -882,6 +882,7 @@ static atomic_t mce_callin;
  */
 static cpumask_t mce_present_cpus;
 static cpumask_t mce_missing_cpus;
+static atomic_t mce_missing_cpus_gate;
 
 /*
  * Check if a timeout waiting for other CPUs happened.
@@ -900,7 +901,7 @@ static int mce_timed_out(u64 *t, const char *msg)
 	if (!mca_cfg.monarch_timeout)
 		goto out;
 	if ((s64)*t < SPINUNIT) {
-		if (mca_cfg.tolerant <= 1) {
+		if (mca_cfg.tolerant <= 1 && !atomic_xchg(&mce_missing_cpus_gate, 1)) {
 			if (cpumask_andnot(&mce_missing_cpus, cpu_online_mask, &mce_present_cpus))
 				pr_info("%s: MCE holdout CPUs (may include false positives): %*pbl\n",
 					__func__, cpumask_pr_args(&mce_missing_cpus));
@@ -1017,6 +1018,7 @@ static int mce_start(int *no_way_out)
 	 */
 	order = atomic_inc_return(&mce_callin);
 	cpumask_set_cpu(smp_processor_id(), &mce_present_cpus);
+	atomic_set(&mce_missing_cpus_gate, 0);
 
 	/*
 	 * Wait for everyone.
@@ -1126,6 +1128,7 @@ static int mce_end(int order)
 	atomic_set(&global_nwo, 0);
 	atomic_set(&mce_callin, 0);
 	cpumask_clear(&mce_present_cpus);
+	atomic_set(&mce_missing_cpus_gate, 0);
 	barrier();
 
 	/*
@@ -2725,6 +2728,7 @@ static void mce_reset(void)
 	atomic_set(&mce_callin, 0);
 	atomic_set(&global_nwo, 0);
 	cpumask_clear(&mce_present_cpus);
+	atomic_set(&mce_missing_cpus_gate, 0);
 }
 
 static int fake_panic_get(void *data, u64 *val)
#14 lore raw

[tip: ras/core] x86/mce: Make mce_timed_out() identify holdout CPUs

In reply to Paul E. McKenney
The following commit has been merged into the ras/core branch of tip:

The following commit has been merged into the ras/core branch of tip:

Commit-ID:     7bb39313cd6239e7eb95198950a02b4ad2a08316
Gitweb:        https://git.kernel.org/tip/7bb39313cd6239e7eb95198950a02b4ad2a08316
Author:        Paul E. McKenney <[email protected]>
AuthorDate:    Wed, 23 Dec 2020 17:04:19 -08:00
Committer:     Borislav Petkov <[email protected]>
CommitterDate: Fri, 08 Jan 2021 18:00:09 +01:00

x86/mce: Make mce_timed_out() identify holdout CPUs

The

"Timeout: Not all CPUs entered broadcast exception handler"

message will appear from time to time given enough systems, but this message does not identify which CPUs failed to enter the broadcast exception handler. This information would be valuable if available, for example, in order to correlate with other hardware-oriented error messages.

Add a cpumask of CPUs which maintains which CPUs have entered this handler, and print out which ones failed to enter in the event of a timeout.

[ bp: Massage. ]

---
 arch/x86/kernel/cpu/mce/core.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/mce/core.c +14 -1
index 13d3f1c..6c81d09 100644
@@ -878,6 +878,12 @@ static atomic_t mce_executing;
 static atomic_t mce_callin;
 
 /*
+ * Track which CPUs entered the MCA broadcast synchronization and which not in
+ * order to print holdouts.
+ */
+static cpumask_t mce_missing_cpus = CPU_MASK_ALL;
+
+/*
  * Check if a timeout waiting for other CPUs happened.
  */
 static int mce_timed_out(u64 *t, const char *msg)
@@ -894,8 +900,12 @@ static int mce_timed_out(u64 *t, const char *msg)
 	if (!mca_cfg.monarch_timeout)
 		goto out;
 	if ((s64)*t < SPINUNIT) {
-		if (mca_cfg.tolerant <= 1)
+		if (mca_cfg.tolerant <= 1) {
+			if (cpumask_and(&mce_missing_cpus, cpu_online_mask, &mce_missing_cpus))
+				pr_emerg("CPUs not responding to MCE broadcast (may include false positives): %*pbl\n",
+					 cpumask_pr_args(&mce_missing_cpus));
 			mce_panic(msg, NULL, NULL);
+		}
 		cpu_missing = 1;
 		return 1;
 	}
@@ -1006,6 +1016,7 @@ static int mce_start(int *no_way_out)
 	 * is updated before mce_callin.
 	 */
 	order = atomic_inc_return(&mce_callin);
+	cpumask_clear_cpu(smp_processor_id(), &mce_missing_cpus);
 
 	/*
 	 * Wait for everyone.
@@ -1114,6 +1125,7 @@ static int mce_end(int order)
 reset:
 	atomic_set(&global_nwo, 0);
 	atomic_set(&mce_callin, 0);
+	cpumask_setall(&mce_missing_cpus);
 	barrier();
 
 	/*
@@ -2712,6 +2724,7 @@ static void mce_reset(void)
 	atomic_set(&mce_executing, 0);
 	atomic_set(&mce_callin, 0);
 	atomic_set(&global_nwo, 0);
+	cpumask_setall(&mce_missing_cpus);
 }
 
 static int fake_panic_get(void *data, u64 *val)