Date: Thu, 10 Sep 2015 09:22:34 -0700 From: Justin Hibbits <jrh29@alumni.cwru.edu> To: Alexey Dokuchaev <danfe@freebsd.org> Cc: "Herminio Hernandez, Jr." <herminio.hernandezjr@gmail.com>, FreeBSD PowerPC ML <freebsd-ppc@freebsd.org> Subject: Re: 64-bit atomic ops on 32-bit CPU (again) Message-ID: <CAHSQbTDUjEE%2B1QJdnpx_DqCXZU7jcHCPnhtc8gd0ZVKF_Nb8yg@mail.gmail.com> In-Reply-To: <20150906072030.GA96996@FreeBSD.org> References: <CAJRA9dy=_QKTpgQreZtYjo8ZzW6QTJ6N=De0m9G6NW4DMCRnyg@mail.gmail.com> <CAHSQbTCDkRV1znAJxCiaW22kZTsfikrVUuYZnmOk4YFCU9kE0w@mail.gmail.com> <20150805185841.GA61013@FreeBSD.org> <CAHSQbTCfEOYwpE1JDaZJH9QymxNvg5T1RW1DV9bmX4Ngi%2B%2BTdA@mail.gmail.com> <20150906072030.GA96996@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Sep 6, 2015 at 12:20 AM, Alexey Dokuchaev <danfe@freebsd.org> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAHSQbTDUjEE%2B1QJdnpx_DqCXZU7jcHCPnhtc8gd0ZVKF_Nb8yg>