From owner-freebsd-arch@FreeBSD.ORG Fri Mar 13 23:58:39 2015 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B6A008B5; Fri, 13 Mar 2015 23:58:39 +0000 (UTC) Received: from gold.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "gold.funkthat.com", Issuer "gold.funkthat.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 7697FAF3; Fri, 13 Mar 2015 23:58:39 +0000 (UTC) Received: from gold.funkthat.com (localhost [127.0.0.1]) by gold.funkthat.com (8.14.5/8.14.5) with ESMTP id t2DNwcjx077069 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 13 Mar 2015 16:58:38 -0700 (PDT) (envelope-from jmg@gold.funkthat.com) Received: (from jmg@localhost) by gold.funkthat.com (8.14.5/8.14.5/Submit) id t2DNwchf077068; Fri, 13 Mar 2015 16:58:38 -0700 (PDT) (envelope-from jmg) Date: Fri, 13 Mar 2015 16:58:38 -0700 From: John-Mark Gurney To: Mateusz Guzik Subject: Re: refcount_release_take_##lock Message-ID: <20150313235838.GM32288@funkthat.com> References: <20141025184448.GA19066@dft-labs.eu> <201410281413.58414.jhb@freebsd.org> <20141028193404.GB12014@dft-labs.eu> <201411111427.15407.jhb@freebsd.org> <20150313231607.GB32157@dft-labs.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150313231607.GB32157@dft-labs.eu> X-Operating-System: FreeBSD 9.1-PRERELEASE amd64 X-PGP-Fingerprint: 54BA 873B 6515 3F10 9E88 9322 9CB1 8F74 6D3F A396 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html X-TipJar: bitcoin:13Qmb6AeTgQecazTWph4XasEsP7nGRbAPE X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? User-Agent: Mutt/1.5.21 (2010-09-15) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (gold.funkthat.com [127.0.0.1]); Fri, 13 Mar 2015 16:58:38 -0700 (PDT) Cc: freebsd-arch@freebsd.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Mar 2015 23:58:39 -0000 Mateusz Guzik wrote this message on Sat, Mar 14, 2015 at 00:16 +0100: > In the meantime I wrote a new version. > > Apart from locking-handling primitives this time we get > refcount_acquire_if_greater and refcount_release_if_greater helpers. I don't see how this is of any benefit... The smallest value you can provide is 0, which means the only time a reference can be obtained is if the caller already has a reference. If you don't have a reference (making it =0), it isn't safe to call this function on the object, as it could be free'd, and point to a different type of object... Even if you implement type-safe memory (which we shouldn't use more of), it's less than ideal, since you then have to check if the object is the same object you were expecting, and need to release it... The release_if is even more problematic IMO... After reading the previous discussion, I really don't like this. If this gets approved (others override my objection), we need some docs that say this should never be used, and it's use is only in the unsafe case where the containing data structure does NOT have a reference to the object. -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."