Re: Our "fallback" atomics implementation doesn't actually work

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Our "fallback" atomics implementation doesn't actually work
Date: 2016-10-07 23:55:42
Message-ID: 20161007235542.ddhgknlhplldpvbn@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2016-10-07 17:12:45 -0400, Tom Lane wrote:
> Andres Freund <andres(at)anarazel(dot)de> writes:
> > It's not quite there yet, unfortunately. At the moment
> > pg_atomic_write_u32() is used for local buffers - and we explicitly
> > don't want that to be locking for temp buffers
> > (c.f. 6b93fcd149329d4ee7319561b30fc15a573c6307).
>
> Hm.
>
> > Don't really have a great idea about addressing this, besides either
> > just living with the lock for temp buffers on fallback platforms (which
> > don't have much of a practical relevance), or introduce
> > pg_atomic_unlocked_write_u32() or something. Neither seems great.
>
> Maybe we could hack it with some macro magic that would cause
> pg_atomic_write_u32() to be expanded into a simple assignment in
> localbuf.c only?

I think it's just as well to add a variant that's globally documented to
have no locking, there might be further uses of it. It's already in two
files (bufmgr.c/localbuf.c), and I don't think it's impossible that
further usages will crop up.

Patch that I intend to push soon-ish attached.

Andres

Attachment Content-Type Size
0001-Fix-fallback-implementation-of-pg_atomic_write_u32.patch text/x-patch 10.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-10-07 23:58:58 Re: [COMMITTERS] pgsql: Remove -Wl,-undefined,dynamic_lookup in macOS build.
Previous Message Robert Haas 2016-10-07 23:41:35 Re: [COMMITTERS] pgsql: Remove -Wl,-undefined,dynamic_lookup in macOS build.