From c7520961bfa09daf33abd81165989e8c9e02e8ae Mon Sep 17 00:00:00 2001 From: bouyer Date: Sun, 17 Apr 2005 14:50:11 +0000 Subject: [PATCH] Allow to pass a more descriptive name to event_set_handler() (e.g. IRQ number for physical IRQ, or device name for xen device drivers). This makes systat and vmstat output more usable, especially as the channel numbers change each time a guest reboots. --- sys/arch/xen/include/evtchn.h | 4 ++-- sys/arch/xen/xen/clock.c | 6 +++--- sys/arch/xen/xen/ctrl_if.c | 7 ++++--- sys/arch/xen/xen/evtchn.c | 25 +++++++++++++++++-------- sys/arch/xen/xen/if_xennet.c | 6 +++--- sys/arch/xen/xen/xbd.c | 10 ++++++---- sys/arch/xen/xen/xbdback.c | 6 ++++-- sys/arch/xen/xen/xencons.c | 6 +++--- sys/arch/xen/xen/xennetback.c | 4 ++-- 9 files changed, 44 insertions(+), 30 deletions(-) diff --git a/sys/arch/xen/include/evtchn.h b/sys/arch/xen/include/evtchn.h index cbca15494fbe..d100837c2418 100644 --- a/sys/arch/xen/include/evtchn.h +++ b/sys/arch/xen/include/evtchn.h @@ -1,4 +1,4 @@ -/* $NetBSD: evtchn.h,v 1.5 2005/04/16 22:49:37 bouyer Exp $ */ +/* $NetBSD: evtchn.h,v 1.6 2005/04/17 14:50:11 bouyer Exp $ */ /* * @@ -41,7 +41,7 @@ extern struct evtsource *evtsource[]; void events_default_setup(void); void init_events(void); unsigned int do_event(int, struct intrframe *); -int event_set_handler(int, int (*func)(void *), void *, int); +int event_set_handler(int, int (*func)(void *), void *, int, const char *); int event_remove_handler(int, int (*func)(void *), void *); int bind_virq_to_evtch(int); diff --git a/sys/arch/xen/xen/clock.c b/sys/arch/xen/xen/clock.c index a648b09cf66c..cad3d3d919c1 100644 --- a/sys/arch/xen/xen/clock.c +++ b/sys/arch/xen/xen/clock.c @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.10 2005/04/16 22:49:38 bouyer Exp $ */ +/* $NetBSD: clock.c,v 1.11 2005/04/17 14:50:11 bouyer Exp $ */ /* * @@ -34,7 +34,7 @@ #include "opt_xen.h" #include -__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.10 2005/04/16 22:49:38 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.11 2005/04/17 14:50:11 bouyer Exp $"); #include #include @@ -235,7 +235,7 @@ xen_initclocks() processed_system_time = shadow_system_time; event_set_handler(evtch, (int (*)(void *))xen_timer_handler, - NULL, IPL_CLOCK); + NULL, IPL_CLOCK, "clock"); hypervisor_enable_event(evtch); } diff --git a/sys/arch/xen/xen/ctrl_if.c b/sys/arch/xen/xen/ctrl_if.c index 98fe6469409e..1f16f8ed0df7 100644 --- a/sys/arch/xen/xen/ctrl_if.c +++ b/sys/arch/xen/xen/ctrl_if.c @@ -1,4 +1,4 @@ -/* $NetBSD: ctrl_if.c,v 1.5 2005/04/16 22:49:38 bouyer Exp $ */ +/* $NetBSD: ctrl_if.c,v 1.6 2005/04/17 14:50:11 bouyer Exp $ */ /****************************************************************************** * ctrl_if.c @@ -9,7 +9,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ctrl_if.c,v 1.5 2005/04/16 22:49:38 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ctrl_if.c,v 1.6 2005/04/17 14:50:11 bouyer Exp $"); #include #include @@ -497,7 +497,8 @@ void ctrl_if_resume(void) aprint_verbose("Domain controller: using event channel %d\n", ctrl_if_evtchn); - event_set_handler(ctrl_if_evtchn, &ctrl_if_interrupt, NULL, IPL_CTRL); + event_set_handler(ctrl_if_evtchn, &ctrl_if_interrupt, NULL, IPL_CTRL, + "ctrlev"); hypervisor_enable_event(ctrl_if_evtchn); } diff --git a/sys/arch/xen/xen/evtchn.c b/sys/arch/xen/xen/evtchn.c index c0a2fef6a570..2520825c8480 100644 --- a/sys/arch/xen/xen/evtchn.c +++ b/sys/arch/xen/xen/evtchn.c @@ -1,4 +1,4 @@ -/* $NetBSD: evtchn.c,v 1.6 2005/04/16 23:33:18 bouyer Exp $ */ +/* $NetBSD: evtchn.c,v 1.7 2005/04/17 14:50:11 bouyer Exp $ */ /* * @@ -34,7 +34,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.6 2005/04/16 23:33:18 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.7 2005/04/17 14:50:11 bouyer Exp $"); #include #include @@ -125,13 +125,15 @@ init_events() evtch = bind_virq_to_evtch(VIRQ_DEBUG); aprint_verbose("debug vitual interrupt using event channel %d\n", evtch); - event_set_handler(evtch, &xen_debug_handler, NULL, IPL_DEBUG); + event_set_handler(evtch, &xen_debug_handler, NULL, IPL_DEBUG, + "debugev"); hypervisor_enable_event(evtch); evtch = bind_virq_to_evtch(VIRQ_MISDIRECT); aprint_verbose("misdirect vitual interrupt using event channel %d\n", evtch); - event_set_handler(evtch, &xen_misdirect_handler, NULL, IPL_DIE); + event_set_handler(evtch, &xen_misdirect_handler, NULL, IPL_DIE, + "misdirev"); hypervisor_enable_event(evtch); /* This needs to be done early, but after the IRQ subsystem is @@ -352,13 +354,15 @@ pirq_establish(int pirq, int evtch, int (*func)(void *), void *arg, int level) { struct pintrhand *ih; physdev_op_t physdev_op; + char evname[8]; ih = malloc(sizeof *ih, M_DEVBUF, cold ? M_NOWAIT : M_WAITOK); if (ih == NULL) { printf("pirq_establish: can't malloc handler info\n"); return NULL; } - if (event_set_handler(evtch, pirq_interrupt, ih, level) != 0) { + snprintf(evname, sizeof(evname), "irq%d", pirq); + if (event_set_handler(evtch, pirq_interrupt, ih, level, evname) != 0) { free(ih, M_DEVBUF); return NULL; } @@ -400,7 +404,8 @@ pirq_interrupt(void *arg) #endif /* DOM0OPS */ int -event_set_handler(int evtch, int (*func)(void *), void *arg, int level) +event_set_handler(int evtch, int (*func)(void *), void *arg, int level, + const char *evname) { struct iplsource *ipls; struct evtsource *evts; @@ -458,8 +463,12 @@ event_set_handler(int evtch, int (*func)(void *), void *arg, int level) panic("can't allocate fixed interrupt source"); evts->ev_handlers = ih; evtsource[evtch] = evts; - snprintf(evts->ev_evname, sizeof(evts->ev_evname), "evt%d", - evtch); + if (evname) + strncpy(evts->ev_evname, evname, + sizeof(evts->ev_evname)); + else + snprintf(evts->ev_evname, sizeof(evts->ev_evname), + "evt%d", evtch); evcnt_attach_dynamic(&evts->ev_evcnt, EVCNT_TYPE_INTR, NULL, ci->ci_dev->dv_xname, evts->ev_evname); } else { diff --git a/sys/arch/xen/xen/if_xennet.c b/sys/arch/xen/xen/if_xennet.c index b1cc18c02168..92c3f1b709eb 100644 --- a/sys/arch/xen/xen/if_xennet.c +++ b/sys/arch/xen/xen/if_xennet.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet.c,v 1.20 2005/04/16 22:49:38 bouyer Exp $ */ +/* $NetBSD: if_xennet.c,v 1.21 2005/04/17 14:50:11 bouyer Exp $ */ /* * @@ -33,7 +33,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: if_xennet.c,v 1.20 2005/04/16 22:49:38 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xennet.c,v 1.21 2005/04/17 14:50:11 bouyer Exp $"); #include "opt_inet.h" #include "rnd.h" @@ -532,7 +532,7 @@ xennet_interface_status_change(netif_fe_interface_status_t *status) aprint_verbose("%s: using event channel %d\n", sc->sc_dev.dv_xname, sc->sc_evtchn); event_set_handler(sc->sc_evtchn, - &xen_network_handler, sc, IPL_NET); + &xen_network_handler, sc, IPL_NET, sc->sc_dev.dv_xname); hypervisor_enable_event(sc->sc_evtchn); xennet_driver_count_connected(); diff --git a/sys/arch/xen/xen/xbd.c b/sys/arch/xen/xen/xbd.c index ca9ad37e9361..6538cc11631f 100644 --- a/sys/arch/xen/xen/xbd.c +++ b/sys/arch/xen/xen/xbd.c @@ -1,4 +1,4 @@ -/* $NetBSD: xbd.c,v 1.17 2005/04/16 22:49:38 bouyer Exp $ */ +/* $NetBSD: xbd.c,v 1.18 2005/04/17 14:50:11 bouyer Exp $ */ /* * @@ -33,7 +33,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: xbd.c,v 1.17 2005/04/16 22:49:38 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbd.c,v 1.18 2005/04/17 14:50:11 bouyer Exp $"); #include "xbd.h" #include "rnd.h" @@ -568,7 +568,8 @@ connect_interface(blkif_fe_interface_status_t *status) aprint_verbose("xbd: using event channel %d\n", blkif_evtchn); - event_set_handler(blkif_evtchn, &xbd_response_handler, NULL, IPL_BIO); + event_set_handler(blkif_evtchn, &xbd_response_handler, NULL, IPL_BIO, + "xbd"); hypervisor_enable_event(blkif_evtchn); /* Transition to connected in case we need to do @@ -775,7 +776,8 @@ enable_update_events(struct device *self) { kthread_create(xbd_update_create_kthread, self); - event_set_handler(_EVENT_VBD_UPD, &xbd_update_handler, self, IPL_BIO); + event_set_handler(_EVENT_VBD_UPD, &xbd_update_handler, self, IPL_BIO, + "xbdup"); hypervisor_enable_event(_EVENT_VBD_UPD); } #endif diff --git a/sys/arch/xen/xen/xbdback.c b/sys/arch/xen/xen/xbdback.c index 4423eea0b82e..0418eb1d86b9 100644 --- a/sys/arch/xen/xen/xbdback.c +++ b/sys/arch/xen/xen/xbdback.c @@ -1,4 +1,4 @@ -/* $NetBSD: xbdback.c,v 1.9 2005/04/16 23:33:18 bouyer Exp $ */ +/* $NetBSD: xbdback.c,v 1.10 2005/04/17 14:50:11 bouyer Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -228,6 +228,7 @@ xbdback_ctrlif_rx(ctrl_msg_t *msg, unsigned long id) { blkif_be_connect_t *req = (blkif_be_connect_t *)&msg->msg[0]; vaddr_t ring_addr; + char evname[16]; if (msg->length != sizeof(blkif_be_connect_t)) goto error; @@ -262,8 +263,9 @@ xbdback_ctrlif_rx(ctrl_msg_t *msg, unsigned long id) } xbdi->blk_ring = (void *)ring_addr; xbdi->evtchn = req->evtchn; + snprintf(evname, sizeof(evname), "xbdback%d", xbdi->domid); event_set_handler(xbdi->evtchn, - xbdback_evthandler, xbdi, IPL_BIO); + xbdback_evthandler, xbdi, IPL_BIO, evname); printf("xbd backend %d for domain %d using event channel %d\n", xbdi->handle, xbdi->domid, xbdi->evtchn); hypervisor_enable_event(xbdi->evtchn); diff --git a/sys/arch/xen/xen/xencons.c b/sys/arch/xen/xen/xencons.c index e94ed4a2f83c..b07dda0835e3 100644 --- a/sys/arch/xen/xen/xencons.c +++ b/sys/arch/xen/xen/xencons.c @@ -1,4 +1,4 @@ -/* $NetBSD: xencons.c,v 1.6 2005/04/16 22:49:38 bouyer Exp $ */ +/* $NetBSD: xencons.c,v 1.7 2005/04/17 14:50:11 bouyer Exp $ */ /* * @@ -33,7 +33,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.6 2005/04/16 22:49:38 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.7 2005/04/17 14:50:11 bouyer Exp $"); #include #include @@ -159,7 +159,7 @@ xencons_attach(struct device *parent, struct device *self, void *aux) aprint_verbose("%s: using event channel %d\n", sc->sc_dev.dv_xname, evtch); if (event_set_handler(evtch, xencons_intr, sc, - IPL_TTY) != 0) + IPL_TTY, "xencons") != 0) printf("console: " "can't register xencons_intr\n"); hypervisor_enable_event(evtch); diff --git a/sys/arch/xen/xen/xennetback.c b/sys/arch/xen/xen/xennetback.c index 02ab84a4dff9..2c300b55e2fa 100644 --- a/sys/arch/xen/xen/xennetback.c +++ b/sys/arch/xen/xen/xennetback.c @@ -1,4 +1,4 @@ -/* $NetBSD: xennetback.c,v 1.8 2005/04/16 23:33:18 bouyer Exp $ */ +/* $NetBSD: xennetback.c,v 1.9 2005/04/17 14:50:11 bouyer Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -349,7 +349,7 @@ fail_1: xneti->xni_txring = (void *)ring_txaddr; xneti->xni_evtchn = req->evtchn; event_set_handler(xneti->xni_evtchn, xennetback_evthandler, - xneti, IPL_NET); + xneti, IPL_NET, xneti->xni_if.if_xname); printf("%s using event channel %d\n", xneti->xni_if.if_xname, xneti->xni_evtchn); hypervisor_enable_event(xneti->xni_evtchn);