git: a3f10d0882e1 - main - rangelocks: add rangelock_free_free() helper to free free list
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 21 Aug 2024 15:21:39 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a3f10d0882e1aebef27698f1e0f94ffadade5935 commit a3f10d0882e1aebef27698f1e0f94ffadade5935 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-08-12 03:48:32 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-08-21 15:18:16 +0000 rangelocks: add rangelock_free_free() helper to free free list Tested by: markj, pho Sponsored by: The FreeBSD Foundation --- sys/kern/kern_rangelock.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/sys/kern/kern_rangelock.c b/sys/kern/kern_rangelock.c index 20b65778c06d..c2f1f2d762bb 100644 --- a/sys/kern/kern_rangelock.c +++ b/sys/kern/kern_rangelock.c @@ -288,6 +288,8 @@ struct rl_q_entry { static uma_zone_t rl_entry_zone; static smr_t rl_smr; +static void rangelock_free_free(struct rl_q_entry *free); + static void rangelock_sys_init(void) { @@ -392,6 +394,26 @@ rl_e_is_rlock(const struct rl_q_entry *e) return ((e->rl_q_flags & RL_LOCK_TYPE_MASK) == RL_LOCK_READ); } +static void +rangelock_free_free(struct rl_q_entry *free) +{ + struct rl_q_entry *x, *xp; + struct thread *td; + + td = curthread; + for (x = free; x != NULL; x = xp) { + MPASS(!rl_e_is_marked(x)); + xp = x->rl_q_free; + MPASS(!rl_e_is_marked(xp)); + if (td->td_rlqe == NULL) { + smr_synchronize(rl_smr); + td->td_rlqe = x; + } else { + uma_zfree_smr(rl_entry_zone, x); + } + } +} + static void rangelock_unlock_int(struct rangelock *lock, struct rl_q_entry *e) { @@ -623,14 +645,12 @@ static struct rl_q_entry * rangelock_lock_int(struct rangelock *lock, bool trylock, vm_ooffset_t start, vm_ooffset_t end, int locktype) { - struct rl_q_entry *e, *free, *x, *xp; - struct thread *td; + struct rl_q_entry *e, *free; void *cookie; enum RL_INSERT_RES res; if (rangelock_cheat_lock(lock, locktype, trylock, &cookie)) return (cookie); - td = curthread; for (res = RL_LOCK_RETRY; res == RL_LOCK_RETRY;) { free = NULL; e = rlqentry_alloc(start, end, locktype); @@ -643,17 +663,7 @@ rangelock_lock_int(struct rangelock *lock, bool trylock, vm_ooffset_t start, free = e; e = NULL; } - for (x = free; x != NULL; x = xp) { - MPASS(!rl_e_is_marked(x)); - xp = x->rl_q_free; - MPASS(!rl_e_is_marked(xp)); - if (td->td_rlqe == NULL) { - smr_synchronize(rl_smr); - td->td_rlqe = x; - } else { - uma_zfree_smr(rl_entry_zone, x); - } - } + rangelock_free_free(free); } return (e); }