Re: [HACKERS] shm_toc_lookup API
От
Andres Freund
Тема
Re: [HACKERS] shm_toc_lookup API
Дата
Msg-id
20170605190249.pd4jpet5y2xoheo2@alap3.anarazel.de
Ответ на
Re: [HACKERS] shm_toc_lookup API (Tom Lane)
Список
Дерево обсуждения
[HACKERS] shm_toc_lookup API Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] shm_toc_lookup API Robert Haas <robertmhaas@gmail.com>
Re: [HACKERS] shm_toc_lookup API Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] shm_toc_lookup API Robert Haas <robertmhaas@gmail.com>
Re: [HACKERS] shm_toc_lookup API Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] shm_toc_lookup API Andres Freund <andres@anarazel.de>
Re: [HACKERS] shm_toc_lookup API Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] shm_toc_lookup API Andres Freund <andres@anarazel.de>
On 2017-06-05 14:57:10 -0400, Tom Lane wrote: > > If it doesn't prevent both the hardware and the compiler from > > reordering, it's broken. See the comments for pg_read_barrier() in > > atomics.h. > > Meh. Without volatile, I think that the compiler would be within its > rights to elide the nentry local variable and re-fetch toc->toc_nentry > each time through the loop. I don't think that's true. Excerption from the docs of the macros: About pg_read_barrier()* A read barrier must act as a compiler barrier, and in addition must About pg_compiler_barrier():* A compiler barrier need not (and preferably should not) emit any actual* machine code, but must act as an optimization fence: the compiler must not* reorder loads or stores to main memory around the barrier. However, the* CPU may still reorder loads or stores at runtime, if the architecture's* memory model permits this.*/ Given that I don't see how it'd be permissible to elide the local variable. Are you saying that's permitted, or that our implementations don't guarantee that? - Andres
В списке pgsql-hackers по дате отправления