'Is it possible to use libhugetlbfs to allocate memory only for large allocations

I would like to use libhugetlbfs for only large allocations. The target application calls malloc many times for small allocations and I would like them to use the malloc() as usual, but for allocations larger than some threshold, e.g., 1 MiB, I would like those requests to be satisfied by large pages through libhugetlbfs. Unfortunately, I see no "HUGETLB_*" environment variable for this. The following command was insightful, but didn't give me the answer I was hoping for:

# strings /usr/lib64/libhugetlbfs.so | grep HUGETLB



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source