Re: Add palloc_aligned() to allow arbitrary power of 2 memory alignment

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Add palloc_aligned() to allow arbitrary power of 2 memory alignment
Дата
Msg-id CAApHDvqYz4VkdTs41SVVYJUq=xUSDjL445RcMzyuivwgzcty7g@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Add palloc_aligned() to allow arbitrary power of 2 memory alignment  (John Naylor <john.naylor@enterprisedb.com>)
Список pgsql-hackers
On Mon, 14 Nov 2022 at 15:25, John Naylor <john.naylor@enterprisedb.com> wrote:
> - Assert((char *) chunk > (char *) block);
> + Assert((char *) chunk >= (char *) block);
>
> Is this related or independent?

It's related.  Because the code is doing:

MemoryChunkSetHdrMask(alignedchunk, unaligned, alignto,
  MCTX_ALIGNED_REDIRECT_ID);

Here the blockoffset gets set to the difference between alignedchunk
and unaligned. Typically when we call MemoryChunkSetHdrMask, the
blockoffset is always the difference between the block and
MemoryChunk, which is never 0 due to the block header fields.  Here it
can be the same pointer when the redirection MemoryChunk is stored on
the first byte of the palloc'd address.  This can happen if the
address returned by palloc + sizeof(MemoryChunk) is aligned to what we
need already.

David



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Pavel Borisov
Дата:
Сообщение: Re: Unit tests for SLRU
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: Assertion failure in SnapBuildInitialSnapshot()