From nobody Wed Aug 28 14:49:56 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 4Wv6l93H00z52PgW; Wed, 28 Aug 2024 14:49:57 +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 4Wv6l90Mtvz4N9m; Wed, 28 Aug 2024 14:49:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724856597; 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=gCEjEgrVuoaUiZEMykZ3+T9Vb0ujTEzIpBll+YnTZGE=; b=YthkF+eubMXD8Uhn+7ne5KXWQkMiaJzLwDs7Q7lLpxi6/rj4V1CctpnR7utgHnrcAw390Y PNUDQFuxFfwjTjWjbhkcxZi1q04Hl506CzKrSjndyCa/wq09+zs09uTd9mjv1NTyUd54et j+rKC0muL027RO6JWPo2QP3yG8sd0PGILmscVC+7xrhoEWWuGBVC4AZkXzo5fvbj51Hkce Ovif1NXoQnUKC0xqdL/ivnV4rkwt3e3SOPVlwzjZJuadbK7qhwiMrMjHLpwV4pDy21zVHA TI1pqkOSeaDJi8Ah40WUE0HQjAeJNLZNHP+lswfMtgdLi53O0758zLMJkOWZnA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724856597; a=rsa-sha256; cv=none; b=YC+nYZvTwbLdDHviZCezkzIUHqlLhksNaRjua6Gy0/J3u+ykbhZzi7m6wtlaIhX+PEG7qH qNhq98K+os6KG5FiChSZT/bZTmIWqMRG3PA+1HNRDGJZBhz3m8zTlFUPL0HaOM0uERgTG1 R5pRj7sTnn6OeKMFy2V7CmIwJ7fKYDsBXCkZOIA5fhtP012I40NF/AIoWY74xrmjSuJUs/ gTgViKkVfPvhRFW1Xg0QXdXHBcnWtKsUnCqkQgGi7OOGr6y6Wv66vFECdP/5LqlF/MzCB5 XzuR0i7VaegZS0dp3twMgy4FdMHBWM9GbCQaXCjAx/ywlk5fPCLCW51eKYE0vA== 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=1724856597; 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=gCEjEgrVuoaUiZEMykZ3+T9Vb0ujTEzIpBll+YnTZGE=; b=vkIONiDmTbzjJis5Y3U+6Qd0tEv1TwpnwLYHlfmIOPursEOT+JuZJZI9ftxKZZPkqbiSZ5 xx9CaPfy5WsOIf5BSUY9348rzxIzEM1IPNcJTNVTAkVabo0v/389Lm6dKgzHlHcpxn0o9E a4KMLrc1QFvS0Sdlo2Gbpz0VFn/7aqyYBTy/Fqe45wF30ZZxBAwHc93EzShXynUri5qYz6 Za5ao6CmZerCGTOyq29X/5bFK97ZcCrEGClqjVOjyn0dVgxhkm8aMx2OiMuD5h5Jt2r6eS HeShqFxvo8LXPgjm3+nlKk5KhU7ClOb8GXSyguC44UJwVQIZ7kn7H4BKC/vGsw== 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 4Wv6l86j7tzdc8; Wed, 28 Aug 2024 14:49:56 +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 47SEnud7000038; Wed, 28 Aug 2024 14:49:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47SEnu78000035; Wed, 28 Aug 2024 14:49:56 GMT (envelope-from git) Date: Wed, 28 Aug 2024 14:49:56 GMT Message-Id: <202408281449.47SEnu78000035@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: 75447afca868 - main - rangelocks: extract the cheat mode drain code 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: 75447afca868f82f1c53c5be32dccd777813ec1a Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=75447afca868f82f1c53c5be32dccd777813ec1a commit 75447afca868f82f1c53c5be32dccd777813ec1a Author: Konstantin Belousov AuthorDate: 2024-08-27 21:32:51 +0000 Commit: Konstantin Belousov CommitDate: 2024-08-28 14:33:46 +0000 rangelocks: extract the cheat mode drain code Reviewed by: markj Tested by: lwhsu Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D46465 --- sys/kern/kern_rangelock.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/sys/kern/kern_rangelock.c b/sys/kern/kern_rangelock.c index 38449f71a8b7..0e62b91b4ee7 100644 --- a/sys/kern/kern_rangelock.c +++ b/sys/kern/kern_rangelock.c @@ -82,6 +82,24 @@ SYSCTL_INT(_debug, OID_AUTO, rangelock_cheat, CTLFLAG_RWTUN, #define RL_RET_CHEAT_RLOCKED 0x1100 #define RL_RET_CHEAT_WLOCKED 0x2200 +static void +rangelock_cheat_drain(struct rangelock *lock) +{ + uintptr_t v; + + DROP_GIANT(); + for (;;) { + v = (uintptr_t)atomic_load_ptr(&lock->head); + if ((v & RL_CHEAT_DRAINING) == 0) + break; + sleepq_add(&lock->head, NULL, "ranged1", 0, 0); + sleepq_wait(&lock->head, PRI_USER); + sleepq_lock(&lock->head); + } + sleepq_release(&lock->head); + PICKUP_GIANT(); +} + static bool rangelock_cheat_lock(struct rangelock *lock, int locktype, bool trylock, void **cookie) @@ -99,17 +117,7 @@ drain: } sleepq_lock(&lock->head); drain1: - DROP_GIANT(); - for (;;) { - v = (uintptr_t)atomic_load_ptr(&lock->head); - if ((v & RL_CHEAT_DRAINING) == 0) - break; - sleepq_add(&lock->head, NULL, "ranged1", 0, 0); - sleepq_wait(&lock->head, PRI_USER); - sleepq_lock(&lock->head); - } - sleepq_release(&lock->head); - PICKUP_GIANT(); + rangelock_cheat_drain(lock); return (false); }