Locking shared memory




I have a database application that creates some shared memory
segments to be used by several programs. Most of the shared memory is
used as a buffer pool for I/O so all the programs do not have to do
physical reads from the disk. Because shared memory is implemented on
Linux as a memory mapped file, it means the memory pages can get swapped
out if space is needed in memory and the page has not been accessed
recently.

Therefore I want to lock the shared memory pages in physical
memory so they can not be swapped. Currently I am allocating 2 256MB
shared memory segments for a total of 512MB. When I make the call to
mlock() for the first segment it returns with a good status. But mlock()
fails for the second segment with errno set to ENOMEM. Here is what the
man page for mlock() says about errors.

==================================================================
The mlock() and munlock() functions shall fail if:

ENOMEM Some or all of the address range specified by the addr and
len
arguments does not correspond to valid mapped pages
in the
address space of the process.

The mlock() function shall fail if:

EAGAIN Some or all of the memory identified by the operation
could not
be locked when the call was made.

The mlock() and munlock() functions may fail if:

EINVAL The addr argument is not a multiple of {PAGESIZE}.

The mlock() function may fail if:

ENOMEM Locking the pages mapped by the specified range would
exceed an
implementation-defined limit on the amount of memory that
the
process may lock.

EPERM The calling process does not have the appropriate
privilege to
perform the requested operation.
===================================================================
I do not think the error is because of the first explanation of ENOMEM
So my question is based on the second one.

Is there a kernel or vm parameter that controls how much memory a
process can utilize?

I am running RH AS 4.4 32 bit with 2GB of physical memory.

Thanks in advance:
Jack Allen

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list



Relevant Pages

  • [HPADM] RE: SHMMAX modification
    ... The problem is that you are using a 32bit version of Oracle ... will allow access to as much as 1750 megs of shared memory. ... the kernel maintains a map relating the virtual ...
    (HP-UX-Admin)
  • [HPADM] Re: HP-UX Oracle/ Shared memory segment question
    ... Does this mean if you set the shmax to be the same size of the memory on ... I read the article below about setting the shared memory for Oracle. ... HP-UX Shared Memory Segments for a 64-Bit Oracle Instance ...
    (HP-UX-Admin)
  • Re: OpenOffice does not start when Firefox open
    ... openings and closings of OO so I don't think it's a memory leak) ... you're left with this small sliver dividing up the remaining space. ... able to allocate a total amount of shared memory that is more than the ...
    (comp.os.os2.apps)
  • Re: Windows XP Shared memory woes
    ... What is shared memory? ... One of them is 3 gig in size. ... Using process explorer, and several of my own breadcrumbs, I find that I ...
    (microsoft.public.dotnet.framework.performance)
  • Re: [RFC v11][PATCH 05/13] Dump memory address space
    ... in one or more chunk: each chunk begins with a header that specifies ... should not change in the interim anyways, the locks protects us from, e.g. ... Even scanning over a large amount of memory, you aren't going to see a performance difference for accessing pgarr from an argument vs off of field in ctx which is going to be cache-hot. ... It is strictly necessary when it comes to handling shared memory. ...
    (Linux-Kernel)