From owner-freebsd-ppc@freebsd.org Thu Sep 10 16:22:35 2015 Return-Path: Delivered-To: freebsd-ppc@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 558DCA01300 for ; Thu, 10 Sep 2015 16:22:35 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: from mail-ig0-x22d.google.com (mail-ig0-x22d.google.com [IPv6:2607:f8b0:4001:c05::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 211FD1CC2; Thu, 10 Sep 2015 16:22:35 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: by igxx6 with SMTP id x6so19373807igx.1; Thu, 10 Sep 2015 09:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=njN2AQGFZdpWpdcZVSvaqLNcWq66IbdPn8H0AVoRtko=; b=UJI3noi4U4bocP9D765tpMlC4Xi16zIWwqQSxJ7Ev8b8wMX3YxDUylzSXUFu97EV2x +Wqavzw+QCNUzcmfGZPGrOHmmKxJ6cYzHt5JXu6VSvwlkpAMIlFQtOExOdYlnKNGnKX+ gg73xlTWXCmuweXWJzLXe8VcZT+Nhbh7LjCvh2LgDz7KyzZ8Cs9hrVYtx87exwX2rbyL /wBhSxti3cahN0GmVaki9jQfDvqsnvmOSiJEx5/G9Kv24zoZs9827TRuyB77MoDlrQX+ M36QBrVCLiO0lWcpAotzian6KLlbt8YGPrxHuksLLn4HIbS76hCcX1tiOwFddPHCYC34 g2rA== MIME-Version: 1.0 X-Received: by 10.50.142.1 with SMTP id rs1mr7784221igb.17.1441902154642; Thu, 10 Sep 2015 09:22:34 -0700 (PDT) Sender: chmeeedalf@gmail.com Received: by 10.36.58.83 with HTTP; Thu, 10 Sep 2015 09:22:34 -0700 (PDT) In-Reply-To: <20150906072030.GA96996@FreeBSD.org> References: <20150805185841.GA61013@FreeBSD.org> <20150906072030.GA96996@FreeBSD.org> Date: Thu, 10 Sep 2015 09:22:34 -0700 X-Google-Sender-Auth: U3UB5NIGCeqWAa8PtRK4Lc-F0-s Message-ID: Subject: Re: 64-bit atomic ops on 32-bit CPU (again) From: Justin Hibbits To: Alexey Dokuchaev Cc: "Herminio Hernandez, Jr." , FreeBSD PowerPC ML Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 16:22:35 -0000 On Sun, Sep 6, 2015 at 12:20 AM, Alexey Dokuchaev wrote: > On Wed, Aug 05, 2015 at 03:16:58PM -0700, Justin Hibbits wrote: >> I *think* all that's needed is atomic64 emulation. I had written a >> patch implementing them, [...] > > Hmm, perhaps you can help me here for a slightly different problem? I > need to do __sync_fetch_and_add() on int64_t argument (in userspace), > but linking fails due to undefined reference to `__sync_fetch_and_add_8' > (this is on 32-bit G4). > > I've googled a bit on how to implement a lock-free atomic 64-bit addition > on a 32-bit ppc (e.g. [1], [2]), it looks certainly doable (albeit would > require good understanding of CPU and cache details, and a manual ;-). > > What's my best bet here: implement local __sync_fetch_and_add_64() with > inline asm(), or teach gcc how to avoid __sync_fetch_and_add_8() linking > problem somehow? > > ./danfe > > [1] http://lists.apple.com/archives/perfoptimization-dev/2008/Nov/msg00012.html > [2] https://lists.freebsd.org/pipermail/freebsd-ppc/2008-September/003129.html Hmm, looking at it again, you could feasibly just augment sys/dev/drm2/drm_atomic.h to use different atomic64 primitives, rather than adding 64-bit atomic(9) support. As for the user space, I would add __sync_*_8() methods into contrib/compiler-rt/lib/builtins/ppc, a'la .../arm/sync*.S . - Justin