Gilles Chanteperdrix wrote:
 > Philippe Gerum wrote:
 >  > On Sun, 2006-07-09 at 18:56 +0200, Jan Kiszka wrote:
 >  > > I can confirm the failing NMI test here on my notebook with both nucleus
 >  > > and native skin built into the kernel. I haven't seen false positive
 >  > > NMIs yet, but the tracer is still on. Will switch off and re-check.
 >  > 
 >  > FWIW, here, the false positive is raised immediately when starting the
 >  > latency test.
 > 
 > The attached patch attempt to workaround these early shots, count them,
 > and display them in /proc/xenomai/nmi_early_shots. Could you try it on
 > your box and see if the /proc display moves ?

This patch should work better.

-- 


                                            Gilles Chanteperdrix.
Index: ksrc/arch/i386/nmi.c
===================================================================
--- ksrc/arch/i386/nmi.c        (revision 1322)
+++ ksrc/arch/i386/nmi.c        (working copy)
@@ -61,6 +61,9 @@
         unsigned long perfctr_msr;
         unsigned long long next_linux_check;
         unsigned int p4_cccr_val;
+
+               unsigned early_shots;
+               unsigned long long tick_date;
     };
     char __pad[SMP_CACHE_BYTES];
 } rthal_nmi_wd_t ____cacheline_aligned;
@@ -108,8 +111,13 @@
     rthal_nmi_wd_t *wd = &rthal_nmi_wds[cpu];
     unsigned long long now;
 
-    if (wd->armed)
+       if (wd->armed) {
+               if (rthal_rdtsc() - wd->tick_date < rthal_maxlat_tsc) {
+                       ++wd->early_shots;
+                       wd->next_linux_check = wd->tick_date + rthal_maxlat_tsc;
+               } else
         rthal_nmi_emergency(regs);
+       }
 
     now = rthal_rdtsc();
 
@@ -142,6 +150,27 @@
     wrmsrl(wd->perfctr_msr, now - wd->next_linux_check);
 }
 
+static int earlyshots_read_proc(char *page,
+                               char **start,
+                               off_t off, int count, int *eof, void *data)
+{
+       int i, len = 0;
+
+       for_each_online_cpu(i)
+               len += sprintf(page + len, "CPU#%d: %u\n",
+                              i, rthal_nmi_wds[i].early_shots);
+       len -= off;
+       if (len <= off + count)
+               *eof = 1;
+       *start = page + off;
+       if (len > count)
+               len = count;
+       if (len < 0)
+               len = 0;
+
+       return len;
+}
+
 int rthal_nmi_request(void (*emergency) (struct pt_regs *))
 {
     if (!nmi_active || !nmi_watchdog_tick)
@@ -180,6 +209,11 @@
     rthal_linux_nmi_tick = nmi_watchdog_tick;
     wmb();
     nmi_watchdog_tick = &rthal_nmi_watchdog_tick;
+
+       __rthal_add_proc_leaf("nmi_early_shots",
+                             &earlyshots_read_proc,
+                             NULL, NULL, rthal_proc_root);
+
     return 0;
 }
 
@@ -188,6 +222,8 @@
     if (!rthal_linux_nmi_tick)
         return;
 
+       remove_proc_entry("nmi_early_shots", rthal_proc_root);
+
     wrmsrl(rthal_nmi_perfctr_msr, 0 - RTHAL_CPU_FREQ);
     touch_nmi_watchdog();
     wmb();
@@ -215,6 +251,8 @@
         rthal_local_irq_restore(flags);
     }
 
+       wd->tick_date = rthal_rdtsc() + (delay - rthal_maxlat_tsc);
+       wmb();
     wrmsrl(wd->perfctr_msr, 0 - delay);
     wmb();
     wd->armed = 1;
_______________________________________________
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core

Reply via email to