From nobody Wed Sep 6 21:56:37 2023 X-Original-To: dev-commits-src-branches@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 4Rgx6F3kGFz4sJLM; Wed, 6 Sep 2023 21:56:37 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Rgx6F3JJwz3ZqW; Wed, 6 Sep 2023 21:56:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694037397; 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=BSclSMgf1/xPtvZvFq6Agdlkqzs+Y01b2mC1oQnDGR8=; b=AIKHydjAq9x1WHkDED0HGtfziww/OIQED4hpXnzj+jo1DBm2x9vytV81dyNQtx9kcPr6PE dkW/rkxcRisHR80DhDaRWjLc6dikIGc50A6CGja0dGOaIWs+BcjWOsn87I5BD+cXqCyzw8 WggwV60byFyzZKdaDrEmY9yNseSwHrEdAMeHyYfiWBLgO8K0zidgdB+JofA87nZovypf7j Y94W0G4cFjluL8Pn/juudwRnZjPafw4ZhqcsxavoGcTSDs8FRg743KuajVBEQ49wkPWtE4 6amgYkPaUdN0ppQ0ptdOSjT494LtHCAJfrmBi04RNpqVQ4AntRMCJ/vriGxAFw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694037397; a=rsa-sha256; cv=none; b=CQzYs60y3MO7bqhtoF7dnJYXptK1aCE3/n5C69XHj5FCw/4KT7rs/PY2VRlSzYueR02vkm PNcA2CUtfcNK/GaiAXBMsR9VCVpjg+vo3Q3bEyN2hjR2sPb+kL64ZqNEesn2r0AX3Vs8+r ronxT0mwGSo1qelCsY3sV8DY/oottI+PQSmMqQpOTQCpfyUao145f+OyTy+tMJDkE12EhM VleIVxp2xNQKkIvEj480cuZgKeq9W2eACyB4U6vMMPb9IvNJDivElnMFVNedRZqkJUUvjd Tf6GSX5zwVsHX2d6abOVE0F0+PkC+/4WqP5POLm45+8S8eIk5iZfccI3XUMVtQ== 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=1694037397; 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=BSclSMgf1/xPtvZvFq6Agdlkqzs+Y01b2mC1oQnDGR8=; b=O5QEaxrvvjFGwsw0wgmjKwak2v9DwGFbQIbIBUkrdcjg/lV13IbyP2+ZDNrDtUEudhs0+r nAWobum2zfNIaub5VRXD2/9gwaeYCdnpO/TxahjEHjd6yEJJYrYAXwNIBRFvB74kbAAUuw g1XTABz1Vtlwp0nyMeeb/YR63zMpR5HtHHWZSL/XTtEKeHo45nMfR1dj3TsKlFcJyBzMya iO2gN2wlKJIBkVmb2MttVXINz3hjobLQ4pYQ8DCa9mE+kiIdwGD8V+4MIOOwaXUyHV0rbs c9uFMLn+9qv7pWZXkx5C5d/ne8VeRrkaWfYivF48n3zcmFhGWBXNFwOqqu/pnQ== 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 4Rgx6F2PdwzZ4t; Wed, 6 Sep 2023 21:56:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 386LubNi022628; Wed, 6 Sep 2023 21:56:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 386Lub2k022625; Wed, 6 Sep 2023 21:56:37 GMT (envelope-from git) Date: Wed, 6 Sep 2023 21:56:37 GMT Message-Id: <202309062156.386Lub2k022625@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 5febbe8a14ca - stable/13 - aio: Fix a test and set race in aio_biowakeup. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5febbe8a14ca293f031236a77054f734b1ff5b7e Auto-Submitted: auto-generated The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=5febbe8a14ca293f031236a77054f734b1ff5b7e commit 5febbe8a14ca293f031236a77054f734b1ff5b7e Author: Keith Reynolds AuthorDate: 2023-02-15 18:56:39 +0000 Commit: John Baldwin CommitDate: 2023-09-06 21:56:09 +0000 aio: Fix a test and set race in aio_biowakeup. Use atomic_fetchadd in place of separate atomic_subtract / atomic_load. Reviewed by: markj Sponsored by: HPE TidalScale Differential Revision: https://reviews.freebsd.org/D38559 (cherry picked from commit 40734fc57ec0158690e9f03284229553b050b8ea) --- sys/kern/vfs_aio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index 5ffc0b31c2ae..7ca0848c5f46 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -2491,10 +2491,9 @@ aio_biowakeup(struct bio *bp) atomic_add_int(&job->outblock, nblks); else atomic_add_int(&job->inblock, nblks); - atomic_subtract_int(&job->nbio, 1); - if (atomic_load_int(&job->nbio) == 0) { + if (atomic_fetchadd_int(&job->nbio, -1) == 1) { if (atomic_load_int(&job->error)) aio_complete(job, -1, job->error); else