VistA Index     Linux Index    

Configuring Shared Memory

The easiest way to configure shared memory is to edit sysctl.conf.

To determine current shared memory limits you can use the ipcs command. The following example shows the values of my shared memory limits with my sysctl.conf already activated on Athlon

--------------- snip ------------------------------------------
Athlon > ipcs -lm
 
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 262144
max total shared memory (kbytes) = 8388608
min seg size (bytes) = 1
 
Athlon >
---------------- end-snip -------------------------------------

Overview of the parameters that are responsible for configuring the shared memory settings in Linux.

SHMMAX

SHMMAX is used to define the maximum size (in bytes) for a shared memory segment. the larger it is, the better Caché performance will be. Watch for messags when Cachée; starts..

Determine the value of SHMMAX by performing the following:

# cat /proc/sys/kernel/shmmax
33554432

As you can see from the output above, the default value for SHMMAX is 32MB. This is too small to run Caché. I generally set the SHMMAX parameter to half the physical memory up to a maximum of 2**32 since that is the largest unsigned value that can be entered into a 32 bit word (4Gb) If your system has less than 512 Mb of physical memory, I recommend a minimum of 100 Mb. My smallest machine had 256 Bm, and I allocated 128 Mb as shared, and Caché was able to run VistA, on the downloaded free single user version of Caché.

2**32 = 4294967296 or 4Gb which should be fine for most 32 bit systems

Athlon has 512 Mb of physical memory, so the following line was added to /etc/sysctl.comf

kernel.shmmax = 268435456

SHMALL

SHMALL controls the total amount of shared memory (in pages) that can be used at one time on the system.

The default size of SHMALL is 2097152 and like all the kernel system variables can be found using the cat command:

Athlon > cat /proc/sys/kernel/shmall
2097152
Athlon >
It appears as though the documentation does not keep up with the implementation. The documentation says the shmall is the same size as shmmax in bytes. However, shmmax is 32 MB by default, and shmall is a different number, so looking at /usr/include/linux/shm.h find SHMALL

#define SHMMAX 0x2000000		 /* max shared seg size (bytes) */
#define SHMMIN 1			 /* min shared seg size (bytes) */
#define SHMMNI 4096			 /* max num of segs system wide */
#define SHMALL (SHMMAX/PAGE_SIZE*(SHMMNI/16)) /* max shm system wide (pages) */
#define SHMSEG SHMMNI			 /* max shared segs per process */

and in /usr/include/sys/user.h find PAGE_SIZE and PAGE_SHIFT
#define PAGE_SHIFT		12
#define PAGE_SIZE		(1UL << PAGE_SHIFT)
so page size is 4096 set shmall = (268435456/4096)*(4096/16) = 268435456/16 = 16777216
I am going to increase shmall for VistA running on Caché to 16777216.


SHMMNI

This kernel parameter is used to set the maximum number of shared memory segments system wide. The default value for this parameter is 4096. This value is sufficient and typically does not need to be changed.

Determine the value of SHMMNI by performing the following:

Athlon > cat /proc/sys/kernel/shmmni
4096
Athlon >

SUMMARY

The only change for shared memory was to shmmax and shmall, so after making the change to /etc/sysctl.conf execute the sysctl command.

sysctl.conf for Athlon follows:

---------------- snip -----------------------

# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
# sysctl.conf(5) for more details.

# Controls IP packet forwarding
net.ipv4.ip_forward = 0

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1

# cache needs more shared memory
# kernel.shmmax default = 33554432
# change it to half physical memory 
kernel.shmmax = 268435456
kernel.shmall = 16777216

------------- end-snip -------------------------------------------

After making changes execute the following lines:


Athlon > su
Password:
[root@Athlon Cache]# /sbin/sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
kernel.sysrq = 0
kernel.core_uses_pid = 1
kernel.shmmax = 268435456
kernel.shmall = 16777216
[root@Athlon Cache]#
That takes care of shared memory.