Use this procedure to test the availability of the hugepages allocated to the pods.

Start 

  1. Check the file's output from the container to let you know if the Kubernetes infrastructure allocated the requested amount of hugepages.

    // Gives the availability of hugepages on the node :
    cat /sys/devices/system/node/node*/meminfo | fgrep Huge
    
    // Gives the hugepages allocated to the container :
    
    // 1GB - availability
    cat /sys/fs/cgroup/hugetlb/hugetlb.1GB.limit_in_bytes
    // 1GB - usage 
    cat /sys/fs/cgroup/hugetlb/hugetlb.1GB.usage_in_bytes
    
    // 2MB - availability 
    cat /sys/fs/cgroup/hugetlb/hugetlb.2MB.limit_in_bytes
    // 2MB - usage 
    cat /sys/fs/cgroup/hugetlb/hugetlb.2MB.usage_in_bytes
  2. Install the following packages inside the container : stress, libhugetlbfs-bin, libhugetlbfs-dev. These packages allow you to use the hugepages for running stress tests from within the container. 

    apt-get install stress libhugetlbfs-bin, libhugetlbfs-dev
  3. Depending on amount of hugepages and vCPUs allocated to the container, run the following command, where:
    cpu is the number of vCPUs allocated to the container - set to 2
    vm-bytes is the amount of memory allocated to each thread - set to 512MB
     m is the number of threads you want to run, each consuming vm-bytes - 2

    LD_PRELOAD=libhugetlbfs.so HUGETLB_MORECORE=yes stress --cpu 2 -m 2 --vm-bytes 536870912 &
  4. Monitor the files (usage of 1GB/2MB hugepages) mentioned in the step 1 to see if you are able to utilize the allocated resources.
    If the hugepages are not allocated to the container, you will encounter the following error. In such a case, contact the cloud admin for increasing the hugepages allocated to the node.

    Example:
    root@sd-pfe-3-cac-5784b66f8b-nmqwk:~# LD_PRELOAD=libhugetlbfs.so HUGETLB_MORECORE=yes stress --cpu 1 -m 1 --vm-bytes 268435456 &
    [1] 95806
    root@sd-pfe-3-cac-5784b66f8b-nmqwk:~#
    [1]+  Bus error               (core dumped) LD_PRELOAD=libhugetlbfs.so HUGETLB_MORECORE=yes stress --cpu 1 -m 1 --vm-bytes 268435456
    root@sd-pfe-3-cac-5784b66f8b-nmqwk:~#