How to configure Shared Memory Parameters in Solaris 10,11
Newer versions of Solaris use resource control settings to configure shared memory. When configuring a new system, it is recommended that they be used, even though the /etc/system settings are still available. It is best to use only 1 method to configure shared memory. When a system is upgraded from an old Solaris version, the /etc/system settings may still be present, so it is important to understand how those settings relate to the new resource control settings. To avoid confusion, it is best to eliminate the settings from /etc/system after they are implemented with resource controls.
Our test system:
# prtdiag -v System Configuration: Sun Microsystems sun4u Sun Ultra 2 UPA/SBus (2 X UltraSPARC-II 296MHz) System clock frequency: 99 MHz Memory size: 256 Megabytes
This section illustrates the interaction between /etc/system settings and the new resource control settings, using root user as the example.
The two project settings for shared memory are project.max-shm-memorywhich has a default value of 1/4 physmem and a maximum of UINT64_MAX, and project.max-shm-ids which has a default value of 128 and a maximum of 2**24. These control the total amount of shared memory that can be allocated by processes in a project, and the number of segments that can exist in a project, respectively.
With no shared memory settings in /etc/system, and no entries for any projects, show the settings for the user we are logged in as ($$ gives the pid of the current process):
# prctl -n project.max-shm-memory -i process $$ process: 1179: sh NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT project.max-shm-memory privileged 61.1MB - deny -
# prctl -n project.max-shm-ids -i process $$ process: 1179: sh NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT project.max-shm-ids privileged 128 - deny -
If there are shared memory settings in /etc/system, but no resource controls set for projects, the settings for all processes are calculated from the
/etc/system settings. Added to /etc/system (this value is 3MB):
/etc/system settings. Added to /etc/system (this value is 3MB):
set shmsys:shminfo_shmmax = 3145728
Reboot system in order to have it read settings in /etc/system.
# prctl -n project.max-shm-memory -i process $$ process: 611: sh NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT project.max-shm-memory privileged 300MB - deny -
# prctl -n project.max-shm-ids -i process $$ process: 611: sh NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT project.max-shm-ids privileged 128 - deny -
Because only shminfo_shmmax was set in /etc/system, the value for project.max-shm-memory was calculated by multiplying shminfo_shmmax by the default value for shminfo_shmmni, which is 100. shminfo_shmmax is the largest segment a user may allocate, but project.max-shm-memory is the maximum total of all segments a user may allocate.
Add this to /etc/system as well:
# vi /etc/system set shmsys:shminfo_shmmni = 50
Reboot the system and verify the values.
# prctl -n project.max-shm-memory -i process $$ process: 610: sh NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT project.max-shm-memory privileged 150MB - deny -
# prctl -n project.max-shm-ids -i process $$ process: 610: sh NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT project.max-shm-ids privileged 128 - deny -
If there is a project.max-shm-memory setting for the project a user is part of, that value overrides anything from /etc/system. Set a value for root user:
# projmod -K project.max-shm-memory="(priv,100M,deny)" user.root
You should never edit the /etc/project file yourself, but you can see values that have been set using the projmod command:
# more /etc/project system:0:::: user.root:1::::project.max-shm-memory=(priv,104857600,deny) ...
# prctl -n project.max-shm-memory -i process $$ process: 610: sh NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT project.max-shm-memory privileged 150MB - deny -
Exit from root login and login back to verify the parameter values.
# prctl -n project.max-shm-memory -i process $$ process: 632: sh NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT project.max-shm-memory privileged 100MB - deny
No comments:
Post a Comment