2001-10-24 21:41:07

by Martín Marqués

[permalink] [raw]
Subject: howto see shmem

I have found out that /proc/meminfo doesn't have (at least that's my first
thought) info about shared memory (it shows 0, even in heavy duty servers).
ipcs also shows nothing, so how can I see the amount of shared memory being
used?
Th mounted /dev/shmem device also shows 0 kb used (just in case).

Saludos... :-)

--
Porqu? usar una base de datos relacional cualquiera,
si pod?s usar PostgreSQL?
-----------------------------------------------------------------
Mart?n Marqu?s | [email protected]
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------


2001-10-24 23:21:11

by Marc Brekoo

[permalink] [raw]
Subject: Re: howto see shmem

Hi,

>I have found out that /proc/meminfo doesn't have (at least that's my first
>thought) info about shared memory (it shows 0, even in heavy duty servers).
>ipcs also shows nothing, so how can I see the amount of shared memory being
>used?
>Th mounted /dev/shmem device also shows 0 kb used (just in case).

AFAIK you can't. Calculating how much shared mem is used in 2.4.x is just
too hard...

Greets,
Marc.


2001-10-24 23:29:01

by Martín Marqués

[permalink] [raw]
Subject: Re: howto see shmem

On Mi? 24 Oct 2001 20:17, Marc Brekoo wrote:
> Hi,
>
> >I have found out that /proc/meminfo doesn't have (at least that's my first
> >thought) info about shared memory (it shows 0, even in heavy duty
> > servers). ipcs also shows nothing, so how can I see the amount of shared
> > memory being used?
> >Th mounted /dev/shmem device also shows 0 kb used (just in case).
>
> AFAIK you can't. Calculating how much shared mem is used in 2.4.x is just
> too hard...

And this:

# ipcs

------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 65536 nobody 600 46084 11 dest

------ Semaphore Arrays --------
key semid owner perms nsems status
0x00000000 393216 nobody 600 1

------ Message Queues --------
key msqid owner perms used-bytes messages

#

I can see 46084 bytes in shared memory used by the apache.
Am I wrong?

Saludos... :-)

--
Porqu? usar una base de datos relacional cualquiera,
si pod?s usar PostgreSQL?
-----------------------------------------------------------------
Mart?n Marqu?s | [email protected]
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------

2001-10-24 23:37:21

by Robert Love

[permalink] [raw]
Subject: Re: howto see shmem

On Wed, 2001-10-24 at 19:27, Mart?n Marqu?s wrote:
> [...]
> ------ Shared Memory Segments --------
> key shmid owner perms bytes nattch status
> 0x00000000 65536 nobody 600 46084 11 dest
> [...]
> I can see 46084 bytes in shared memory used by the apache.
> Am I wrong?

Nope. Applications know how much the are sharing because they can
easily see what region of memory is shared/mapped into their's.

The reason the kernel can't figure out the net shared memory is because
there is no simple way -- it has to add up the shared regions of all
applications, counting each shared segment only once. Too much work.

Robert Love

2001-10-24 23:40:51

by Martín Marqués

[permalink] [raw]
Subject: Re: howto see shmem

On Mi? 24 Oct 2001 20:37, Robert Love wrote:
> On Wed, 2001-10-24 at 19:27, Mart?n Marqu?s wrote:
> > [...]
> > ------ Shared Memory Segments --------
> > key shmid owner perms bytes nattch status
> > 0x00000000 65536 nobody 600 46084 11 dest
> > [...]
> > I can see 46084 bytes in shared memory used by the apache.
> > Am I wrong?
>
> Nope. Applications know how much the are sharing because they can
> easily see what region of memory is shared/mapped into their's.
>
> The reason the kernel can't figure out the net shared memory is because
> there is no simple way -- it has to add up the shared regions of all
> applications, counting each shared segment only once. Too much work.

Yes, I guess you are right. I just checked on and old RH server with a 2.2.x
kernel, and the sum of the shared memory of each application doesn't give me
the amount of shared memory that free gives me.

Thanks to all!

--
Porqu? usar una base de datos relacional cualquiera,
si pod?s usar PostgreSQL?
-----------------------------------------------------------------
Mart?n Marqu?s | [email protected]
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------

2001-10-24 23:48:31

by Mike Fedyk

[permalink] [raw]
Subject: Re: howto see shmem

On Wed, Oct 24, 2001 at 07:37:26PM -0400, Robert Love wrote:
> On Wed, 2001-10-24 at 19:27, Mart?n Marqu?s wrote:
> > [...]
> > ------ Shared Memory Segments --------
> > key shmid owner perms bytes nattch status
> > 0x00000000 65536 nobody 600 46084 11 dest
> > [...]
> > I can see 46084 bytes in shared memory used by the apache.
> > Am I wrong?
>
> Nope. Applications know how much the are sharing because they can
> easily see what region of memory is shared/mapped into their's.
>
> The reason the kernel can't figure out the net shared memory is because
> there is no simple way -- it has to add up the shared regions of all
> applications, counting each shared segment only once. Too much work.
>

Actually, if it's done in the COW code, you could quite possibly get most of
it right there...

Does anyone know of something that can make use of the shmem accting?

2001-10-25 13:34:43

by Christoph Rohland

[permalink] [raw]
Subject: Re: howto see shmem

Hi Mart?n,

On Wed, 24 Oct 2001, Mart?n Marqu?s wrote:
> I have found out that /proc/meminfo doesn't have (at least that's my
> first thought) info about shared memory (it shows 0, even in heavy
> duty servers).

/proc/meminfo did show the number of shared pages in the whole system
independent of SYSV shared mem.

In the -ac series it shows all shared anonymous pages
(i.e. tmpfs, shared mmap and SYSV shm pages)

> ipcs also shows nothing, so how can I see the amount
> of shared memory being used?

linux:~ # ipcs -mu

------ Shared Memory Status --------
segments allocated 3
pages allocated 256
pages resident 12
pages swapped 87
Swap performance: 0 attempts 0 successes

It shows it.

> Th mounted /dev/shmem device also shows 0 kb used (just in case).

That would only show the posix shared memory segments in this
instance.

Greetings
Christoph