From ae1d62cec88b407829500bdbda089bfdb1a116f8 Mon Sep 17 00:00:00 2001 From: trasz Date: Sun, 15 Nov 2015 12:10:51 +0000 Subject: Speed up rctl operation with large rulesets, by holding the lock during iteration instead of relocking it for each traversed rule. Reviewed by: mjg@ MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D4110 --- sys/kern/kern_loginclass.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sys/kern/kern_loginclass.c') diff --git a/sys/kern/kern_loginclass.c b/sys/kern/kern_loginclass.c index 62e6421..07ef910 100644 --- a/sys/kern/kern_loginclass.c +++ b/sys/kern/kern_loginclass.c @@ -234,12 +234,17 @@ sys_setloginclass(struct thread *td, struct setloginclass_args *uap) void loginclass_racct_foreach(void (*callback)(struct racct *racct, - void *arg2, void *arg3), void *arg2, void *arg3) + void *arg2, void *arg3), void (*pre)(void), void (*post)(void), + void *arg2, void *arg3) { struct loginclass *lc; rw_rlock(&loginclasses_lock); + if (pre != NULL) + (pre)(); LIST_FOREACH(lc, &loginclasses, lc_next) (callback)(lc->lc_racct, arg2, arg3); + if (post != NULL) + (post)(); rw_runlock(&loginclasses_lock); } -- cgit v1.1