aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Luck <tony.luck@intel.com>2016-01-16 15:06:09 -0800
committerTony Luck <tony.luck@intel.com>2016-01-16 15:06:09 -0800
commit767456f1cf0d32d7f25753c84413517c89455980 (patch)
tree4acb7d3346727642665d544cab9558137997c368
parent14ce72b257788f253fec6d99843c2d3cd94937aa (diff)
downloadras-tools-767456f1cf0d32d7f25753c84413517c89455980.tar.gz
Don't wait for a fixed interval for CMCIs to be counted
Instead of hard coding a fixed large time to sleep before checking how many CMCIs were logged, just sleep in 100us increments until we see at least the expected number. Give up waiting after 1000 such rechecks. If we blocked for any more than 100us, then report the actual time. Original patch by Carl Sapp. Modified to use gettimeofday() to report actual delay. Signed-off-by: Tony Luck <tony.luck@intel.com>
-rw-r--r--einj_mem_uc.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/einj_mem_uc.c b/einj_mem_uc.c
index b37f1a4..4c45739 100644
--- a/einj_mem_uc.c
+++ b/einj_mem_uc.c
@@ -14,6 +14,7 @@
#include <string.h>
#include <time.h>
#include <sys/mman.h>
+#include <sys/time.h>
#include <setjmp.h>
#include <signal.h>
@@ -309,12 +310,13 @@ struct sigaction recover_act = {
int main(int argc, char **argv)
{
int c, i;
- int count = 1;
+ int count = 1, cmci_wait_count = 0;
double delay = 1.0;
struct test *t;
void *vaddr;
long long paddr;
long b_mce, b_cmci, a_mce, a_cmci;
+ struct timeval t1, t2;
progname = argv[0];
@@ -351,11 +353,13 @@ int main(int argc, char **argv)
sigaction(SIGBUS, &recover_act, NULL);
for (i = 0; i < count; i++) {
+ cmci_wait_count = 0;
vaddr = t->alloc();
paddr = vtop((long long)vaddr);
printf("%d: %-8s vaddr = %p paddr = %llx\n", i, t->testname, vaddr, paddr);
proc_interrupts(&b_mce, &b_cmci);
+ gettimeofday(&t1, NULL);
if (sigsetjmp(env, 1)) {
if ((t->flags & F_SIGBUS) == 0) {
printf("Unexpected SIGBUS\n");
@@ -374,7 +378,7 @@ int main(int argc, char **argv)
}
/* Give system a chance to process on possibly deep C-state idle cpus */
- usleep(10000);
+ usleep(100);
proc_interrupts(&a_mce, &a_cmci);
@@ -399,6 +403,20 @@ int main(int argc, char **argv)
}
if (t->flags & F_CMCI) {
+ while (a_cmci < b_cmci + lcpus_persocket) {
+ if (cmci_wait_count > 1000) {
+ break;
+ }
+ usleep(100);
+ proc_interrupts(&a_mce, &a_cmci);
+ cmci_wait_count++;
+ }
+ if (cmci_wait_count != 0) {
+ gettimeofday(&t2, NULL);
+ printf("CMCIs took ~%ld usecs to be reported.\n",
+ 1000000 * (t2.tv_sec - t1.tv_sec) +
+ (t2.tv_usec - t1.tv_usec));
+ }
if (a_cmci == b_cmci) {
printf("Expected CMCI, but none seen\n");
} else if (a_cmci < b_cmci + lcpus_persocket) {