Shmem allocated wrong for custom cumulative stats - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Shmem allocated wrong for custom cumulative stats
Date
Msg-id 04b04387-92f5-476c-90b0-4064e71c5f37@iki.fi
Whole thread Raw
Responses Re: Shmem allocated wrong for custom cumulative stats
List pgsql-hackers
There's only one call of ShmemAlloc() left in the tree outside shmem.c, 
in StatsShmemInit(), and that call doesn't look right:

The StatsShmemSize() function takes those allocations into account when 
it calculates the size for the "Shared Memory Stats" shmem area, but 
ShmemAlloc() doesn't use that reservation, it uses the general-purpose 
unreserved shmem that then shows up as "<anonymous>" in 
pg_shmem_allocations. The space reserved with ShmemRequestStruct() / 
ShmemInitStruct() goes unused.

We should use the memory that we've reserved, per the attached patch. 
One consequence of this fix though is that the allocations are now only 
MAXALIGNed, while ShmemAlloc() uses CACHELINEALIGN(). Not sure which we 
want.

I noticed this while working on the new shmem allocation functions, but 
it's a pre-existing bug in stable branches too.

- Heikki

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Adding locks statistics
Next
From: Daniel Gustafsson
Date:
Subject: Re: Changing the state of data checksums in a running cluster