From owner-svn-src-all@freebsd.org Sun Feb 16 18:20:11 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9D41323D284; Sun, 16 Feb 2020 18:20:11 +0000 (UTC) (envelope-from mjg@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48LFlZ5xZLz433M; Sun, 16 Feb 2020 18:20:10 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A06C229E69; Sun, 16 Feb 2020 18:20:10 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 01GIKAoV018392; Sun, 16 Feb 2020 18:20:10 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 01GIKAKl018391; Sun, 16 Feb 2020 18:20:10 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202002161820.01GIKAKl018391@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 16 Feb 2020 18:20:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r358007 - in head/sys: kern sys X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys: kern sys X-SVN-Commit-Revision: 358007 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Feb 2020 18:20:11 -0000 Author: mjg Date: Sun Feb 16 18:20:09 2020 New Revision: 358007 URL: https://svnweb.freebsd.org/changeset/base/358007 Log: refcount: update comments about fencing when releasing counts after r357989 Requested by: kib Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D23719 Modified: head/sys/kern/kern_synch.c head/sys/sys/refcount.h Modified: head/sys/kern/kern_synch.c ============================================================================== --- head/sys/kern/kern_synch.c Sun Feb 16 17:55:32 2020 (r358006) +++ head/sys/kern/kern_synch.c Sun Feb 16 18:20:09 2020 (r358007) @@ -368,8 +368,8 @@ refcount_release_last(volatile u_int *count, u_int n, /* * Last reference. Signal the user to call the destructor. * - * Ensure that the destructor sees all updates. The fence_rel - * at the start of refcount_releasen synchronizes with this fence. + * Ensure that the destructor sees all updates. This synchronizes + * with release fences from all routines which drop the count. */ atomic_thread_fence_acq(); return (true); Modified: head/sys/sys/refcount.h ============================================================================== --- head/sys/sys/refcount.h Sun Feb 16 17:55:32 2020 (r358006) +++ head/sys/sys/refcount.h Sun Feb 16 18:20:09 2020 (r358007) @@ -119,6 +119,9 @@ refcount_releasen(volatile u_int *count, u_int n) KASSERT(n < REFCOUNT_SATURATION_VALUE / 2, ("refcount_releasen: n=%u too large", n)); + /* + * Paired with acquire fence in refcount_release_last. + */ atomic_thread_fence_rel(); old = atomic_fetchadd_int(count, -n); if (__predict_false(n >= REFCOUNT_COUNT(old) || @@ -198,6 +201,9 @@ refcount_release_if_gt(volatile u_int *count, u_int n) return (false); if (__predict_false(REFCOUNT_SATURATED(old))) return (true); + /* + * Paired with acquire fence in refcount_release_last. + */ if (atomic_fcmpset_rel_int(count, &old, old - 1)) return (true); }