From nobody Thu Aug 08 08:33:35 2024 X-Original-To: dev-commits-src-all@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 4WfgL73Ls2z5StMN; Thu, 08 Aug 2024 08:33:35 +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 4WfgL72q3Pz4pGH; Thu, 8 Aug 2024 08:33:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723106015; 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=gV8nAwozFyInOtDACbLwqLQTWAsrWT5yheXU8Jrby6Y=; b=tO32EJ+fo8TF3j8fvNYhpf8jT+SnRFm1L9P2xSRLq07RGl/lxtTI5mXbstn6720aIE54I+ hLX+wDx6WeCDeCbWkV8VV6FBrpmR43WPoE//nnbFh23WzV7JyZzimG1qXpKx3o1xM0TFIC nN5YVAXjwG7jM+Tzmo4tDSYRGMp5LlxOZK9mwphRsx40+gs1J+bdMpW1ESujfBuAfDfGaD 5zm3vP0UIHzn6n2+F/rf2z8pAriyPpkRhQeyxv3iD7elMvJZnxxmlqfKP7wEtoVCVlz9x8 HWqFiJ7iFnbaIiUE0oYRXphlS/BBoHDFs+JZY0ZA9sjsLy2eIxOB0F2S00n3Xw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723106015; a=rsa-sha256; cv=none; b=PGIgfwsUjPgtYV4HuwMJt4WCKr+eRh9l5S+9Q/S0GCGe18oQzLAwFPf11iA1ObztYm53aS jhESIb9Ko+hcXIjP0Kv1rrtxTTcw+fpVLTlF7WAUeMFq6y8sO7RQlElLJiwoQQNUeDv9Ix 3xhoF1Gsyc8/fxL+Dv9oRRUGbjeHH1vT+APRJOHmyZpkK+yeDibh25BLA+3ID5PM3CtM54 CDyRtl+clXDUAYav6udRDkZQfoC4sB+J6IAxRw7c6GVV83KJhwk59Xb3j3wPCAHxXnHyd5 +l+8RKaPhO6K2PVG3eW92fqHtF/wolHSdb5e72M0KpslQYYZ5+rTqM3Oj52f7A== 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=1723106015; 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=gV8nAwozFyInOtDACbLwqLQTWAsrWT5yheXU8Jrby6Y=; b=sWJqIcFPkszjI1F1YUv7cRxhTQj8D/bVrlb26qxYAzdld/G+W81SneLMtuK79bbpUwZy/m dXDxsuDv5r0IigKXm3Tx+TioTsHyz4QVuynE6n+2SKcggh7Tpc4ezBhpb5avinUzqDoqwD WjJ+oTuO5VqxS9EyO2iMMSZ0zNnn9Kcn8GDz0NwbCrBjC/q8eJ7shhz0MMtpf9GB1pIq39 rau4VpYN+f5sTZKQlic8UjvM0mJ1fppNCMXI8UJ0x8FS0bXmf/T4nyGo1s9r6Rf0P+K1Y8 1WmhfbuvklrQ0W/yAEDY3ixGVWLKbmlkFPnZGe/yoAz0et6y3vE3MWB+8khh4w== 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 4WfgL72QB5zQGF; Thu, 8 Aug 2024 08:33:35 +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 4788XZTP047013; Thu, 8 Aug 2024 08:33:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4788XZWg047010; Thu, 8 Aug 2024 08:33:35 GMT (envelope-from git) Date: Thu, 8 Aug 2024 08:33:35 GMT Message-Id: <202408080833.4788XZWg047010@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: 57cc80e6e39e - main - rangelocks: re-check that the lock is still in the cheating mode after setting of DRAINING failed List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: 57cc80e6e39ecef3d11b7a787866f79ad1310da1 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=57cc80e6e39ecef3d11b7a787866f79ad1310da1 commit 57cc80e6e39ecef3d11b7a787866f79ad1310da1 Author: Konstantin Belousov AuthorDate: 2024-08-07 15:02:24 +0000 Commit: Konstantin Belousov CommitDate: 2024-08-08 08:32:36 +0000 rangelocks: re-check that the lock is still in the cheating mode after setting of DRAINING failed Noted by: markj Tested by: dougm, pho (previous version) Reviewed by: markj (previous version), dougm Fixes: 9ef425e560a97cabd1862e803eeb48468f89de18 Sponsored by: The FreeBSD Foundation --- sys/kern/kern_rangelock.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sys/kern/kern_rangelock.c b/sys/kern/kern_rangelock.c index 89b52d2550f0..20b65778c06d 100644 --- a/sys/kern/kern_rangelock.c +++ b/sys/kern/kern_rangelock.c @@ -128,12 +128,13 @@ drain1: goto drain1; sleepq_release(&lock->head); /* Possibly forgive passed conflict */ - continue; + } else { + x = (v & ~RL_CHEAT_MASK) + RL_CHEAT_READER; + x |= RL_CHEAT_CHEATING; + if (atomic_fcmpset_acq_ptr(&lock->head, &v, + x) != 0) + break; } - x = (v & ~RL_CHEAT_MASK) + RL_CHEAT_READER; - x |= RL_CHEAT_CHEATING; - if (atomic_fcmpset_acq_ptr(&lock->head, &v, x) != 0) - break; if ((v & RL_CHEAT_CHEATING) == 0) return (false); if ((v & RL_CHEAT_DRAINING) != 0) @@ -156,11 +157,12 @@ drain1: goto drain1; sleepq_release(&lock->head); /* Possibly forgive passed conflict */ - continue; + } else { + x = RL_CHEAT_WLOCKED | RL_CHEAT_CHEATING; + if (atomic_fcmpset_acq_ptr(&lock->head, &v, + x) != 0) + break; } - x = RL_CHEAT_WLOCKED | RL_CHEAT_CHEATING; - if (atomic_fcmpset_acq_ptr(&lock->head, &v, x) != 0) - break; if ((v & RL_CHEAT_CHEATING) == 0) return (false); if ((v & RL_CHEAT_DRAINING) != 0)