Tue Dec 17 22:39:49 2013 UTC ()
Pull up following revision(s) (requested by bouyer in ticket #995):
	sys/arch/xen/xen/evtchn.c: revision 1.70
Remove the "evtchn_do_event: handler %p didn't lower ipl %d %d\n" printf.
With help from Robert Elz we've finally figured out what's going on, and
it actually isn't a bug in the handler, but related to spin mutexes.
When a spin mutex is released, the IPL isn't lowered back if the
curcpu is holding other spin mutexes. This is because mutexes may not
be released in order (and, in this case, the CPU in interrupted while
it holds a spin mutex at IPL < IPL_SCHED).
Also remove the test and resetting the IPL, it will be reset anyway
inside the loop, or at the end of the loop.


(riz)
diff -r1.62 -r1.62.8.1 src/sys/arch/xen/xen/evtchn.c

cvs diff -r1.62 -r1.62.8.1 src/sys/arch/xen/xen/evtchn.c (expand / switch to unified diff)

--- src/sys/arch/xen/xen/evtchn.c 2012/02/12 14:24:08 1.62
+++ src/sys/arch/xen/xen/evtchn.c 2013/12/17 22:39:49 1.62.8.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: evtchn.c,v 1.62 2012/02/12 14:24:08 jym Exp $ */ 1/* $NetBSD: evtchn.c,v 1.62.8.1 2013/12/17 22:39:49 riz Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006 Manuel Bouyer. 4 * Copyright (c) 2006 Manuel Bouyer.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -44,27 +44,27 @@ @@ -44,27 +44,27 @@
44 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 44 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
45 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 45 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
46 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 46 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
47 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 47 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 48 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 50 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
52 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 52 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 */ 53 */
54 54
55 55
56#include <sys/cdefs.h> 56#include <sys/cdefs.h>
57__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.62 2012/02/12 14:24:08 jym Exp $"); 57__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.62.8.1 2013/12/17 22:39:49 riz Exp $");
58 58
59#include "opt_xen.h" 59#include "opt_xen.h"
60#include "isa.h" 60#include "isa.h"
61#include "pci.h" 61#include "pci.h"
62 62
63#include <sys/param.h> 63#include <sys/param.h>
64#include <sys/cpu.h> 64#include <sys/cpu.h>
65#include <sys/kernel.h> 65#include <sys/kernel.h>
66#include <sys/systm.h> 66#include <sys/systm.h>
67#include <sys/device.h> 67#include <sys/device.h>
68#include <sys/proc.h> 68#include <sys/proc.h>
69#include <sys/kmem.h> 69#include <sys/kmem.h>
70#include <sys/reboot.h> 70#include <sys/reboot.h>
@@ -337,33 +337,26 @@ splx: @@ -337,33 +337,26 @@ splx:
337 iplbit = 1 << (NIPL - 1); 337 iplbit = 1 << (NIPL - 1);
338 i = (NIPL - 1); 338 i = (NIPL - 1);
339 while (iplmask != 0 && i > ilevel) { 339 while (iplmask != 0 && i > ilevel) {
340 while (iplmask & iplbit) { 340 while (iplmask & iplbit) {
341 ci->ci_ipending &= ~iplbit; 341 ci->ci_ipending &= ~iplbit;
342 ci->ci_ilevel = i; 342 ci->ci_ilevel = i;
343 for (ih = ci->ci_isources[i]->ipl_handlers; 343 for (ih = ci->ci_isources[i]->ipl_handlers;
344 ih != NULL; ih = ih->ih_ipl_next) { 344 ih != NULL; ih = ih->ih_ipl_next) {
345 KASSERT(ih->ih_cpu == ci); 345 KASSERT(ih->ih_cpu == ci);
346 sti(); 346 sti();
347 ih_fun = (void *)ih->ih_fun; 347 ih_fun = (void *)ih->ih_fun;
348 ih_fun(ih->ih_arg, regs); 348 ih_fun(ih->ih_arg, regs);
349 cli(); 349 cli();
350 if (ci->ci_ilevel != i) { 
351 printf("evtchn_do_event: " 
352 "handler %p didn't lower " 
353 "ipl %d %d\n", 
354 ih_fun, ci->ci_ilevel, i); 
355 ci->ci_ilevel = i; 
356 } 
357 } 350 }
358 hypervisor_enable_ipl(i); 351 hypervisor_enable_ipl(i);
359 /* more pending IPLs may have been registered */ 352 /* more pending IPLs may have been registered */
360 iplmask = 353 iplmask =
361 (IUNMASK(ci, ilevel) & ci->ci_ipending); 354 (IUNMASK(ci, ilevel) & ci->ci_ipending);
362 } 355 }
363 i--; 356 i--;
364 iplbit >>= 1; 357 iplbit >>= 1;
365 } 358 }
366 } 359 }
367 ci->ci_ilevel = ilevel; 360 ci->ci_ilevel = ilevel;
368 return 0; 361 return 0;
369} 362}