From nobody Wed Aug 21 15:21:44 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 4Wpqn45Y5rz5V2tr; Wed, 21 Aug 2024 15:21:44 +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 4Wpqn44HbMz4P72; Wed, 21 Aug 2024 15:21:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724253704; 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=3Ni3vIzGdGOGgiifSZr5D2I592QCUsF6AgD+6dgrvnU=; b=VKr8PcY24+2RoXILQ5NWj/M17mtjAcz8PG/AXbbijHkCfpZd3M3KbiNOuGqTunSIPRPyGu ZuDSpS/zlwZMN2Lc9U5kCN3PQGzny+ReMMGzsz57wBY+xMK3uwfrVJhN/iXUSBwcp5BXjC F4E1FlT1XBadoFBcYW/aLsc2JzsWRBdlX6rjS/UwG8SlCqdCnBDM+9mfSWfg1i4719xKLd CuLmRpbXehZhlRGKldmCx1hGpphx3pq/KOZCVHjW3im8p272pKs8c3MRcCTwOZYriW7JPh dxrnpvwhiwZvDMUEpYzJw22wf0tyFu2QJHpvYnaH7fhubj/eeZ1WgZPc/pPxxw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724253704; a=rsa-sha256; cv=none; b=LfTyvkX1ukcDCbmsAPmXCvYnaG6XErcZSjeNZPb3TVsr9CZ/2WWzKVmzhBkNUJDfTgQJfm 6HXk90Pj69N7jfREPhogpkKIJyQzyf2OYAFOiQqiH+RR1VTVpDkHq2dxcJAqnd2o7vIX2w YAROZWx22gh67BcoLY9SRw22dFw/i/V/IA56mlFiAebpbYZSZLJQvCXUCs5NeJekUz+keF 8yDc4aR0IP6oHhHbfxfMLrmrs5LY4fx7F96BMdE0VTW/UVs6b5NQT2hsGQJoYn9l4i1mrR Eg3cS4mcmisfuNwEMAiu00efRtfH4YF3tMGpWadVhWkKvex8JK/Xf5FIYnTy3w== 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=1724253704; 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=3Ni3vIzGdGOGgiifSZr5D2I592QCUsF6AgD+6dgrvnU=; b=tbzGdaoKK8ZQLbkqNHzJ1HFFjYcludx7Z2xE687G/Uiiss+YLC88ME6n7w5mh8+8RlxhDc uiSy8Wf8CnBO3kOGhw0/bo8f3hJNXTM0j5IOSkszgTHuGNXRWmmw60GJAl51+RnfCogwrk heftKpskTWSL28FH7F853xxMcRdMXfcveRSjc77Sq2h9Ru4XU56oef1ljxTunYRTD1sp7b KgHqB6+AOmUCPhwBcQ3nNfSIZb7p4MrFjGWB7c6T6I/1rQVYGeGzIKTdJkJrohZCIFcFhK r5dPJZznhfzi/+BF8H+EbPRRjInnt9PjxZk9qNeRBBJG+oPUKU5iHt6EJ+YgTw== 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 4Wpqn43fd7zpjk; Wed, 21 Aug 2024 15:21:44 +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 47LFLiFR067326; Wed, 21 Aug 2024 15:21:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47LFLiV9067323; Wed, 21 Aug 2024 15:21:44 GMT (envelope-from git) Date: Wed, 21 Aug 2024 15:21:44 GMT Message-Id: <202408211521.47LFLiV9067323@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: a725d61825f3 - main - rangelock: if CAS for removal failed, restart list iteration 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: a725d61825f32ea00d07a2064431a02fd640313a Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a725d61825f32ea00d07a2064431a02fd640313a commit a725d61825f32ea00d07a2064431a02fd640313a Author: Konstantin Belousov AuthorDate: 2024-08-16 05:45:52 +0000 Commit: Konstantin Belousov CommitDate: 2024-08-21 15:19:36 +0000 rangelock: if CAS for removal failed, restart list iteration Our next pointer is invalid and cannot be followed. Tested by: markj, pho Sponsored by: The FreeBSD Foundation --- sys/kern/kern_rangelock.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sys/kern/kern_rangelock.c b/sys/kern/kern_rangelock.c index 2667bf30fb6f..d9042f364737 100644 --- a/sys/kern/kern_rangelock.c +++ b/sys/kern/kern_rangelock.c @@ -539,6 +539,7 @@ rl_r_validate(struct rangelock *lock, struct rl_q_entry *e, bool trylock, { struct rl_q_entry *cur, *next, **prev; +again: prev = &e->rl_q_next; cur = rl_q_load(prev); MPASS(!rl_e_is_marked(cur)); /* nobody can unlock e yet */ @@ -551,9 +552,10 @@ rl_r_validate(struct rangelock *lock, struct rl_q_entry *e, bool trylock, if (rl_q_cas(prev, cur, next)) { cur->rl_q_free = *free; *free = cur; + cur = next; + continue; } - cur = next; - continue; + goto again; } if (rl_e_is_rlock(cur)) { prev = &cur->rl_q_next; @@ -583,6 +585,7 @@ rl_w_validate(struct rangelock *lock, struct rl_q_entry *e, { struct rl_q_entry *cur, *next, **prev; +again: prev = (struct rl_q_entry **)&lock->head; cur = rl_q_load(prev); MPASS(!rl_e_is_marked(cur)); /* head is not marked */ @@ -595,9 +598,10 @@ rl_w_validate(struct rangelock *lock, struct rl_q_entry *e, if (rl_q_cas(prev, cur, next)) { cur->rl_q_next = *free; *free = cur; + cur = next; + continue; } - cur = next; - continue; + goto again; } if (cur->rl_q_end <= e->rl_q_start) { prev = &cur->rl_q_next; @@ -642,9 +646,10 @@ again: #endif cur->rl_q_free = *free; *free = cur; + cur = next; + continue; } - cur = next; - continue; + goto again; } }