Index: share/man/man9/srp_enter.9 =================================================================== RCS file: /cvs/src/share/man/man9/srp_enter.9,v retrieving revision 1.9 diff -u -p -r1.9 srp_enter.9 --- share/man/man9/srp_enter.9 12 Feb 2016 12:52:28 -0000 1.9 +++ share/man/man9/srp_enter.9 14 May 2016 12:38:58 -0000 @@ -45,11 +45,11 @@ .Ft void .Fn srp_update_locked "struct srp_gc *gc" "struct srp *p" "void *v" .Ft void * -.Fn srp_enter "struct srp *p" +.Fn srp_enter "struct srp_ref *sr" "struct srp *p" .Ft void * -.Fn srp_follow "struct srp *p" "void *v" "struct srp *n" +.Fn srp_follow "struct srp_ref *sr" "struct srp *n" .Ft void -.Fn srp_leave "struct srp *p" "void *v" +.Fn srp_leave "struct srp_ref *sr" .Ft void * .Fn srp_get_locked "struct srp *p" .Ft void @@ -118,39 +118,18 @@ call to .Fn srp_leave or .Fn srp_follow . +The reference is held via +.Fa sr . .Pp .Fn srp_follow -returns a pointer to the data structure referenced by the srp struct -.Fa n -that exists within the structure referenced by -.Fa v -via -.Fa p , -while releasing the reference to -.Fa v -and making it available for garbage collection. -It is equivalent to a call to -.Fn srp_enter -using -.Fa n -as an argument -followed by a call to -.Fn srp_leave -with -.Fa p -and -.Fa v -as arguments. -.Fn srp_follow -is necessary to correctly order the taking and releasing of SRP -critical sections in situations such as following a chain of data -structures linked with SRPs. +replaces the reference held via +.Fa sr +with a reference to the data structure represented by +.Fa p . .Pp .Fn srp_leave -releases the reference to -.Fa v -by the srp struct -.Fa p +releases the reference held via +.Fa sr and makes it available for garbage collection. .Pp .Fn srp_get_locked Index: share/man/man9/srpl_rc_init.9 =================================================================== RCS file: /cvs/src/share/man/man9/srpl_rc_init.9,v retrieving revision 1.9 diff -u -p -r1.9 srpl_rc_init.9 --- share/man/man9/srpl_rc_init.9 3 Dec 2015 16:27:32 -0000 1.9 +++ share/man/man9/srpl_rc_init.9 14 May 2016 12:38:58 -0000 @@ -38,7 +38,6 @@ .Nd singly-linked shared reference pointer list .Sh SYNOPSIS .In sys/srp.h -.Vt struct srpl_iter; .Vt struct srpl_rc; .Ft void .Fo "srpl_rc_init" @@ -51,16 +50,16 @@ .Fn SRPL_ENTRY "TYPE" .Fn "SRPL_INIT" "SRPL_HEAD *sl" .Ft void * -.Fn "SRPL_ENTER" "SRPL_HEAD *sl" "struct srpl_iter *si" +.Fn "SRPL_ENTER" "struct srp_ref *sr" "SRPL_HEAD *sl" .Ft void * -.Fn "SRPL_NEXT" "struct srpl_iter *si" "struct TYPE *listelm" "FIELDNAME" +.Fn "SRPL_NEXT" "struct srpl_ref *sr" "struct TYPE *listelm" "FIELDNAME" .Fo "SRPL_FOREACH" .Fa "VARNAME" +.Fa "struct srp_ref *sr" .Fa "SRPL_HEAD *sl" -.Fa "struct srpl_iter *si" .Fa "FIELDNAME" .Fc -.Fn "SRPL_LEAVE" "struct srpl_iter *si" "struct TYPE *listelm" +.Fn "SRPL_LEAVE" "struct srp_ref *sr" .Fn "SRPL_EMPTY_LOCKED" "SRPL_HEAD *sl" .Ft void * .Fn "SRPL_FIRST_LOCKED" "SRPL_HEAD *sl" @@ -139,9 +138,8 @@ to an empty state. .Fn SRPL_ENTER begins iterating over elements in the SRP list .Fa sl . -Local state necessary for iterating over the list is stored in the -SRP list iterator structure -.Fa si . +The reference to the list item is held via +.Fa sr . Every call to .Fn SRPL_ENTER must have a corresponding call to @@ -163,7 +161,8 @@ to release references to the list and it .Fn SRPL_LEAVE releases references to the list and its elements held by previous calls to -.Fn SRPL_ENTER +.Fn SRPL_ENTER , +.Fn SRPL_NEXT , or .Fn SRPL_FOREACH . .Pp Index: sys/kern/kern_srp.c =================================================================== RCS file: /cvs/src/sys/kern/kern_srp.c,v retrieving revision 1.7 diff -u -p -r1.7 kern_srp.c --- sys/kern/kern_srp.c 23 Nov 2015 10:56:19 -0000 1.7 +++ sys/kern/kern_srp.c 14 May 2016 12:38:59 -0000 @@ -207,7 +207,7 @@ srp_v(struct srp_hazard *hzrd, struct sr } void * -srp_enter(struct srp *srp) +srp_enter(struct srp_ref *sr, struct srp *srp) { struct cpu_info *ci = curcpu(); struct srp_hazard *hzrd; @@ -215,8 +215,10 @@ srp_enter(struct srp *srp) for (i = 0; i < nitems(ci->ci_srp_hazards); i++) { hzrd = &ci->ci_srp_hazards[i]; - if (hzrd->sh_p == NULL) + if (hzrd->sh_p == NULL) { + sr->hz = hzrd; return (srp_v(hzrd, srp)); + } } panic("%s: not enough srp hazard records", __func__); @@ -226,38 +228,15 @@ srp_enter(struct srp *srp) } void * -srp_follow(struct srp *srp, void *v, struct srp *next) +srp_follow(struct srp_ref *sr, struct srp *srp) { - struct cpu_info *ci = curcpu(); - struct srp_hazard *hzrd; - - hzrd = ci->ci_srp_hazards + nitems(ci->ci_srp_hazards); - while (hzrd-- != ci->ci_srp_hazards) { - if (hzrd->sh_p == srp && hzrd->sh_v == v) - return (srp_v(hzrd, next)); - } - - panic("%s: unexpected ref %p via %p", __func__, v, srp); - - /* NOTREACHED */ - return (NULL); + return (srp_v(sr->hz, srp)); } void -srp_leave(struct srp *srp, void *v) +srp_leave(struct srp_ref *sr) { - struct cpu_info *ci = curcpu(); - struct srp_hazard *hzrd; - - hzrd = ci->ci_srp_hazards + nitems(ci->ci_srp_hazards); - while (hzrd-- != ci->ci_srp_hazards) { - if (hzrd->sh_p == srp && hzrd->sh_v == v) { - hzrd->sh_p = NULL; - return; - } - } - - panic("%s: unexpected ref %p via %p", __func__, v, srp); + sr->hz->sh_p = NULL; } #else /* MULTIPROCESSOR */ Index: sys/net/bpf.c =================================================================== RCS file: /cvs/src/sys/net/bpf.c,v retrieving revision 1.140 diff -u -p -r1.140 bpf.c --- sys/net/bpf.c 10 May 2016 23:48:07 -0000 1.140 +++ sys/net/bpf.c 14 May 2016 12:38:59 -0000 @@ -1134,7 +1134,7 @@ int bpf_tap(caddr_t arg, u_char *pkt, u_int pktlen, u_int direction) { struct bpf_if *bp = (struct bpf_if *)arg; - struct srpl_iter i; + struct srp_ref sr; struct bpf_d *d; size_t slen; struct timeval tv; @@ -1144,20 +1144,21 @@ bpf_tap(caddr_t arg, u_char *pkt, u_int if (bp == NULL) return (0); - SRPL_FOREACH(d, &bp->bif_dlist, &i, bd_next) { + SRPL_FOREACH(d, &sr, &bp->bif_dlist, bd_next) { atomic_inc_long(&d->bd_rcount); if ((direction & d->bd_dirfilt) != 0) slen = 0; else { + struct srp_ref sr; struct bpf_program *bf; struct bpf_insn *fcode = NULL; - bf = srp_enter(&d->bd_rfilter); + bf = srp_enter(&sr, &d->bd_rfilter); if (bf != NULL) fcode = bf->bf_insns; slen = bpf_filter(fcode, pkt, pktlen, pktlen); - srp_leave(&d->bd_rfilter, bf); + srp_leave(&sr); } if (slen > 0) { @@ -1177,7 +1178,7 @@ bpf_tap(caddr_t arg, u_char *pkt, u_int drop = 1; } } - SRPL_LEAVE(&i, d); + SRPL_LEAVE(&sr); return (drop); } @@ -1214,7 +1215,7 @@ _bpf_mtap(caddr_t arg, const struct mbuf void (*cpfn)(const void *, void *, size_t)) { struct bpf_if *bp = (struct bpf_if *)arg; - struct srpl_iter i; + struct srp_ref sr; struct bpf_d *d; size_t pktlen, slen; const struct mbuf *m0; @@ -1236,20 +1237,21 @@ _bpf_mtap(caddr_t arg, const struct mbuf for (m0 = m; m0 != NULL; m0 = m0->m_next) pktlen += m0->m_len; - SRPL_FOREACH(d, &bp->bif_dlist, &i, bd_next) { + SRPL_FOREACH(d, &sr, &bp->bif_dlist, bd_next) { atomic_inc_long(&d->bd_rcount); if ((direction & d->bd_dirfilt) != 0) slen = 0; else { + struct srp_ref bsr; struct bpf_program *bf; struct bpf_insn *fcode = NULL; - bf = srp_enter(&d->bd_rfilter); + bf = srp_enter(&bsr, &d->bd_rfilter); if (bf != NULL) fcode = bf->bf_insns; slen = bpf_mfilter(fcode, m, pktlen); - srp_leave(&d->bd_rfilter, bf); + srp_leave(&bsr); } if (slen > 0) { @@ -1269,7 +1271,7 @@ _bpf_mtap(caddr_t arg, const struct mbuf drop = 1; } } - SRPL_LEAVE(&i, d); + SRPL_LEAVE(&sr); return (drop); } Index: sys/net/if.c =================================================================== RCS file: /cvs/src/sys/net/if.c,v retrieving revision 1.432 diff -u -p -r1.432 if.c --- sys/net/if.c 10 May 2016 06:37:15 -0000 1.432 +++ sys/net/if.c 14 May 2016 12:39:00 -0000 @@ -774,7 +774,7 @@ if_input_process(void *xmq) struct mbuf *m; struct ifnet *ifp; struct ifih *ifih; - struct srpl_iter i; + struct srp_ref sr; int s; mq_delist(mq, &ml); @@ -795,11 +795,11 @@ if_input_process(void *xmq) * Pass this mbuf to all input handlers of its * interface until it is consumed. */ - SRPL_FOREACH(ifih, &ifp->if_inputs, &i, ifih_next) { + SRPL_FOREACH(ifih, &sr, &ifp->if_inputs, ifih_next) { if ((*ifih->ifih_input)(ifp, m, ifih->ifih_cookie)) break; } - SRPL_LEAVE(&i, ifih); + SRPL_LEAVE(&sr); if (ifih == NULL) m_freem(m); @@ -1532,22 +1532,22 @@ ifunit(const char *name) struct ifnet * if_get(unsigned int index) { + struct srp_ref sr; struct if_map *if_map; struct srp *map; struct ifnet *ifp = NULL; - if_map = srp_enter(&if_idxmap.map); + if_map = srp_enter(&sr, &if_idxmap.map); if (index < if_map->limit) { map = (struct srp *)(if_map + 1); - ifp = srp_follow(&if_idxmap.map, if_map, &map[index]); + ifp = srp_follow(&sr, &map[index]); if (ifp != NULL) { KASSERT(ifp->if_index == index); if_ref(ifp); } - srp_leave(&map[index], ifp); - } else - srp_leave(&if_idxmap.map, if_map); + } + srp_leave(&sr); return (ifp); } Index: sys/net/if_vlan.c =================================================================== RCS file: /cvs/src/sys/net/if_vlan.c,v retrieving revision 1.164 diff -u -p -r1.164 if_vlan.c --- sys/net/if_vlan.c 19 Apr 2016 23:32:15 -0000 1.164 +++ sys/net/if_vlan.c 14 May 2016 12:39:00 -0000 @@ -335,7 +335,7 @@ vlan_input(struct ifnet *ifp0, struct mb struct ether_vlan_header *evl; struct ether_header *eh; SRPL_HEAD(, ifvlan) *tagh, *list; - struct srpl_iter i; + struct srp_ref sr; u_int tag; struct mbuf_list ml = MBUF_LIST_INITIALIZER(); u_int16_t etype; @@ -370,7 +370,7 @@ vlan_input(struct ifnet *ifp0, struct mb m->m_pkthdr.pf.prio = !m->m_pkthdr.pf.prio; list = &tagh[TAG_HASH(tag)]; - SRPL_FOREACH(ifv, list, &i, ifv_list) { + SRPL_FOREACH(ifv, &sr, list, ifv_list) { if (ifp0->if_index == ifv->ifv_ifp0 && tag == ifv->ifv_tag && etype == ifv->ifv_type) break; @@ -400,11 +400,11 @@ vlan_input(struct ifnet *ifp0, struct mb ml_enqueue(&ml, m); if_input(&ifv->ifv_if, &ml); - SRPL_LEAVE(&i, ifv); + SRPL_LEAVE(&sr); return (1); drop: - SRPL_LEAVE(&i, ifv); + SRPL_LEAVE(&sr); m_freem(m); return (1); } Index: sys/net/rtable.c =================================================================== RCS file: /cvs/src/sys/net/rtable.c,v retrieving revision 1.41 diff -u -p -r1.41 rtable.c --- sys/net/rtable.c 2 May 2016 22:15:49 -0000 1.41 +++ sys/net/rtable.c 14 May 2016 12:39:00 -0000 @@ -231,14 +231,15 @@ rtable_get(unsigned int rtableid, sa_fam { struct rtmap *map; void *tbl = NULL; + struct srp_ref sr; if (af >= nitems(af2idx) || af2idx[af] == 0) return (NULL); - map = srp_enter(&afmap[af2idx[af]]); + map = srp_enter(&sr, &afmap[af2idx[af]]); if (rtableid < map->limit) tbl = map->tbl[rtableid]; - srp_leave(&afmap[af2idx[af]], map); + srp_leave(&sr); return (tbl); } @@ -267,11 +268,12 @@ rtable_l2(unsigned int rtableid) { struct dommp *dmm; unsigned int rdomain = 0; + struct srp_ref sr; - dmm = srp_enter(&afmap[0]); + dmm = srp_enter(&sr, &afmap[0]); if (rtableid < dmm->limit) rdomain = dmm->dom[rtableid]; - srp_leave(&afmap[0], dmm); + srp_leave(&sr); return (rdomain); } @@ -534,7 +536,7 @@ rtable_lookup(unsigned int rtableid, str struct art_root *ar; struct art_node *an; struct rtentry *rt; - struct srpl_iter i; + struct srp_ref sr; uint8_t *addr; int plen; @@ -562,9 +564,9 @@ rtable_lookup(unsigned int rtableid, str } #ifdef SMALL_KERNEL - rt = SRPL_ENTER(&an->an_rtlist, &i); + rt = SRPL_ENTER(&sr, &an->an_rtlist); #else - SRPL_FOREACH(rt, &an->an_rtlist, &i, rt_next) { + SRPL_FOREACH(rt, &sr, &an->an_rtlist, rt_next) { if (prio != RTP_ANY && (rt->rt_priority & RTP_MASK) != (prio & RTP_MASK)) continue; @@ -577,13 +579,13 @@ rtable_lookup(unsigned int rtableid, str break; } if (rt == NULL) { - SRPL_LEAVE(&i, rt); + SRPL_LEAVE(&sr); return (NULL); } #endif /* SMALL_KERNEL */ rtref(rt); - SRPL_LEAVE(&i, rt); + SRPL_LEAVE(&sr); return (rt); } @@ -594,7 +596,7 @@ rtable_match(unsigned int rtableid, stru struct art_root *ar; struct art_node *an; struct rtentry *rt = NULL; - struct srpl_iter i; + struct srp_ref sr; uint8_t *addr; #ifndef SMALL_KERNEL int hash; @@ -611,33 +613,32 @@ rtable_match(unsigned int rtableid, stru if (an == NULL) goto out; - rt = SRPL_ENTER(&an->an_rtlist, &i); + rt = SRPL_ENTER(&sr, &an->an_rtlist); rtref(rt); - SRPL_LEAVE(&i, rt); + SRPL_LEAVE(&sr); #ifndef SMALL_KERNEL /* Gateway selection by Hash-Threshold (RFC 2992) */ if ((hash = rt_hash(rt, dst, src)) != -1) { struct rtentry *mrt; - struct srpl_iter i; int threshold, npaths = 0; KASSERT(hash <= 0xffff); - SRPL_FOREACH(mrt, &an->an_rtlist, &i, rt_next) { + SRPL_FOREACH(mrt, &sr, &an->an_rtlist, rt_next) { /* Only count nexthops with the same priority. */ if (mrt->rt_priority == rt->rt_priority) npaths++; } - SRPL_LEAVE(&i, mrt); + SRPL_LEAVE(&sr); threshold = (0xffff / npaths) + 1; - mrt = SRPL_ENTER(&an->an_rtlist, &i); + mrt = SRPL_ENTER(&sr, &an->an_rtlist); while (hash > threshold && mrt != NULL) { if (mrt->rt_priority == rt->rt_priority) hash -= threshold; - mrt = SRPL_NEXT(&i, mrt, rt_next); + mrt = SRPL_NEXT(&sr, mrt, rt_next); } if (mrt != NULL) { @@ -645,7 +646,7 @@ rtable_match(unsigned int rtableid, stru rtfree(rt); rt = mrt; } - SRPL_LEAVE(&i, mrt); + SRPL_LEAVE(&sr); } #endif /* SMALL_KERNEL */ out: Index: sys/netinet/ip_carp.c =================================================================== RCS file: /cvs/src/sys/netinet/ip_carp.c,v retrieving revision 1.288 diff -u -p -r1.288 ip_carp.c --- sys/netinet/ip_carp.c 13 Apr 2016 11:41:15 -0000 1.288 +++ sys/netinet/ip_carp.c 14 May 2016 12:39:00 -0000 @@ -1321,10 +1321,10 @@ carp_iamatch(struct ifnet *ifp, uint8_t { struct carp_softc *sc = ifp->if_softc; struct carp_vhost_entry *vhe; - struct srpl_iter i; + struct srp_ref sr; int match = 0; - vhe = SRPL_ENTER(&sc->carp_vhosts, &i); /* head */ + vhe = SRPL_ENTER(&sr, &sc->carp_vhosts); /* head */ if (vhe->state == MASTER) { if (sc->sc_balancing == CARP_BAL_IPSTEALTH || sc->sc_balancing == CARP_BAL_IP) { @@ -1333,7 +1333,7 @@ carp_iamatch(struct ifnet *ifp, uint8_t } match = 1; } - SRPL_LEAVE(&i, vhe); + SRPL_LEAVE(&sr); return (match); } @@ -1379,13 +1379,13 @@ int carp_vhe_match(struct carp_softc *sc, uint8_t *ena) { struct carp_vhost_entry *vhe; - struct srpl_iter i; + struct srp_ref sr; int match = 0; - vhe = SRPL_ENTER(&sc->carp_vhosts, &i); /* head */ + vhe = SRPL_ENTER(&sr, &sc->carp_vhosts); /* head */ match = (vhe->state == MASTER || sc->sc_balancing >= CARP_BAL_IP) && !memcmp(ena, sc->sc_ac.ac_enaddr, ETHER_ADDR_LEN); - SRPL_LEAVE(&i, vhe); + SRPL_LEAVE(&sr); return (match); } @@ -1397,13 +1397,13 @@ carp_input(struct ifnet *ifp0, struct mb struct mbuf_list ml = MBUF_LIST_INITIALIZER(); struct carp_if *cif; struct carp_softc *sc; - struct srpl_iter i; + struct srp_ref sr; eh = mtod(m, struct ether_header *); cif = (struct carp_if *)cookie; KASSERT(cif == (struct carp_if *)ifp0->if_carp); - SRPL_FOREACH(sc, &cif->vhif_vrs, &i, sc_list) { + SRPL_FOREACH(sc, &sr, &cif->vhif_vrs, sc_list) { if ((sc->sc_if.if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) continue; @@ -1413,7 +1413,7 @@ carp_input(struct ifnet *ifp0, struct mb } if (sc == NULL) { - SRPL_LEAVE(&i, sc); + SRPL_LEAVE(&sr); if (!ETHER_IS_MULTICAST(eh->ether_dhost)) return (0); @@ -1422,7 +1422,7 @@ carp_input(struct ifnet *ifp0, struct mb * XXX Should really check the list of multicast addresses * for each CARP interface _before_ copying. */ - SRPL_FOREACH(sc, &cif->vhif_vrs, &i, sc_list) { + SRPL_FOREACH(sc, &sr, &cif->vhif_vrs, sc_list) { struct mbuf *m0; if (!(sc->sc_if.if_flags & IFF_UP)) @@ -1437,7 +1437,7 @@ carp_input(struct ifnet *ifp0, struct mb if_input(&sc->sc_if, &ml); } - SRPL_LEAVE(&i, sc); + SRPL_LEAVE(&sr); return (0); } @@ -1451,7 +1451,7 @@ carp_input(struct ifnet *ifp0, struct mb ml_enqueue(&ml, m); if_input(&sc->sc_if, &ml); - SRPL_LEAVE(&i, sc); + SRPL_LEAVE(&sr); return (1); } @@ -2299,15 +2299,15 @@ carp_output(struct ifnet *ifp, struct mb { struct carp_softc *sc = ((struct carp_softc *)ifp->if_softc); struct carp_vhost_entry *vhe; - struct srpl_iter i; + struct srp_ref sr; int ismaster; KASSERT(sc->sc_carpdev != NULL); if (sc->cur_vhe == NULL) { - vhe = SRPL_ENTER(&sc->carp_vhosts, &i); /* head */ + vhe = SRPL_ENTER(&sr, &sc->carp_vhosts); /* head */ ismaster = (vhe->state == MASTER); - SRPL_LEAVE(&i, vhe); + SRPL_LEAVE(&sr); } else { ismaster = (sc->cur_vhe->state == MASTER); } Index: sys/sys/srp.h =================================================================== RCS file: /cvs/src/sys/sys/srp.h,v retrieving revision 1.7 diff -u -p -r1.7 srp.h --- sys/sys/srp.h 3 Dec 2015 16:27:32 -0000 1.7 +++ sys/sys/srp.h 14 May 2016 12:39:00 -0000 @@ -25,11 +25,16 @@ struct srp { void *ref; }; + struct srp_hazard { struct srp *sh_p; void *sh_v; }; +struct srp_ref { + struct srp_hazard *hz; +}; + #define SRP_HAZARD_NUM 16 struct srp_gc { @@ -53,14 +58,14 @@ void srp_init(struct srp *); #ifdef MULTIPROCESSOR void srp_update(struct srp_gc *, struct srp *, void *); -void *srp_enter(struct srp *); -void *srp_follow(struct srp *, void *, struct srp *); -void srp_leave(struct srp *, void *); +void *srp_enter(struct srp_ref *, struct srp *); +void *srp_follow(struct srp_ref *, struct srp *); +void srp_leave(struct srp_ref *); #else /* MULTIPROCESSOR */ #define srp_update(_gc, _srp, _v) srp_update_locked((_gc), (_srp), (_v)) -#define srp_enter(_srp) ((_srp)->ref) -#define srp_follow(_srp, _v, _next) ((_next)->ref) -#define srp_leave(_srp, _v) do { } while (0) +#define srp_enter(_sr, _srp) ((_sr)->hz = NULL, (_srp)->ref) +#define srp_follow(_sr, _srp) ((_srp)->ref) +#define srp_leave(_sr) do { } while (0) #endif /* MULTIPROCESSOR */ #endif /* _KERNEL */ @@ -79,10 +84,6 @@ struct srpl { struct srp sl_head; }; -struct srpl_iter { - struct srp * si_ref; -}; - #ifdef _KERNEL void srpl_rc_init(struct srpl_rc *, void (*)(void *, void *), @@ -99,41 +100,23 @@ struct { \ struct srp se_next; \ } -static inline void * -_srpl_enter(struct srpl *sl, struct srpl_iter *si) -{ - si->si_ref = &sl->sl_head; - return (srp_enter(si->si_ref)); -} - -static inline void * -_srpl_next(struct srpl_iter *si, void *elm, struct srp *nref) -{ - void *n; - - n = srp_follow(si->si_ref, elm, nref); - si->si_ref = nref; - - return (n); -} - -#define SRPL_ENTER(_sl, _si) _srpl_enter(_sl, _si) +#define SRPL_ENTER(_sr, _sl) srp_enter((_sr), &(_sl)->sl_head) -#define SRPL_NEXT(_si, _e, _ENTRY) \ - _srpl_next(_si, _e, &(_e)->_ENTRY.se_next) +#define SRPL_NEXT(_sr, _e, _ENTRY) \ + srp_follow((_sr), &(_e)->_ENTRY.se_next) -#define SRPL_FOREACH(_c, _sl, _si, _ENTRY) \ - for ((_c) = SRPL_ENTER(_sl, _si); \ +#define SRPL_FOREACH(_c, _sr, _sl, _ENTRY) \ + for ((_c) = SRPL_ENTER(_sr, _sl); \ (_c) != NULL; \ - (_c) = SRPL_NEXT(_si, _c, _ENTRY)) + (_c) = SRPL_NEXT(_sr, _c, _ENTRY)) -#define SRPL_LEAVE(_si, _c) srp_leave((_si)->si_ref, (_c)) +#define SRPL_LEAVE(_sr) srp_leave((_sr)) #define SRPL_EMPTY_LOCKED(_sl) (SRPL_FIRST_LOCKED(_sl) == NULL) #define SRPL_FIRST_LOCKED(_sl) srp_get_locked(&(_sl)->sl_head) #define SRPL_NEXT_LOCKED(_e, _ENTRY) \ - srp_get_locked(&(_e)->_ENTRY.se_next) + srp_get_locked(&(_e)->_ENTRY.se_next) #define SRPL_FOREACH_LOCKED(_c, _sl, _ENTRY) \ for ((_c) = SRPL_FIRST_LOCKED(_sl); \