Index: sys/srp.h =================================================================== RCS file: /cvs/src/sys/sys/srp.h,v retrieving revision 1.7 diff -u -p -r1.7 srp.h --- sys/srp.h 3 Dec 2015 16:27:32 -0000 1.7 +++ sys/srp.h 7 Apr 2016 03:56:56 -0000 @@ -56,11 +56,13 @@ void srp_update(struct srp_gc *, struc void *srp_enter(struct srp *); void *srp_follow(struct srp *, void *, struct srp *); void srp_leave(struct srp *, void *); +void srp_wait(void *); #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_wait(_srp, _v) do { } while (0) #endif /* MULTIPROCESSOR */ #endif /* _KERNEL */ Index: 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 --- kern/kern_srp.c 23 Nov 2015 10:56:19 -0000 1.7 +++ kern/kern_srp.c 7 Apr 2016 03:56:56 -0000 @@ -260,6 +260,33 @@ srp_leave(struct srp *srp, void *v) panic("%s: unexpected ref %p via %p", __func__, v, srp); } +static inline int +srp_referenced(void *v) +{ + struct cpu_info *ci; + CPU_INFO_ITERATOR cii; + u_int i; + struct srp_hazard *hzrd; + + CPU_INFO_FOREACH(cii, ci) { + for (i = 0; i < nitems(ci->ci_srp_hazards); i++) { + hzrd = &ci->ci_srp_hazards[i]; + + if (hzrd->sh_v == v) + return (1); + } + } + + return (0); +} + +void +srp_wait(void *v) +{ + while (srp_referenced(v)) + tsleep(v, PWAIT, "srpwait", 1); +} + #else /* MULTIPROCESSOR */ void