MEMTIER(7)
β¨ NAME β¨
libmemtier.so β it's the interposer library that turns on the memkind memory tiering, bestie π
πΈ SYNOPSIS πΈ
So the whole vibe here? You've got a pre-built binary and you want memkind memory tiering in your life. You don't recompile it. You just pass these environment variables along with the command, like a little gift π
LD_PRELOAD=libmemtier.so MEMKIND_MEM_TIERS="..." command
{arguments ...}
π¦ DESCRIPTION π¦
Okay so this library is literally the thing that enables the memkind memory tiering mechanism β¨ With this functionality, your allocations get split between different types of memory automatically. No manual labor, no cap.
The library lets you make allocations using multiple kinds while keeping a specified ratio between them. That ratio decides how much of the total allocated memory should be allocated with each kind. Simple as that, periodt π
And listen β both the LD_PRELOAD and MEMKIND_MEM_TIERS environment variables are mandatory for enabling the memkind memory tiering. You need both. Not one. Both. π
π ENVIRONMENT π
MEMKIND_MEM_TIERSβ a semicolon-separated list of tier configurations, ended with a policy parameter. Each of the tier configurations is a comma-separated list of tier parameters in the format:param_name:value,(...). For the list of available tier parameters, please see the TIER PARAMETERS section below πMEMKIND_MEM_THRESHOLDSβ semicolon-separated list of threshold configurations. Each configuration consists of a comma-separated list of threshold parameters in the same format asMEMKIND_MEM_TIERS, where theparam_nameis one of theINIT_VAL,MIN_VALandMAX_VAL. Each parameter can be set only once. When any of the parameters are missing, they will be set to a default value. If threshold configuration is missing, threshold with default configuration will be used. If any of the parameters is set more than once, the application will be aborted π Order of provided configurations is important β configuration of Nth threshold defines threshold between Nth and (N+1)th tier. Note that for N+1 tiers there should be at most N thresholds defined. Set this variable only whenDYNAMIC_THRESHOLDpolicy is used. For more details aboutparam_namesee the THRESHOLD PARAMETERS section below. See also the EXAMPLES section for the usage ofMEMKIND_MEM_THRESHOLDSenvironment variable π
π TIER PARAMETERS π
KINDβ (required) kind of memory used in memory tier. Allowed kind names are'DRAM','KMEM_DAX'and'FS_DAX'. There can be multiple different kind names provided in theMEMKIND_MEM_TIERSenvironment variable β one in each tier configuration. Additionally, in this variable more than one'FS_DAX'kind name is allowed. More information about available kinds can be found in thememkind(3)manual, where the'DRAM'kind name allocates memory with the usage of theMEMKIND_DEFAULTkind, the'KMEM_DAX'with theMEMKIND_DAX_KMEMkind and the'FS_DAX'with a file-backed kind of memory created with thememkind_create_pmem()function πPATHβ (required only for theFS_DAXkind) the path to the location where pmem file will be created. The path has to exist. For other kinds, if set, will cause an error π¨PMEM_SIZE_LIMITβ (optional, only for theFS_DAXkind) if set, it limits the size of pmem file and the maximum size of total allocations from persistent memory. By default, no limit is introduced. Pass this option only withFS_DAXkind. For other kinds, if set, will cause an error. The accepted formats are:1,1K,1M,1G. See thememkind(3)manual for information about limitations to this value which are the same as for themax_sizevalue of thememkind_create_pmem()function π§RATIOβ (required) the part of the ratio tied to the given kind. It's an unsigned type in a range from1toUINT_MAX. See EXAMPLES section β¨POLICYβ (required, only one in the whole environment variable) determines the algorithm used to distribute allocations between provided memory kinds. This parameter has to be the last parameter inMEMKIND_MEM_TIERSconfiguration string. Currently onlySTATIC_RATIOandDYNAMIC_THRESHOLDpolicies are valid. See the POLICIES section π―
NOTE: The application will fail when the provided environment variable string is not in the correct format. So likeβ¦ format matters, bestie π
π POLICIES π
STATIC_RATIO
All allocations are made in such a way that the ratio between memory tiers is constant. No threshold is used. Set it and forget it π
DYNAMIC_THRESHOLD
The ratio between memory tiers is kept with a help of a threshold between kinds which value changes in time β³
Minimum two tiers are required for this policy, otherwise the application will be aborted π
The threshold value can change in time to keep the desired ratio between tiers, but it will not be lesser than MIN_VAL and it will not be greater than MAX_VAL.
For every allocation, if its size is greater than or equal to INIT_VAL, it will come from the (N+1)th tier.
Default values for a threshold between the first two tiers in the MEMKIND_MEM_TIERS environment variable are:
INIT_VAL = 1024, MIN_VAL = 513, MAX_VAL = 1536.
If there are more tiers defined, each next undefined threshold will have all parameters increased by 1024, so the next undefined threshold between the next two tiers will have:
INIT_VAL = 2048, MIN_VAL = 1537, MAX_VAL = 2560.
π THRESHOLD PARAMETERS π
INIT_VALβ (optional) the initial value of the threshold between two adjacent Nth and (N+1)th tiers. It must be greater than or equal toMIN_VALand less than or equal toMAX_VALβMIN_VALβ (optional) the minimum value of the threshold β¬οΈMAX_VALβ (optional) the maximum value of the threshold β¬οΈ
NOTE: Because setting the above parameters is optional, they will be set to default values in case they are not defined. So no stress if you skip them π«Ά
π DRAM FALLBACK POLICY π
Okay this part is important, pay attention π₯
- With the usage of both
DRAMandKMEM_DAXtiers, if there is not enough memory to satisfy theDRAMtier memory allocation request, the allocation will fall back to PMEM memory. - With the usage of both
DRAMandFS_DAXtiers, if there is not enough memory to satisfy theDRAMtier memory allocation request, the allocation will fail π - If there is not enough memory to satisfy the
FS_DAXorKMEM_DAXtier memory allocation request, the allocation will fail.
β EXAMPLES β
The following example will run ls with the memkind memory tiering library. Make sure that paths to both libmemtier.so and libmemkind.so are included in LD_LIBRARY_PATH. During the application run, 20% of the allocated memory will come from PMEM memory and 80% will come from DRAM ( FS_DAX:DRAM ratio is 1:4):
LD_PRELOAD=libmemtier.so
MEMKIND_MEM_TIERS="KIND:FS_DAX,PATH:/mnt/pmem0,PMEM_SIZE_LIMIT:10G,RATIO:1;KIND:DRAM,RATIO:4;POLICY:STATIC_RATIO"
/bin/ls -l
The example value of MEMKIND_MEM_TIERS environment variable where all allocations will come from PMEM memory with filesystem created with the path /mnt/pmem0 (PMEM file size is limited only by the specified filesystem):
LD_PRELOAD=libmemtier.so
MEMKIND_MEM_TIERS="KIND:FS_DAX,PATH:/mnt/pmem0,RATIO:1;POLICY:STATIC_RATIO"
The example value of MEMKIND_MEM_THRESHOLDS environment variable. With INIT_VAL=64, on the application start all allocations lower than 64 bytes threshold will come from DRAM and equal to or greater than this value will come from PMEM memory NUMA nodes. The threshold value changes during the runtime in order to maintain the ratio. MIN_VAL=1 and MAX_VAL=10000 set the lower and upper limits of the threshold value. Note that the DYNAMIC_THRESHOLD policy has to be set in MEMKIND_MEM_TIERS environment variable:
LD_PRELOAD=libmemtier.so
MEMKIND_MEM_TIERS="KIND:DRAM,RATIO:1;KIND:KMEM_DAX,RATIO:4;POLICY:DYNAMIC_THRESHOLD"
MEMKIND_MEM_THRESHOLDS="INIT_VAL:64,MIN_VAL:1,MAX_VAL:10000"
π NOTES π
libmemtier works for applications that do not statically link a malloc implementation. That's the whole note, bestie, keep it in mind π§
π COPYRIGHT π
Copyright (C) 2021 Intel Corporation. All rights reserved.
π SEE ALSO π
okay that's the whole page!! brought to you by the legends at Intel Corporation, dated 2021-06-23, from the LIBMEMTIER LD_PRELOAD API manual, section 7 β slay, go tier your memory bestie π β¨
π¦ where this page comes from
- debian bookworm: libmemkind-dev 1.14.0-2 Β· BSD-3-Clause
- fedora 43: memkind 1.14.0-11.fc43 Β· BSD-2-Clause
- ubuntu noble: libmemkind-dev 1.14.0-3build1 Β· BSD-3-Clause
- π the page's license: BSD-2-Clause
- Copyright (C) 2021-2022 Intel Corporation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms