From nobody Wed Aug 21 15:21:39 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Wpqn00xfWz5V2p8; Wed, 21 Aug 2024 15:21:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Wpqn00P7jz4PBb; Wed, 21 Aug 2024 15:21:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724253700; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GWu/SJ+RDnuvYdLA/D1uYDLeNyhMhFR3G66iUEa7PyE=; b=kpQAGA1rvdL5iQNyj1CKW+hCifC4Kf1UYqvxxjy7QwrmTmcLKYq12wREOXDW/DEOHErQLN ZLgOSRm8wWnWQJui8vNWo/+dzdkLiTVAJhGvK6v5EFNd9bsiMxbaigNtsHH/FoqDOR0l2c zMSj0eXjf2FdfNWZLs6MXc583nli7FmBoUoEmGWG6E3nbM47HLadtmzzw3IX/UAFf9Hnud A1inYfnIBozKSRxddx2LASJvM8pkFEiRTD8l0uHaNNoxfSiTJnFKyw7iiE6AvAoTJriDdn ecweb1uZOi8qgY21iS8To6uQ3LNBp2GqERNR2NVe4cDoAnMNRNjzN7ehtGNxqQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724253700; a=rsa-sha256; cv=none; b=ZlMfQX1b/NPAjosuT6ZZK128rS0Jz1cbuVNpNQ6fsHqb6n9NeQJUFfWKxnp5e4UzKq00ev TqVSESb8kIeI6HorKWofyoyRo+tNNfGx/JvpdqJG6w/kS0BxEZ2hIA+0Qy+xP3GY624nlx 56ZeMWuKFKi6pVGkNRkW1Zqk8MYxsWUW4Cz/p6yBEqrzpI8Kfmdb6wCL549SFDqndoQnXv 6aHjjd2YMElL3C6uEzYnQrxACNwL5mkOv43agKaCRNwRbsT/XpXE+skW/whE6pufSWHoxA zsrw9ChJRmx6lxZQKFp19jG7DstpKe0JBxzfV5QdWeLpWpMjmEnVsjy914mBKw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724253700; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GWu/SJ+RDnuvYdLA/D1uYDLeNyhMhFR3G66iUEa7PyE=; b=AJ2Yg4rLck1xgCBNE6vPXOHd2VwPDX7DGrKCOk7gQ+GtdNM7h6njJQTKwCdSdIF1UG0S2Y z7PWaLjS2elkqbv4//PurYWH+Crng+mdC5ATwH3riW76TuxwnhjU6FG0psvkQBKzlCMV5t icIJ0StfenkpCJZmsKxlMnG5SU9kbfgQowK1QkaWgEvxGmslS8KnM+sZMegMF0og7Mxyrl xwoHgu7DyxU6vLucCu9g6xVMRu5O/YH7TGgmdgh+0oMkwFzi9DxEd5fKbvv77Mmr9DH6yx IKBSD3ztfSXbhNWGPSVY303ooQ9rSMwlhFpG+8AFX0mW5yZK3RRPY/J8cwG7Wg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Wpqn000x3zplg; Wed, 21 Aug 2024 15:21:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47LFLd38067078; Wed, 21 Aug 2024 15:21:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47LFLdDB067075; Wed, 21 Aug 2024 15:21:39 GMT (envelope-from git) Date: Wed, 21 Aug 2024 15:21:39 GMT Message-Id: <202408211521.47LFLdDB067075@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: a3f10d0882e1 - main - rangelocks: add rangelock_free_free() helper to free free list List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a3f10d0882e1aebef27698f1e0f94ffadade5935 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a3f10d0882e1aebef27698f1e0f94ffadade5935 commit a3f10d0882e1aebef27698f1e0f94ffadade5935 Author: Konstantin Belousov AuthorDate: 2024-08-12 03:48:32 +0000 Commit: Konstantin Belousov 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); }