Creating shared memory objects with 1 TB segment size

The 1 TB segment size improves the performance of processes that use large shared memory regions. This support is available for 64-bit applications that use 16 MB large pages and do not use extended shared memory.

If an application qualifies to use a 1 TB segment size, the AIX operating system creates the shared memory region with 1 TB segments. By using the lgpg_size, lgpg_regions, v_pinshm, and hugeseg_shm_mode tunable parameters of the vmo command. The system must have enough free 16 MB large pages to contain the entire shared memory region that must be created.
vmo -o lgpg_regions=<number of pages> -o lgpg_size=16M
vmo -o v_pinshm=1
vmo -o hugeseg_shm_mode=1
Applications can ask for a 1 TB segment size by using the SHM_HGSEG flag of the shmget subroutine when creating shared memory objects. To set this type of setting, the hugeseg_shm_mode tunable parameter of the vmo command must be set to 1. The following example shows the syntax of the shmget subroutine:

shmget(key, size, shmflag | SHM_HGSEG | SHM_LGPAGE | SHM_PIN);
You can also use theshmctl() subroutine (as shown in the following example) to request 16 MB pages after the shmget subroutine is complete, and the AIX operating system starts creating the shared memory regions with 1TB segments.
struct shmid_ds shminfo = { 0 };
int shmid;
shmid = shmget(key, size, shmflag);
shminfo.shm_pagesize = 16M;
shmctl(shmid, SHM_PAGESIZE, &shminfo);
The AIX operating system can autonomically use a 1 TB segment size without any changes to the application. This configuration can be implemented by exporting the VMM_CNTRL environment variable with the SHM_AUTO_1TB keyword and by making use of the hugeseg_shm_mode tunable parameter of the vmo command. Set the tunable, and the environment variable using:
vmo -o hugeseg_shm_mode=1
export VMM_CNTRL=SHM_AUTO_1TB=ON
This causes the AIX operating system to try to use 1 TB segment size for any processes that are executed under this environment. The hugeseg_shm_mode tunable parameter can also be set to a global promote setting.
vmo -o hugeseg_shm_mode=2
This attempts to use 1 TB segment size for all processes without needing to set the environment variable, or using the SHM_HGSEG flag.
Note: This is considered an advisory operation, if the AIX OS cannot allocate a shared memory region with 1TB segment size, the allocation is created using a different segment size.