From: Matthew Dillon Date: Thu, 20 Jan 2011 06:29:17 +0000 (-0800) Subject: kernel - Remove mplock shims from global tokens X-Git-Tag: v2.11.0~286 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/a3c18566ccf6ecbc95134c676a31772261128e67 kernel - Remove mplock shims from global tokens * Remove the mplock safety shims from all global tokens. * Remove the mplock flag and API arguments. All tokens are now always MPSAFE. --- diff --git a/sys/emulation/linux/i386/linprocfs/linprocfs_subr.c b/sys/emulation/linux/i386/linprocfs/linprocfs_subr.c index 48a0f224a9..b148ce1582 100644 --- a/sys/emulation/linux/i386/linprocfs/linprocfs_subr.c +++ b/sys/emulation/linux/i386/linprocfs/linprocfs_subr.c @@ -403,7 +403,7 @@ vfs_findname(vfs_namemap_t *nm, char *buf, int buflen) void linprocfs_init(void) { - lwkt_token_init(&pfs_token, 1, "linprocfs"); + lwkt_token_init(&pfs_token, "linprocfs"); } void diff --git a/sys/emulation/ndis/kern_ndis.c b/sys/emulation/ndis/kern_ndis.c index 88da46330e..84b77d7b41 100644 --- a/sys/emulation/ndis/kern_ndis.c +++ b/sys/emulation/ndis/kern_ndis.c @@ -249,7 +249,7 @@ ndis_create_kthreads(void) struct ndis_req *r; int i, error = 0; - lwkt_token_init(&ndis_thr_token, 1, "ndis"); + lwkt_token_init(&ndis_thr_token, "ndis"); STAILQ_INIT(&ndis_ttodo); STAILQ_INIT(&ndis_itodo); diff --git a/sys/emulation/ndis/subr_ntoskrnl.c b/sys/emulation/ndis/subr_ntoskrnl.c index 6795b70979..37a42a80cc 100644 --- a/sys/emulation/ndis/subr_ntoskrnl.c +++ b/sys/emulation/ndis/subr_ntoskrnl.c @@ -186,7 +186,7 @@ static MALLOC_DEFINE(M_NDIS, "ndis", "ndis emulation"); int ntoskrnl_libinit(void) { - lwkt_token_init(&ntoskrnl_dispatchtoken, 1, "ndiskrnl"); + lwkt_token_init(&ntoskrnl_dispatchtoken, "ndiskrnl"); ntoskrnl_init_lock(&ntoskrnl_global); TAILQ_INIT(&ntoskrnl_reflist); return(0); diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 1aefd31aa5..61f136bf88 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(kq_token); +struct lwkt_token kq_token = LWKT_TOKEN_INITIALIZER(kq_token); SYSCTL_INT(_lwkt, OID_AUTO, kq_mpsafe, CTLFLAG_RW, &kq_token.t_flags, 0, "Require MP lock for kq_token"); diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c index 4778078310..a9cacfe460 100644 --- a/sys/kern/kern_kthread.c +++ b/sys/kern/kern_kthread.c @@ -41,7 +41,7 @@ #include -static struct lwkt_token kpsus_token = LWKT_TOKEN_MP_INITIALIZER(kpsus_token); +static struct lwkt_token kpsus_token = LWKT_TOKEN_INITIALIZER(kpsus_token); /* diff --git a/sys/kern/kern_mpipe.c b/sys/kern/kern_mpipe.c index 47d4632f11..26ca50e3a3 100644 --- a/sys/kern/kern_mpipe.c +++ b/sys/kern/kern_mpipe.c @@ -94,7 +94,7 @@ mpipe_init(malloc_pipe_t mpipe, malloc_type_t type, int bytes, ++mpipe->total_count; } - lwkt_token_init(&mpipe->token, 1, "mpipe token"); + lwkt_token_init(&mpipe->token, "mpipe token"); } /* diff --git a/sys/kern/lwkt_token.c b/sys/kern/lwkt_token.c index 231bd0da3c..174d80ca8c 100644 --- a/sys/kern/lwkt_token.c +++ b/sys/kern/lwkt_token.c @@ -120,35 +120,16 @@ KTR_INFO(KTR_TOKENS, tokens, contention_stop, 7, UNCONTENDED_STRING, sizeof(void * 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 mp_token = LWKT_TOKEN_MP_INITIALIZER(mp_token); -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); -struct lwkt_token vmobj_token = LWKT_TOKEN_UP_INITIALIZER(vmobj_token); - -SYSCTL_INT(_lwkt, OID_AUTO, pmap_mpsafe, CTLFLAG_RW, - &pmap_token.t_flags, 0, "Require MP lock for pmap_token"); -SYSCTL_INT(_lwkt, OID_AUTO, dev_mpsafe, CTLFLAG_RW, - &dev_token.t_flags, 0, "Require MP lock for dev_token"); -SYSCTL_INT(_lwkt, OID_AUTO, vm_mpsafe, CTLFLAG_RW, - &vm_token.t_flags, 0, "Require MP lock for vm_token"); -SYSCTL_INT(_lwkt, OID_AUTO, vmspace_mpsafe, CTLFLAG_RW, - &vmspace_token.t_flags, 0, "Require MP lock for vmspace_token"); -SYSCTL_INT(_lwkt, OID_AUTO, kvm_mpsafe, CTLFLAG_RW, - &kvm_token.t_flags, 0, "Require MP lock for kvm_token"); -SYSCTL_INT(_lwkt, OID_AUTO, proc_mpsafe, CTLFLAG_RW, - &proc_token.t_flags, 0, "Require MP lock for proc_token"); -SYSCTL_INT(_lwkt, OID_AUTO, tty_mpsafe, CTLFLAG_RW, - &tty_token.t_flags, 0, "Require MP lock for tty_token"); -SYSCTL_INT(_lwkt, OID_AUTO, vnode_mpsafe, CTLFLAG_RW, - &vnode_token.t_flags, 0, "Require MP lock for vnode_token"); -SYSCTL_INT(_lwkt, OID_AUTO, vmobj_mpsafe, CTLFLAG_RW, - &vmobj_token.t_flags, 0, "Require MP lock for vmobj_token"); +struct lwkt_token mp_token = LWKT_TOKEN_INITIALIZER(mp_token); +struct lwkt_token pmap_token = LWKT_TOKEN_INITIALIZER(pmap_token); +struct lwkt_token dev_token = LWKT_TOKEN_INITIALIZER(dev_token); +struct lwkt_token vm_token = LWKT_TOKEN_INITIALIZER(vm_token); +struct lwkt_token vmspace_token = LWKT_TOKEN_INITIALIZER(vmspace_token); +struct lwkt_token kvm_token = LWKT_TOKEN_INITIALIZER(kvm_token); +struct lwkt_token proc_token = LWKT_TOKEN_INITIALIZER(proc_token); +struct lwkt_token tty_token = LWKT_TOKEN_INITIALIZER(tty_token); +struct lwkt_token vnode_token = LWKT_TOKEN_INITIALIZER(vnode_token); +struct lwkt_token vmobj_token = LWKT_TOKEN_INITIALIZER(vmobj_token); static int lwkt_token_ipi_dispatch = 4; SYSCTL_INT(_lwkt, OID_AUTO, token_ipi_dispatch, CTLFLAG_RW, @@ -219,24 +200,7 @@ static __inline intptr_t _lwkt_tok_flags(lwkt_token_t tok, thread_t td) { - intptr_t flags; - - /* - * tok->t_flags can change out from under us, make sure we have - * a local copy. - */ - flags = tok->t_flags; - cpu_ccfence(); -#ifdef SMP - if ((flags & LWKT_TOKEN_MPSAFE) == 0 && - _lwkt_token_held(&mp_token, td)) { - return (flags | LWKT_TOKEN_MPSAFE); - } else { - return (flags); - } -#else - return (flags | LWKT_TOKEN_MPSAFE); -#endif + return(tok->t_flags); } static __inline @@ -553,9 +517,6 @@ lwkt_gettoken(lwkt_token_t tok) intptr_t flags; flags = _lwkt_tok_flags(tok, td); - if ((flags & LWKT_TOKEN_MPSAFE) == 0) - get_mplock(); - ref = td->td_toks_stop; KKASSERT(ref < &td->td_toks_end); ++td->td_toks_stop; @@ -606,9 +567,6 @@ lwkt_gettoken_hard(lwkt_token_t tok) intptr_t flags; flags = _lwkt_tok_flags(tok, td); - if ((flags & LWKT_TOKEN_MPSAFE) == 0) - get_mplock(); - ref = td->td_toks_stop; KKASSERT(ref < &td->td_toks_end); ++td->td_toks_stop; @@ -667,9 +625,6 @@ lwkt_getpooltoken(void *ptr) tok = _lwkt_token_pool_lookup(ptr); flags = _lwkt_tok_flags(tok, td); - if ((flags & LWKT_TOKEN_MPSAFE) == 0) - get_mplock(); - ref = td->td_toks_stop; KKASSERT(ref < &td->td_toks_end); ++td->td_toks_stop; @@ -729,11 +684,6 @@ lwkt_trytoken(lwkt_token_t tok) intptr_t flags; flags = _lwkt_tok_flags(tok, td); - if ((flags & LWKT_TOKEN_MPSAFE) == 0) { - if (try_mplock() == 0) - return (FALSE); - } - ref = td->td_toks_stop; KKASSERT(ref < &td->td_toks_end); ++td->td_toks_stop; @@ -744,15 +694,8 @@ lwkt_trytoken(lwkt_token_t tok) /* * Cleanup, deactivate the failed token. */ - if ((ref->tr_flags & LWKT_TOKEN_MPSAFE) == 0) { - cpu_ccfence(); - --td->td_toks_stop; - cpu_ccfence(); - rel_mplock(); - } else { - cpu_ccfence(); - --td->td_toks_stop; - } + cpu_ccfence(); + --td->td_toks_stop; return (FALSE); } return (TRUE); @@ -796,16 +739,9 @@ lwkt_reltoken(lwkt_token_t tok) _lwkt_reltoken_mask(tok); } cpu_sfence(); - if ((ref->tr_flags & LWKT_TOKEN_MPSAFE) == 0) { - cpu_ccfence(); - td->td_toks_stop = ref; - cpu_ccfence(); - rel_mplock(); - } else { - cpu_ccfence(); - td->td_toks_stop = ref; - cpu_ccfence(); - } + cpu_ccfence(); + td->td_toks_stop = ref; + cpu_ccfence(); KKASSERT(tok->t_ref != ref); } @@ -859,7 +795,7 @@ lwkt_token_pool_init(void) int i; for (i = 0; i < LWKT_NUM_POOL_TOKENS; ++i) - lwkt_token_init(&pool_tokens[i], 1, "pool"); + lwkt_token_init(&pool_tokens[i], "pool"); } lwkt_token_t @@ -873,10 +809,10 @@ lwkt_token_pool_lookup(void *ptr) * acquiring the token and released after releasing the token. */ void -lwkt_token_init(lwkt_token_t tok, int mpsafe, const char *desc) +lwkt_token_init(lwkt_token_t tok, const char *desc) { tok->t_ref = NULL; - tok->t_flags = mpsafe ? LWKT_TOKEN_MPSAFE : 0; + tok->t_flags = 0; tok->t_collisions = 0; tok->t_collmask = 0; tok->t_desc = desc; diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 1528898d99..de816f80a5 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1379,7 +1379,7 @@ disk_init(void) objcache_malloc_free, &disk_msg_malloc_args); - lwkt_token_init(&disklist_token, 1, "disks"); + lwkt_token_init(&disklist_token, "disks"); /* * Initialize the reply-only port which acts as a message drain diff --git a/sys/kern/subr_eventhandler.c b/sys/kern/subr_eventhandler.c index f58ebe7f60..ac4d3445a9 100644 --- a/sys/kern/subr_eventhandler.c +++ b/sys/kern/subr_eventhandler.c @@ -41,7 +41,7 @@ MALLOC_DEFINE(M_EVENTHANDLER, "eventhandler", "Event handler records"); /* List of 'slow' lists */ static TAILQ_HEAD(, eventhandler_list) eventhandler_lists = TAILQ_HEAD_INITIALIZER(eventhandler_lists); -static struct lwkt_token evlist_token = LWKT_TOKEN_MP_INITIALIZER(evlist_token); +static struct lwkt_token evlist_token = LWKT_TOKEN_INITIALIZER(evlist_token); struct eventhandler_entry_generic { diff --git a/sys/kern/subr_kobj.c b/sys/kern/subr_kobj.c index ec5435ce84..8041f3cb69 100644 --- a/sys/kern/subr_kobj.c +++ b/sys/kern/subr_kobj.c @@ -52,7 +52,7 @@ static int kobj_next_id = 1; static void kobj_init_token(void *arg) { - lwkt_token_init(&kobj_token, 1, "kobj"); + lwkt_token_init(&kobj_token, "kobj"); } SYSINIT(kobj, SI_BOOT1_LOCK, SI_ORDER_ANY, kobj_init_token, NULL); diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c index 4e6588ad91..23e9a3acab 100644 --- a/sys/kern/subr_rman.c +++ b/sys/kern/subr_rman.c @@ -91,7 +91,7 @@ rman_init(struct rman *rm) if (once == 0) { once = 1; TAILQ_INIT(&rman_head); - lwkt_token_init(&rman_tok, 1, "rman"); + lwkt_token_init(&rman_tok, "rman"); } if (rm->rm_type == RMAN_UNINIT) @@ -103,7 +103,7 @@ rman_init(struct rman *rm) rm->rm_slock = kmalloc(sizeof *rm->rm_slock, M_RMAN, M_NOWAIT); if (rm->rm_slock == NULL) return ENOMEM; - lwkt_token_init(rm->rm_slock, 1, "rmanslock"); + lwkt_token_init(rm->rm_slock, "rmanslock"); lwkt_gettoken(&rman_tok); TAILQ_INSERT_TAIL(&rman_head, rm, rm_link); diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index 8f70272152..dbbbb30aa4 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 mioctl_token = LWKT_TOKEN_MP_INITIALIZER(mioctl_token); +static struct lwkt_token mioctl_token = LWKT_TOKEN_INITIALIZER(mioctl_token); static int doselect(int nd, fd_set *in, fd_set *ou, fd_set *ex, struct timespec *ts, int *res); diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 7b64efc573..49de412730 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -350,8 +350,8 @@ pipe_create(struct pipe **cpipep) vfs_timestamp(&cpipe->pipe_ctime); cpipe->pipe_atime = cpipe->pipe_ctime; cpipe->pipe_mtime = cpipe->pipe_ctime; - lwkt_token_init(&cpipe->pipe_rlock, 1, "piper"); - lwkt_token_init(&cpipe->pipe_wlock, 1, "pipew"); + lwkt_token_init(&cpipe->pipe_rlock, "piper"); + lwkt_token_init(&cpipe->pipe_wlock, "pipew"); return (0); } diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 41d9655833..a3d137dd75 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -154,8 +154,8 @@ soalloc(int waitok) TAILQ_INIT(&so->so_aiojobq); TAILQ_INIT(&so->so_rcv.ssb_kq.ki_mlist); TAILQ_INIT(&so->so_snd.ssb_kq.ki_mlist); - lwkt_token_init(&so->so_rcv.ssb_token, 1, "rcvtok"); - lwkt_token_init(&so->so_snd.ssb_token, 1, "sndtok"); + lwkt_token_init(&so->so_rcv.ssb_token, "rcvtok"); + lwkt_token_init(&so->so_snd.ssb_token, "sndtok"); so->so_state = SS_NOFDREF; so->so_refs = 1; } diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 1cdc6cc139..a710462a5f 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -73,7 +73,7 @@ static u_int unp_count; static struct unp_head unp_shead, unp_dhead; -static struct lwkt_token unp_token = LWKT_TOKEN_MP_INITIALIZER(unp_token); +static struct lwkt_token unp_token = LWKT_TOKEN_INITIALIZER(unp_token); static int unp_defdiscard_nest; static unp_defdiscard_t unp_defdiscard_base; diff --git a/sys/kern/vfs_lock.c b/sys/kern/vfs_lock.c index 95501aa5d6..f02864dd1b 100644 --- a/sys/kern/vfs_lock.c +++ b/sys/kern/vfs_lock.c @@ -416,7 +416,7 @@ vnode_ctor(void *obj, void *private, int ocflags) { struct vnode *vp = obj; - lwkt_token_init(&vp->v_token, 1, "vnode"); + lwkt_token_init(&vp->v_token, "vnode"); lockinit(&vp->v_lock, "vnode", 0, 0); ccms_dataspace_init(&vp->v_ccms); TAILQ_INIT(&vp->v_namecache); diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 7f1be20ea3..916ccd7f29 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -136,9 +136,9 @@ static TAILQ_HEAD(,bio_ops) bio_ops_list = TAILQ_HEAD_INITIALIZER(bio_ops_list); void vfs_mount_init(void) { - lwkt_token_init(&mountlist_token, 1, "mntlist"); - lwkt_token_init(&mntvnode_token, 1, "mntvnode"); - lwkt_token_init(&mntid_token, 1, "mntid"); + lwkt_token_init(&mountlist_token, "mntlist"); + lwkt_token_init(&mntvnode_token, "mntvnode"); + lwkt_token_init(&mntid_token, "mntid"); TAILQ_INIT(&mountscan_list); TAILQ_INIT(&mntvnodescan_list); mount_init(&dummymount); @@ -322,7 +322,7 @@ void mount_init(struct mount *mp) { lockinit(&mp->mnt_lock, "vfslock", 0, 0); - lwkt_token_init(&mp->mnt_token, 1, "permnt"); + lwkt_token_init(&mp->mnt_token, "permnt"); TAILQ_INIT(&mp->mnt_nvnodelist); TAILQ_INIT(&mp->mnt_reservedvnlist); diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 575e870ed8..7d75d3fb45 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -194,7 +194,7 @@ vfs_subr_init(void) KvaSize / factor2); desiredvnodes = imax(desiredvnodes, maxproc * 8); - lwkt_token_init(&spechash_token, 1, "spechash"); + lwkt_token_init(&spechash_token, "spechash"); } /* diff --git a/sys/kern/vfs_sync.c b/sys/kern/vfs_sync.c index 892faac8ee..3573b9891a 100644 --- a/sys/kern/vfs_sync.c +++ b/sys/kern/vfs_sync.c @@ -123,7 +123,7 @@ vfs_sync_init(void) syncer_workitem_pending = hashinit(syncer_maxdelay, M_DEVBUF, &syncer_mask); syncer_maxdelay = syncer_mask + 1; - lwkt_token_init(&syncer_token, 1, "syncer"); + lwkt_token_init(&syncer_token, "syncer"); } /* diff --git a/sys/net/ip_mroute/ip_mroute.c b/sys/net/ip_mroute/ip_mroute.c index 8c2ac22e4d..b2a395971f 100644 --- a/sys/net/ip_mroute/ip_mroute.c +++ b/sys/net/ip_mroute/ip_mroute.c @@ -100,7 +100,7 @@ SYSCTL_OPAQUE(_net_inet_ip, OID_AUTO, viftable, CTLFLAG_RD, static u_char nexpire[MFCTBLSIZ]; -struct lwkt_token mroute_token = LWKT_TOKEN_MP_INITIALIZER(mroute_token); +struct lwkt_token mroute_token = LWKT_TOKEN_INITIALIZER(mroute_token); static struct callout expire_upcalls_ch; diff --git a/sys/net/pf/pf.c b/sys/net/pf/pf.c index 74e7c65af4..046eb9fd9e 100644 --- a/sys/net/pf/pf.c +++ b/sys/net/pf/pf.c @@ -104,7 +104,7 @@ extern int ip_optcopy(struct ip *, struct ip *); extern int debug_pfugidhack; -struct lwkt_token pf_token = LWKT_TOKEN_MP_INITIALIZER(pf_token); +struct lwkt_token pf_token = LWKT_TOKEN_INITIALIZER(pf_token); #define DPFPRINTF(n, x) if (pf_status.debug >= (n)) kprintf x diff --git a/sys/net/raw_usrreq.c b/sys/net/raw_usrreq.c index 19f6f39eab..a947233039 100644 --- a/sys/net/raw_usrreq.c +++ b/sys/net/raw_usrreq.c @@ -50,7 +50,7 @@ #include -static struct lwkt_token raw_token = LWKT_TOKEN_MP_INITIALIZER(raw_token); +static struct lwkt_token raw_token = LWKT_TOKEN_INITIALIZER(raw_token); /* * Initialize raw connection block q. diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 9d3190461b..281598775e 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -123,7 +123,7 @@ static u_long div_recvspace = DIVRCVQ; /* XXX sysctl ? */ static struct mbuf *ip_divert(struct mbuf *, int, int); -static struct lwkt_token div_token = LWKT_TOKEN_MP_INITIALIZER(div_token); +static struct lwkt_token div_token = LWKT_TOKEN_INITIALIZER(div_token); /* * Initialize divert connection block queue. diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index df8a407ec8..632dfff301 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -218,7 +218,7 @@ SYSCTL_INT(_net_inet_ip, OID_AUTO, dispatch_software_count, CTLFLAG_RD, SYSCTL_INT(_net_inet_ip, OID_AUTO, dispatch_recheck_count, CTLFLAG_RD, &ip_dispatch_recheck, 0, ""); -static struct lwkt_token ipq_token = LWKT_TOKEN_MP_INITIALIZER(ipq_token); +static struct lwkt_token ipq_token = LWKT_TOKEN_INITIALIZER(ipq_token); #ifdef DIAGNOSTIC static int ipprintfs = 0; diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index a824dcc33d..8671b6e379 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -86,7 +86,7 @@ struct inpcbinfo ripcbinfo; ip_fw_ctl_t *ip_fw_ctl_ptr; ip_dn_ctl_t *ip_dn_ctl_ptr; -static struct lwkt_token raw_token = LWKT_TOKEN_MP_INITIALIZER(raw_token); +static struct lwkt_token raw_token = LWKT_TOKEN_INITIALIZER(raw_token); /* diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 7b534cc716..b6e61b98f5 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -163,7 +163,7 @@ struct inpcbinfo tcbinfo[MAXCPU]; struct tcpcbackqhead tcpcbackq[MAXCPU]; static struct lwkt_token tcp_port_token = - LWKT_TOKEN_MP_INITIALIZER(tcp_port_token); + LWKT_TOKEN_INITIALIZER(tcp_port_token); int tcp_mssdflt = TCP_MSS; SYSCTL_INT(_net_inet_tcp, TCPCTL_MSSDFLT, mssdflt, CTLFLAG_RW, diff --git a/sys/netproto/key/key.c b/sys/netproto/key/key.c index bc56d34474..16e75c8eae 100644 --- a/sys/netproto/key/key.c +++ b/sys/netproto/key/key.c @@ -152,7 +152,7 @@ static LIST_HEAD(_acqtree, secacq) acqtree; /* acquiring list */ #endif static LIST_HEAD(_spacqtree, secspacq) spacqtree; /* SP acquiring list */ -struct lwkt_token key_token = LWKT_TOKEN_MP_INITIALIZER(key_token); +struct lwkt_token key_token = LWKT_TOKEN_INITIALIZER(key_token); struct key_cb key_cb; diff --git a/sys/platform/pc32/i386/busdma_machdep.c b/sys/platform/pc32/i386/busdma_machdep.c index bcca7698b1..7d3708fc96 100644 --- a/sys/platform/pc32/i386/busdma_machdep.c +++ b/sys/platform/pc32/i386/busdma_machdep.c @@ -139,7 +139,7 @@ struct bounce_zone { #endif static struct lwkt_token bounce_zone_tok = - LWKT_TOKEN_MP_INITIALIZER(bounce_zone_tok); + LWKT_TOKEN_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 4b486c7b84..187122e546 100644 --- a/sys/platform/pc64/x86_64/busdma_machdep.c +++ b/sys/platform/pc64/x86_64/busdma_machdep.c @@ -139,7 +139,7 @@ struct bounce_zone { #endif static struct lwkt_token bounce_zone_tok = - LWKT_TOKEN_MP_INITIALIZER(bounce_zone_token); + LWKT_TOKEN_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 3262e6c7d9..c79f9fbcbf 100644 --- a/sys/platform/vkernel/platform/busdma_machdep.c +++ b/sys/platform/vkernel/platform/busdma_machdep.c @@ -129,7 +129,7 @@ struct bounce_zone { #endif static struct lwkt_token bounce_zone_tok = - LWKT_TOKEN_MP_INITIALIZER(bounce_zone_token); + LWKT_TOKEN_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 59daef6049..6e8cfb4285 100644 --- a/sys/platform/vkernel64/platform/busdma_machdep.c +++ b/sys/platform/vkernel64/platform/busdma_machdep.c @@ -127,7 +127,7 @@ struct bounce_zone { #endif static struct lwkt_token bounce_zone_tok = - LWKT_TOKEN_MP_INITIALIZER(bounce_zone_token); + LWKT_TOKEN_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 21624871f7..139a229f49 100644 --- a/sys/sys/thread.h +++ b/sys/sys/thread.h @@ -108,14 +108,10 @@ typedef struct lwkt_token { const char *t_desc; /* Descriptive name */ } lwkt_token; -#define LWKT_TOKEN_MPSAFE 0x0001 - /* * Static initialization for a 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(name) \ +#define LWKT_TOKEN_INITIALIZER(name) \ { \ .t_ref = NULL, \ .t_flags = 0, \ @@ -124,15 +120,6 @@ typedef struct lwkt_token { .t_desc = #name \ } -#define LWKT_TOKEN_MP_INITIALIZER(name) \ -{ \ - .t_ref = NULL, \ - .t_flags = LWKT_TOKEN_MPSAFE, \ - .t_collisions = 0, \ - .t_collmask = 0, \ - .t_desc = #name \ -} - /* * Assert that a particular token is held */ @@ -453,7 +440,7 @@ extern int lwkt_cnttoken(lwkt_token_t, thread_t); extern int lwkt_getalltokens(thread_t); extern void lwkt_relalltokens(thread_t); extern void lwkt_drain_token_requests(void); -extern void lwkt_token_init(lwkt_token_t, int, const char *); +extern void lwkt_token_init(lwkt_token_t, const char *); extern void lwkt_token_uninit(lwkt_token_t); extern void lwkt_token_pool_init(void); diff --git a/sys/vfs/gnu/ext2fs/ext2_ihash.c b/sys/vfs/gnu/ext2fs/ext2_ihash.c index 2121f324eb..bc75eee3d8 100644 --- a/sys/vfs/gnu/ext2fs/ext2_ihash.c +++ b/sys/vfs/gnu/ext2fs/ext2_ihash.c @@ -69,7 +69,7 @@ ext2_ihashinit(void) ext2_ihash <<= 1; ext2_ihashtbl = kmalloc(sizeof(void *) * ext2_ihash, M_EXT2IHASH, M_WAITOK|M_ZERO); --ext2_ihash; - lwkt_token_init(&ext2_ihash_token, 1, "ext2ihash"); + lwkt_token_init(&ext2_ihash_token, "ext2ihash"); } int diff --git a/sys/vfs/hammer/hammer_vfsops.c b/sys/vfs/hammer/hammer_vfsops.c index b097b61952..fd1e7d1456 100644 --- a/sys/vfs/hammer/hammer_vfsops.c +++ b/sys/vfs/hammer/hammer_vfsops.c @@ -573,8 +573,8 @@ hammer_vfs_mount(struct mount *mp, char *mntpt, caddr_t data, RB_INIT(&hmp->lose_root); TAILQ_INIT(&hmp->iorun_list); - lwkt_token_init(&hmp->fs_token, 1, "hammerfs"); - lwkt_token_init(&hmp->io_token, 1, "hammerio"); + lwkt_token_init(&hmp->fs_token, "hammerfs"); + lwkt_token_init(&hmp->io_token, "hammerio"); lwkt_gettoken(&hmp->fs_token); diff --git a/sys/vfs/hpfs/hpfs_hash.c b/sys/vfs/hpfs/hpfs_hash.c index 428e1ffd96..5c4ba6a069 100644 --- a/sys/vfs/hpfs/hpfs_hash.c +++ b/sys/vfs/hpfs/hpfs_hash.c @@ -69,7 +69,7 @@ hpfs_hphashinit(void) lockinit (&hpfs_hphash_lock, "hpfs_hphashlock", 0, 0); hpfs_hphashtbl = HASHINIT(desiredvnodes, M_HPFSHASH, M_WAITOK, &hpfs_hphash); - lwkt_token_init(&hpfs_hphash_token, 1, "hpfsihash"); + lwkt_token_init(&hpfs_hphash_token, "hpfsihash"); } /* diff --git a/sys/vfs/hpfs/hpfs_vfsops.c b/sys/vfs/hpfs/hpfs_vfsops.c index 10b37cc9fd..d0da2536ad 100644 --- a/sys/vfs/hpfs/hpfs_vfsops.c +++ b/sys/vfs/hpfs/hpfs_vfsops.c @@ -500,7 +500,7 @@ hpfs_vget(struct mount *mp, struct vnode *dvp, ino_t ino, struct vnode **vpp) if (ino == (ino_t)hpmp->hpm_su.su_rootfno) vsetflags(vp, VROOT); - lwkt_token_init(&hp->h_interlock, 1, "hpfsilock"); + lwkt_token_init(&hp->h_interlock, "hpfsilock"); hp->h_flag = H_INVAL; hp->h_vp = vp; diff --git a/sys/vfs/isofs/cd9660/cd9660_node.c b/sys/vfs/isofs/cd9660/cd9660_node.c index 66f397d7c1..2fd3156aac 100644 --- a/sys/vfs/isofs/cd9660/cd9660_node.c +++ b/sys/vfs/isofs/cd9660/cd9660_node.c @@ -87,7 +87,7 @@ cd9660_init(struct vfsconf *vfsp) isohashtbl = kmalloc(sizeof(void *) * isohash, M_ISOFSMNT, M_WAITOK|M_ZERO); --isohash; - lwkt_token_init(&cd9660_ihash_token, 1, "cd9660ihash"); + lwkt_token_init(&cd9660_ihash_token, "cd9660ihash"); return (0); } diff --git a/sys/vfs/msdosfs/msdosfs_denode.c b/sys/vfs/msdosfs/msdosfs_denode.c index 5b82fa17be..1c254f76e6 100644 --- a/sys/vfs/msdosfs/msdosfs_denode.c +++ b/sys/vfs/msdosfs/msdosfs_denode.c @@ -122,7 +122,7 @@ msdosfs_init(struct vfsconf *vfsp) dehashtbl = kmalloc(sizeof(void *) * dehash, M_MSDOSFSMNT, M_WAITOK|M_ZERO); --dehash; - lwkt_token_init(&dehash_token, 1, "msdosihash"); + lwkt_token_init(&dehash_token, "msdosihash"); return (0); } diff --git a/sys/vfs/nfs/nfs_node.c b/sys/vfs/nfs/nfs_node.c index 6816eedd80..e88a8188fb 100644 --- a/sys/vfs/nfs/nfs_node.c +++ b/sys/vfs/nfs/nfs_node.c @@ -59,7 +59,7 @@ static vm_zone_t nfsnode_zone; static LIST_HEAD(nfsnodehashhead, nfsnode) *nfsnodehashtbl; static u_long nfsnodehash; -static lwkt_token nfsnhash_token = LWKT_TOKEN_MP_INITIALIZER(nfsnhash_token); +static lwkt_token nfsnhash_token = LWKT_TOKEN_INITIALIZER(nfsnhash_token); static struct lock nfsnhash_lock; #define TRUE 1 diff --git a/sys/vfs/nfs/nfs_srvcache.c b/sys/vfs/nfs/nfs_srvcache.c index 24ba8ac207..6c2a96fadd 100644 --- a/sys/vfs/nfs/nfs_srvcache.c +++ b/sys/vfs/nfs/nfs_srvcache.c @@ -73,7 +73,7 @@ static u_long nfsrvhash; #define NETFAMILY(rp) \ (((rp)->rc_flag & RC_INETADDR) ? AF_INET : AF_ISO) -struct lwkt_token srvcache_token = LWKT_TOKEN_MP_INITIALIZER(srvcache_token); +struct lwkt_token srvcache_token = LWKT_TOKEN_INITIALIZER(srvcache_token); /* * Static array that defines which nfs rpc's are nonidempotent diff --git a/sys/vfs/nfs/nfs_subs.c b/sys/vfs/nfs/nfs_subs.c index 065a06a657..6b12d6f996 100644 --- a/sys/vfs/nfs/nfs_subs.c +++ b/sys/vfs/nfs/nfs_subs.c @@ -103,7 +103,7 @@ int nfs_ticks; * Protect master lists only. Primary protection uses the per-mount * and per nfssvc_sock tokens. */ -struct lwkt_token nfs_token = LWKT_TOKEN_MP_INITIALIZER(unp_token); +struct lwkt_token nfs_token = LWKT_TOKEN_INITIALIZER(unp_token); static int nfs_pbuf_freecnt = -1; /* start out unlimited */ diff --git a/sys/vfs/nfs/nfs_syscalls.c b/sys/vfs/nfs/nfs_syscalls.c index 2198bd310f..de4c03ca33 100644 --- a/sys/vfs/nfs/nfs_syscalls.c +++ b/sys/vfs/nfs/nfs_syscalls.c @@ -412,7 +412,7 @@ nfssvc_addsock(struct file *fp, struct sockaddr *mynam, struct thread *td) mtx_init(&slp->ns_solock); STAILQ_INIT(&slp->ns_rec); TAILQ_INIT(&slp->ns_uidlruhead); - lwkt_token_init(&slp->ns_token, 1, "nfssrv_token"); + lwkt_token_init(&slp->ns_token, "nfssrv_token"); lwkt_gettoken(&nfs_token); nfsrv_slpref(slp); diff --git a/sys/vfs/nfs/nfs_vfsops.c b/sys/vfs/nfs/nfs_vfsops.c index dd28a36a4f..0e58e87704 100644 --- a/sys/vfs/nfs/nfs_vfsops.c +++ b/sys/vfs/nfs/nfs_vfsops.c @@ -1047,7 +1047,7 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam, TAILQ_INIT(&nmp->nm_reqtxq); TAILQ_INIT(&nmp->nm_reqrxq); mp->mnt_data = (qaddr_t)nmp; - lwkt_token_init(&nmp->nm_token, 1, "nfs_token"); + lwkt_token_init(&nmp->nm_token, "nfs_token"); } vfs_getnewfsid(mp); nmp->nm_mountp = mp; diff --git a/sys/vfs/ntfs/ntfs_ihash.c b/sys/vfs/ntfs/ntfs_ihash.c index 2ce78dbf0e..6c85f18d42 100644 --- a/sys/vfs/ntfs/ntfs_ihash.c +++ b/sys/vfs/ntfs/ntfs_ihash.c @@ -70,7 +70,7 @@ ntfs_nthashinit(void) lockinit(&ntfs_hashlock, "ntfs_nthashlock", 0, 0); ntfs_nthashtbl = HASHINIT(desiredvnodes, M_NTFSNTHASH, M_WAITOK, &ntfs_nthash); - lwkt_token_init(&ntfs_nthash_slock, 1, "ntfsihash"); + lwkt_token_init(&ntfs_nthash_slock, "ntfsihash"); } /* diff --git a/sys/vfs/udf/udf_vfsops.c b/sys/vfs/udf/udf_vfsops.c index 2a2909ae65..3fc68ac888 100644 --- a/sys/vfs/udf/udf_vfsops.c +++ b/sys/vfs/udf/udf_vfsops.c @@ -384,7 +384,7 @@ udf_mountfs(struct vnode *devvp, struct mount *mp) brelse(bp); bp = NULL; - lwkt_token_init(&udfmp->hash_token, 1, "udfihash"); + lwkt_token_init(&udfmp->hash_token, "udfihash"); udfmp->hashtbl = phashinit(UDF_HASHTBLSIZE, M_UDFMOUNT, &udfmp->hashsz); return(0); diff --git a/sys/vfs/ufs/ufs_ihash.c b/sys/vfs/ufs/ufs_ihash.c index 6ed2d7620a..277bcf2991 100644 --- a/sys/vfs/ufs/ufs_ihash.c +++ b/sys/vfs/ufs/ufs_ihash.c @@ -68,7 +68,7 @@ ufs_ihashinit(void) ihash <<= 1; ihashtbl = kmalloc(sizeof(void *) * ihash, M_UFSIHASH, M_WAITOK|M_ZERO); --ihash; - lwkt_token_init(&ufs_ihash_token, 1, "ufsihash"); + lwkt_token_init(&ufs_ihash_token, "ufsihash"); } int diff --git a/sys/vm/vm_vmspace.c b/sys/vm/vm_vmspace.c index eaa3e663bf..13e0b65a1b 100644 --- a/sys/vm/vm_vmspace.c +++ b/sys/vm/vm_vmspace.c @@ -97,7 +97,7 @@ sys_vmspace_create(struct vmspace_create_args *uap) lwkt_gettoken(&proc_token); if (p->p_vkernel == NULL) { vkp->refs = 1; - lwkt_token_init(&vkp->token, 1, "vkernel"); + lwkt_token_init(&vkp->token, "vkernel"); RB_INIT(&vkp->root); p->p_vkernel = vkp; } else {