SUMMARY: Marking down memory on a Sparc

From: Richard C. Mills (rmills@ccd.harris.com)
Date: Thu Jul 27 1995 - 09:52:25 CDT


Hello All,

My original question:

> We currently have a situation where we need to mark down memory on a Sparc
> 10. On our IBMs we're able to do this via the 'rmss' command.
>
> (From the rmss MAN Page)
> "PURPOSE
>
> Simulate an RS/6000 with various sizes of real memory, without
> having to extract and replace memory boards. By running an
> application at several memory sizes and collecting performance
> statistics at each memory size, one can determine how much
> memory an RS/6000 must have to run the application with
> acceptable performance. NOTE: The rmss user's guide (reference
> it by typing "man rmss.ug") contains critical information that
> will help you to use rmss more effectively. Please read it
> thoroughly."
>
> Is there anyway to do something similiar on a Sun? Pulling memory out
> physically is not an option for us.

I got a few responses, but most of them were for SunOS4.1.x, and we're
running Solaris 2.3 here. I should have been more specific (sorry). The
solution came from an engineer in-house. Here it is, enjoy!

---------------BEGIN------------------------------------------------------
#include <time.h>
#include <sys/lock.h>
#include <stdio.h>
 
int main (int argc, char *argv[])
 
/*
PURPOSE: This process is used to simulate a reduction in
usable physical memory.
 
DESCRIPTION: This process allocate a large chunk of memory
and then locks itself and its allocated memory into
physical memory via the plock() function.
 
RETURNS: Not applicable.
*/
/*STOP MAIN*/
 
{
extern int optind; /* used with getopt */
extern char *optarg; /* used with getopt */
 
char *buf_p; /* pointer to allocated memory */
int one_meg = 1024 * 1024; /* one meg */
int meg = 1; /* the number of megs to allocate */
int c; /* input option character */
int lock_b = 0; /* process lock flag */
int slptime = 1; /* time, in minutes, to sleep */
 
/*
** Get all the command line options specified.
*/
while ((c = getopt (argc,argv,"-m:s:lh?")) != EOF)
    {
    switch (c)
        {
        case 'm': meg=atoi (optarg); break;
        case 's': slptime=atoi (optarg); break;
 
        case 'l': lock_b = 1; break;
        case 'h':
        case '?':
            printf (
                "plock: This process is used to allocate a block\n" );
            printf ( "of memory and optionally lock the process\n" );
            printf ( "and its allocated memory into physical memory\n\n");
            printf ( "Usage: plock [-m meg] [-s min] [-l] [-h]\n");
            printf ( "-m meg specifies the megabytes to allocate,\n");
            printf ( "-s min specifies the minutes to sleep, and\n" );
            printf ( "-l indicates that the plock() function should be called.\n");
            printf ( "Defaults are -m 1 -s 1\n\n");
            printf ( "***Note: This process must have root access to call plock().\n");
            exit ( 0 );
            break;
 
        default:
            fprintf(stderr,"Invalid Argument");
            exit ( 0 );
            break;
        }
    }
 
/*
** allocate the specified amount of memory and make sure
** we got it.
*/
buf_p = (char *) malloc ( meg * one_meg );
 
if ( (char *)NULL == buf_p )
    {
    fprintf ( stderr, "Can't allocate %d bytes!\n" , meg * one_meg );
    exit ( 0 );
    }
 
/*
** if we specified we want to lock this into memory do so
** and test for success.
*/
if ( lock_b )
    {
    if ( plock ( PROCLOCK ) != 0 )
        {
        fprintf(stderr, "Can't lock process into memory\n" );
        exit ( 0 );
        }
    }
 
/*
** good night...
*/
sleep ( slptime * 60 );
 
exit ( 0 );
}
---------------END--------------------------------------------------------

However, for those interested in the SunOS4.1.x solution:

From: Kevin.Sheehan@uniq.com.au (Kevin Sheehan {Consulting Poster Child})

You'll probably get told about chill - don't use it in anger, as it has
other side effects. Easiest way is to patch the "physmem" variable in
in the kernel to subtract pages from the pool.

Best done and then rebooted...

                l & h,
                kev

From: Claus Assmann <ca@mine.informatik.uni-kiel.de>

Maybe you can try chill ?

CHILL(8) MAINTENANCE COMMANDS CHILL(8)

NAME
     chill - remove useful pages from the virtual memory cache

SYNOPSIS
     chill [ -c cycles ] [ -f factor ] [ -m memsize ]

DESCRIPTION
     chill is a command designed to cool off the system by remov-
     ing any useful (to a process) pages from the virtual memory
     cache. chill does this by creating a large pool of private
     pages, and then cycling through the pool, dirtying every
     page. Currently, this forces chill's pages to be hot, which
     forces out all the other (non-locked) pages in the system.
     Then when chill exits, all its private pages are put on the
     free list, leaving no useful pages in memory.

     With no options specified, the size of the pool created by
     chill is twice the amount of pageable memory, and it is
     cycled through just once. This seems to give correct
     results with minimal overhead.

     However, the size of the pool may be explicitly specified as
     memsize, or as factor times the amount of pageable memory.
     memsize overrides the factor specification. The cycle count
     may be specified as cycles.

OPTIONS
     -c cycles
          Set the cycle count to cycles. The default is 1.

     -f factor
          Set the expansion factor to factor. The default is 2.

     -m memsize
          Set the memory size to memsize. The default is
          unspecified, which means that factor times the amount
          of pageable memory will be used.

BUGS
     chill is dependent on implementation details which are sub-
     ject to change.

But it doesn't look exactly like what you need...

Regards,

Claus Assmann

From: sysadm@its.brooklyn.cuny.edu (Sun System Admin)

Richard,

SunOS4.1.3_U1 still has /usr/etc/chill which marked memory pages
as in use, but the man page is missing.

Bill Goodridge

Thanks to everyone!

Richard Mills

  __________________________________
 ///////////////////////////////////|
===================================/|
||Richard Mills ||/|
||System Administration ||/|
||Harris Controls Division ||/|
||Melbourne Florida ||/|
||(407)242-5324__________________||/|
||rmills@ccd.harris.com//////////||/|
===================================/



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:30 CDT