| From: | Gregory Bittar <gbittar(at)iqa(dot)cc> | 
|---|---|
| To: | Matthew Rice <matt(at)starnix(dot)com>, pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: shared memory settings: SHMMAX and SHMALL | 
| Date: | 2001-03-15 15:02:42 | 
| Message-ID: | 3AB0D992.717C70C1@iqa.cc | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
Matthew Rice wrote:
> Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp> writes:
> > > If I have 512MB of memory in my system, excluding swap
> > > space,
> > > what values do I want to set for SHMMAX and SHMALL?
> >
> > That depeneds on your kernel implemetaion and hardware. I found
> > followings in /usr/include/asm/shmparam.h on my Linux box.
> >
> > here PAGE_SIZE == 4096. So I guess we cannot have more than 128MB for
> > the shared memory on this platform if above comment is correct.
>
> You can recompile the kernel with the new defaults or just change them on
> a live system (kernel 2.2.x or higher) with something like:
>
>    echo 419430400 >/proc/sys/kernel/shmall
>    echo 419430400 >/proc/sys/kernel/shmmax
>
> You pick the numbers, of course.
Two questions jump to my mind.
1) You've allocated 419430400 bytes (400MB) to shared memory.  If I am
planning on running, e.g., 10 postmasters, wouldn't I want to set SHMMAX to
40MB  (400MB divided by 10), since SHMMAX is the max shared memory allotment
per running application?
2) I've read that SHMALL = (SHMMAX/PAGE_SIZE*SHMMNI).   I haven't been able
to determine SHMMNI's value on my system.  I am inferring that PAGE_SIZE = 1
and SHMMNI = 4096 based simply on other users' comments and my
/usr/include/asm/shmparam.h (reprinted below) which, frankly, I am not very
good at reading.   Anyway, if this is the case, isn't it likely that
SHMALL is less than SHMMAX?
/*
 * Format of a swap-entry for shared memory pages currently out in
 * swap space (see also mm/swap.c).
 *
 * SWP_TYPE = SHM_SWP_TYPE
 * SWP_OFFSET is used as follows:
 *
 *  bits 0..6 : id of shared memory segment page belongs to (SHM_ID)
 *  bits 7..21: index of page within shared memory segment (SHM_IDX)
 *              (actually fewer bits get used since SHMMAX is so low)
 */
/*
 * Keep _SHM_ID_BITS as low as possible since SHMMNI depends on it and
 * there is a static array of size SHMMNI.
 */
#define _SHM_ID_BITS    9
#define SHM_ID_MASK     ((1<<_SHM_ID_BITS)-1)
#define SHM_IDX_SHIFT   (_SHM_ID_BITS)
#define _SHM_IDX_BITS   15
#define SHM_IDX_MASK    ((1<<_SHM_IDX_BITS)-1)
/*
 * _SHM_ID_BITS + _SHM_IDX_BITS must be <= 24 on the i386 and
 * SHMMAX <= (PAGE_SIZE << _SHM_IDX_BITS).
 */
#define SHMMAX 0x2000000                /* max shared seg size (bytes) */
/* Try not to change the default shipped SHMMAX - people rely on it */
#define SHMMIN 1 /* really PAGE_SIZE */ /* min shared seg size (bytes) */
#define SHMMNI (1<<_SHM_ID_BITS)        /* max num of segs system wide */
#define SHMALL                          /* max shm system wide (pages) */ \
        (1<<(_SHM_IDX_BITS+_SHM_ID_BITS))
#define SHMLBA PAGE_SIZE                /* attach addr a multiple of this */
#define SHMSEG SHMMNI                   /* max shared segs per process */
#endif /* _ASMI386_SHMPARAM_H */
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Gregory Bittar | 2001-03-15 15:43:05 | Re: shared memory settings: SHMMAX and SHMALL | 
| Previous Message | lsmith | 2001-03-15 14:20:40 | getting the right version of cygwin for windows2000 install |