[HACKERS] Double shared memory allocation for SLRU LWLocks - Mailing list pgsql-hackers

From Alexander Korotkov
Subject [HACKERS] Double shared memory allocation for SLRU LWLocks
Date
Msg-id CAPpHfdvd3cBpY4wEPZdUyY4bgRn0W6+8M3vtesX=M3goni2GDQ@mail.gmail.com
Whole thread Raw
Responses Re: [HACKERS] Double shared memory allocation for SLRU LWLocks
List pgsql-hackers
Hi, all!

It seems to me that we're allocating shared memory for SLRU lwlocks twice, unless I'm missing something.

SimpleLruShmemSize() calculates total SLRU shared memory size including lwlocks size.

SimpleLruInit() starts with line

shared = (SlruShared) ShmemInitStruct(name,
                                      SimpleLruShmemSize(nslots, nlsns),
                                      &found);

which allocates SLRU shared memory (LWLocks size is included because SimpleLruShmemSize() is used for size computation).

Following line allocates shared memory for LWLocks again:
shared->buffer_locks = (LWLockPadded *) ShmemAlloc(sizeof(LWLockPadded) * nslots);

Attached patch fixes that by removing extra ShmemAlloc for SLRU.

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachment

pgsql-hackers by date:

Previous
From: Ashutosh Bapat
Date:
Subject: Re: [HACKERS] paths in partitions of a dummy partitioned table
Next
From: Heikki Linnakangas
Date:
Subject: Re: [HACKERS] List of hostaddrs not supported