Re: shared memory settings: SHMMAX and SHMALL

From: Matthew Rice <matt(at)starnix(dot)com>
To: Gregory Bittar <gbittar(at)iqa(dot)cc>
Cc: Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp>, pgsql-general(at)postgresql(dot)org
Subject: Re: shared memory settings: SHMMAX and SHMALL
Date: 2001-03-15 19:12:25
Message-ID: lvae6mvobq.fsf@sol.starnix.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Gregory Bittar <gbittar(at)iqa(dot)cc> writes:
> According to my /usr/include/asm/shmparam.h,
> SHMMAX (should be) <= (PAGE_SIZE << _SHM_IDX_BITS) = (4096 bytes << 15)
> = 128MB.

Mine is just:

#define SHMMAX 0x2000000

> I still don't see where to find the PAGE_SIZE value, although 4096 seems
> to be a general default out there.

man getpagesize

or

matt(at)sol:/usr/include[106]% egrep 'define PAGE_S(IZE|HIFT)' */* 2>/dev/null
asm/page.h:#define PAGE_SHIFT 12
asm/page.h:#define PAGE_SIZE (1UL << PAGE_SHIFT)
linux/a.out.h:#define PAGE_SIZE 0x400
sys/user.h:#define PAGE_SHIFT 12
sys/user.h:#define PAGE_SIZE (1UL << PAGE_SHIFT)

Although, 'man postmaster' says that it used 8k (or "whatever BLCKSZ
is set to in config.h") for it's shared memory buffers.

> Also according to my server's /usr/include/asm/shmparam.h,
> SHMALL should be = (1 << (_SHM_IDX_BITS + _SHM_ID_BITS)) = (1 <<
> (9+15)) = 16.

My 2.2.16 kernel has 15 and 7, BTW.

> I wonder why some people are setting SHMALL and SHMMAX to the same value
> when one is a measurement in pages and the other a measurement in

Pure laziness, I'm sure.

> bytes. Also, I thought that SHMMAX should be the max allotment in bytes
> per application, rather than the max shared by all applications. If I
> anticipate 10 postmasters, is it dangerous to set SHMMAX so high?

I'm not certain. I just used those numbers for a testing server (I actually
only told postmaster to use ~300MB).

Are you saying 10 postmasters or 10 backends?

Either way, you can set SHMMAX as high as you like. Just don't tell the
postmasters to try and use them all.

Actually, I just did this:

echo 11111111111 >/proc/sys/kernel/shmmax

and got:

cat /proc/sys/kernel/shmmax
-1773790777

Probably not good, long term :)

My kernel also wouldn't let me make SHMALL higher than 16M
--
matthew rice <matt(at)starnix(dot)com> starnix inc.
tollfree: 1-87-pro-linux thornhill, ontario, canada
http://www.starnix.com professional linux services & products

In response to

Browse pgsql-general by date

  From Date Subject
Next Message will trillich 2001-03-15 19:56:00 Re: Fw: Please Help
Previous Message keith 2001-03-15 18:24:43 ODBC