[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

9680.0. "mlockall fails on shared memory" by NNTPD::"[email protected]" (Sri) Wed Apr 30 1997 12:37

Hi , One of my customers us is running Unix 4.0b, when he does mlockall after
shmget., shmat, for a large shared memory region above 128Meg or so, he gets
an error message that operation would block. On 3.x series unix., it  has no
problems. Also, mlocklall works just fine if it precedes shmat call. Any help
would be great. Process/IPC limits are fine.. Regards, Sri
[Posted by WWW Notes gateway]
T.RTitleUserPersonal
Name
DateLines
9680.1NNTPD::"[email protected]"Shashi MangalatWed Apr 30 1997 14:4910
>On 3.x series unix., it  has no problems.

Is that 3.2x or 3.0?  Total wired pages are calculated differently in 3.0.

What seems to happen is that the system has reached the wired page limit.
This is a percentage (defaults to 80%) of the pages that VM manages.  How
much memory is on the system?  What does vmstat show?

--shashi
[Posted by WWW Notes gateway]
9680.2Here are the stats:NNTPD::"[email protected]"SriThu May 01 1997 16:3972
Program works fine with 3.2x series OS, not 4.0b if the mlockall
issued after shmat (more than 128 Meg) call.

Our lab system (8400, 4Gig RAM) reproduced it as follows:

vm:
 vm-syswiredpercent = 80

# vmstat 4
Virtual Memory Statistics: (pagesize = 8192)
  procs    memory         pages                          intr        cpu
  r  w  u  act  free wire fault cow zero react pin pout  in  sy  cs  us sy  id
  4107 21   19K 476K  18K  203   13  148    0    9    0  17 604 192  50  1  49


The program itself is:
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdlib.h>
#include <sys/mman.h>

int main(void)
        {
        int mem_key;
        int mem_id;
        char *mem_address;
        /*----------------------------------------------*/
        /*              GENERATE A KEY                  */
        /*----------------------------------------------*/
        mem_key = ftok("/tmp",'v');
        if (mem_key < 0)
                {perror(" ftok trouble! \n"); exit(EXIT_FAILURE); }

        /*----------------------------------------------*/
        /*              CREATE SHARED MEMORY            */
        /*----------------------------------------------*/

        mem_id = shmget(mem_key,500004096, (IPC_CREAT | 0666));
        if (mem_id < 0)
                {perror(" shmget trouble! \n"); exit(EXIT_FAILURE); }

        /*----------------------------------------------*/
        /*              MLOCKALL ATTEMPT BEFORE shmat   */
        /*----------------------------------------------*/

        if (mlockall( MCL_CURRENT | MCL_FUTURE ) != 0 )
        {perror( "mlockall error before shmat:");}

        /*----------------------------------------------*/
        /*              GET ADDRESS OF SHARED MEMORY    */
        /*----------------------------------------------*/

        mem_address = shmat(mem_id,0,0);
        if (mem_address == 0)
                {perror(" shmat trouble! \n"); exit(EXIT_FAILURE); }

        /*----------------------------------------------*/
        /*              MLOCKALL ATTEMPT AFTER shmat    */
        /*----------------------------------------------*/

        if (mlockall( MCL_CURRENT | MCL_FUTURE ) != 0 )
        {perror( "mlockall error after shmat:");}


        }


-Sri

[Posted by WWW Notes gateway]
9680.3NNTPD::&quot;[email protected]&quot;Shashi MangalatFri May 02 1997 00:5110
Are you using SSM or gh-chunks?  Does it fail without either of them?  While
testing your sample program, I noticed a peculiar behaviour from SSM, in that
unaligned size fails to attach.  You might consider filing a QAR.  I'll send
you mail when I have more info.

The test for shmat() failure is incorrect in the test program.  You should be
checking for (char *) -1 instead of 0.

--shashi
[Posted by WWW Notes gateway]
9680.4NNTPD::&quot;[email protected]&quot;Shashi MangalatTue May 06 1997 18:3916
Sri,

The problem I ran into with attach was that I didn't have vm-vpagemax
set correctly.  Maybe you are running into that?

The unaligned size causes kernel internal vpage array to be allocated
on locking.  There is a per-process limit (defaults to 16k) on the
array size.  The size is calculated based on the segment size
rounded-up to an 8Meg boundary.  The #of vpage structures needed is
roundup_to_8M(size)/page_size.

Did you fix the test and tried it again?  Also try an 8Meg aligned size.

--shashi

[Posted by WWW Notes gateway]
9680.5vm-vpagemax did itNNTPD::&quot;[email protected]&quot;SriWed May 07 1997 17:087
Hi Shashi,

	Thanks for your suggestion on vm-vpagemax. It did it.

Regards
-Sri
[Posted by WWW Notes gateway]