From 12586b823bd2bb1e45d057286b2912e27a33bacb Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Fri, 27 Aug 2010 18:28:38 -0700 Subject: [PATCH] kernel - Add description to static token initializers * Add a description argument for LWKT_TOKEN_xx_INITIALIZER() --- sys/kern/kern_event.c | 2 +- sys/kern/lwkt_token.c | 16 ++++++++-------- sys/kern/sys_generic.c | 14 +++++++------- sys/platform/pc32/i386/busdma_machdep.c | 3 ++- sys/platform/pc64/x86_64/busdma_machdep.c | 3 ++- sys/platform/vkernel/platform/busdma_machdep.c | 3 ++- sys/platform/vkernel64/platform/busdma_machdep.c | 3 ++- sys/sys/thread.h | 10 ++++++---- 8 files changed, 30 insertions(+), 24 deletions(-) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index f859dae..40c42ab 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -60,7 +60,7 @@ /* * Global token for kqueue subsystem */ -struct lwkt_token kq_token = LWKT_TOKEN_UP_INITIALIZER; +struct lwkt_token kq_token = LWKT_TOKEN_UP_INITIALIZER(kq_token); MALLOC_DEFINE(M_KQUEUE, "kqueue", "memory for kqueue system"); diff --git a/sys/kern/lwkt_token.c b/sys/kern/lwkt_token.c index 2597df5..e0f015f 100644 --- a/sys/kern/lwkt_token.c +++ b/sys/kern/lwkt_token.c @@ -128,14 +128,14 @@ SYSCTL_INT(_lwkt, OID_AUTO, token_debug, CTLFLAG_RW, &token_debug, 0, ""); * any time, the MP state is copied to the tokref when the token is acquired * and will not race against sysctl changes. */ -struct lwkt_token pmap_token = LWKT_TOKEN_UP_INITIALIZER; -struct lwkt_token dev_token = LWKT_TOKEN_UP_INITIALIZER; -struct lwkt_token vm_token = LWKT_TOKEN_UP_INITIALIZER; -struct lwkt_token vmspace_token = LWKT_TOKEN_UP_INITIALIZER; -struct lwkt_token kvm_token = LWKT_TOKEN_UP_INITIALIZER; -struct lwkt_token proc_token = LWKT_TOKEN_UP_INITIALIZER; -struct lwkt_token tty_token = LWKT_TOKEN_UP_INITIALIZER; -struct lwkt_token vnode_token = LWKT_TOKEN_UP_INITIALIZER; +struct lwkt_token pmap_token = LWKT_TOKEN_UP_INITIALIZER(pmap_token); +struct lwkt_token dev_token = LWKT_TOKEN_UP_INITIALIZER(dev_token); +struct lwkt_token vm_token = LWKT_TOKEN_UP_INITIALIZER(vm_token); +struct lwkt_token vmspace_token = LWKT_TOKEN_UP_INITIALIZER(vmspace_token); +struct lwkt_token kvm_token = LWKT_TOKEN_UP_INITIALIZER(kvm_token); +struct lwkt_token proc_token = LWKT_TOKEN_UP_INITIALIZER(proc_token); +struct lwkt_token tty_token = LWKT_TOKEN_UP_INITIALIZER(tty_token); +struct lwkt_token vnode_token = LWKT_TOKEN_UP_INITIALIZER(vnode_token); SYSCTL_INT(_lwkt, OID_AUTO, pmap_mpsafe, CTLFLAG_RW, &pmap_token.t_flags, 0, ""); diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index f6672f6..18b6f6a 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -108,7 +108,7 @@ struct poll_kevent_copyin_args { int error; }; -static struct lwkt_token mapped_ioctl_token = LWKT_TOKEN_MP_INITIALIZER; +static struct lwkt_token mioctl_token = LWKT_TOKEN_MP_INITIALIZER(mioctl_token); static int doselect(int nd, fd_set *in, fd_set *ou, fd_set *ex, struct timespec *ts, int *res); @@ -603,7 +603,7 @@ mapped_ioctl(int fd, u_long com, caddr_t uspc_data, struct ioctl_map *map, maskcmd = com & map->mask; - lwkt_gettoken(&mapped_ioctl_token); + lwkt_gettoken(&mioctl_token); LIST_FOREACH(e, &map->mapping, entries) { for (iomc = e->cmd_ranges; iomc->start != 0 || iomc->maptocmd != 0 || iomc->wrapfunc != NULL || @@ -619,7 +619,7 @@ mapped_ioctl(int fd, u_long com, caddr_t uspc_data, struct ioctl_map *map, iomc->wrapfunc != NULL || iomc->mapfunc != NULL) break; } - lwkt_reltoken(&mapped_ioctl_token); + lwkt_reltoken(&mioctl_token); if (iomc == NULL || (iomc->start == 0 && iomc->maptocmd == 0 @@ -767,9 +767,9 @@ mapped_ioctl_register_handler(struct ioctl_map_handler *he) ne->subsys = he->subsys; ne->cmd_ranges = he->cmd_ranges; - lwkt_gettoken(&mapped_ioctl_token); + lwkt_gettoken(&mioctl_token); LIST_INSERT_HEAD(&he->map->mapping, ne, entries); - lwkt_reltoken(&mapped_ioctl_token); + lwkt_reltoken(&mioctl_token); return(0); } @@ -785,7 +785,7 @@ mapped_ioctl_unregister_handler(struct ioctl_map_handler *he) KKASSERT(he != NULL && he->map != NULL && he->cmd_ranges != NULL); - lwkt_gettoken(&mapped_ioctl_token); + lwkt_gettoken(&mioctl_token); LIST_FOREACH(ne, &he->map->mapping, entries) { if (ne->cmd_ranges == he->cmd_ranges) { LIST_REMOVE(ne, entries); @@ -794,7 +794,7 @@ mapped_ioctl_unregister_handler(struct ioctl_map_handler *he) break; } } - lwkt_reltoken(&mapped_ioctl_token); + lwkt_reltoken(&mioctl_token); return(error); } diff --git a/sys/platform/pc32/i386/busdma_machdep.c b/sys/platform/pc32/i386/busdma_machdep.c index 6f02811..2721b20 100644 --- a/sys/platform/pc32/i386/busdma_machdep.c +++ b/sys/platform/pc32/i386/busdma_machdep.c @@ -138,7 +138,8 @@ struct bounce_zone { #define BZ_UNLOCK(bz) crit_exit() #endif -static struct lwkt_token bounce_zone_tok = LWKT_TOKEN_MP_INITIALIZER; +static struct lwkt_token bounce_zone_tok = + LWKT_TOKEN_MP_INITIALIZER(bounce_zone_tok); static int busdma_zonecount; static STAILQ_HEAD(, bounce_zone) bounce_zone_list = STAILQ_HEAD_INITIALIZER(bounce_zone_list); diff --git a/sys/platform/pc64/x86_64/busdma_machdep.c b/sys/platform/pc64/x86_64/busdma_machdep.c index 6f02811..eba440f 100644 --- a/sys/platform/pc64/x86_64/busdma_machdep.c +++ b/sys/platform/pc64/x86_64/busdma_machdep.c @@ -138,7 +138,8 @@ struct bounce_zone { #define BZ_UNLOCK(bz) crit_exit() #endif -static struct lwkt_token bounce_zone_tok = LWKT_TOKEN_MP_INITIALIZER; +static struct lwkt_token bounce_zone_tok = + LWKT_TOKEN_MP_INITIALIZER(bounce_zone_token); static int busdma_zonecount; static STAILQ_HEAD(, bounce_zone) bounce_zone_list = STAILQ_HEAD_INITIALIZER(bounce_zone_list); diff --git a/sys/platform/vkernel/platform/busdma_machdep.c b/sys/platform/vkernel/platform/busdma_machdep.c index 4e1bcc5..d8326c8 100644 --- a/sys/platform/vkernel/platform/busdma_machdep.c +++ b/sys/platform/vkernel/platform/busdma_machdep.c @@ -128,7 +128,8 @@ struct bounce_zone { #define BZ_UNLOCK(bz) crit_exit() #endif -static struct lwkt_token bounce_zone_tok = LWKT_TOKEN_MP_INITIALIZER; +static struct lwkt_token bounce_zone_tok = + LWKT_TOKEN_MP_INITIALIZER(bounce_zone_token); static int busdma_zonecount; static STAILQ_HEAD(, bounce_zone) bounce_zone_list = STAILQ_HEAD_INITIALIZER(bounce_zone_list); diff --git a/sys/platform/vkernel64/platform/busdma_machdep.c b/sys/platform/vkernel64/platform/busdma_machdep.c index 05c391b..e5ded77 100644 --- a/sys/platform/vkernel64/platform/busdma_machdep.c +++ b/sys/platform/vkernel64/platform/busdma_machdep.c @@ -126,7 +126,8 @@ struct bounce_zone { #define BZ_UNLOCK(bz) crit_exit() #endif -static struct lwkt_token bounce_zone_tok = LWKT_TOKEN_MP_INITIALIZER; +static struct lwkt_token bounce_zone_tok = + LWKT_TOKEN_MP_INITIALIZER(bounce_zone_token); static int busdma_zonecount; static STAILQ_HEAD(, bounce_zone) bounce_zone_list = STAILQ_HEAD_INITIALIZER(bounce_zone_list); diff --git a/sys/sys/thread.h b/sys/sys/thread.h index ca8b2a0..2e37597 100644 --- a/sys/sys/thread.h +++ b/sys/sys/thread.h @@ -114,18 +114,20 @@ typedef struct lwkt_token { * UP - Not MPSAFE (full MP lock will also be acquired) * MP - Is MPSAFE (only the token will be acquired) */ -#define LWKT_TOKEN_UP_INITIALIZER \ +#define LWKT_TOKEN_UP_INITIALIZER(name) \ { \ .t_ref = NULL, \ .t_flags = 0, \ - .t_collisions = 0 \ + .t_collisions = 0, \ + .t_desc = #name \ } -#define LWKT_TOKEN_MP_INITIALIZER \ +#define LWKT_TOKEN_MP_INITIALIZER(name) \ { \ .t_ref = NULL, \ .t_flags = LWKT_TOKEN_MPSAFE, \ - .t_collisions = 0 \ + .t_collisions = 0, \ + .t_desc = #name \ } #define ASSERT_LWKT_TOKEN_HELD(tok) \ -- 1.7.7.2