Could putting /tmp in RAM be shrinking the HugePages available on my server?

November 18, 2026 5 answers
Asked by _s26!gasketnotch.4

A production server has 64 GB of RAM and /tmp mounted in memory. After a few days, it becomes difficult to allocate HugePages even though there appears to be enough free memory.

Could /tmp be contributing to fragmentation, and would moving it to disk help?

Answers

_d48!mivlora.7

It could contribute to memory pressure, but the observation alone doesn't pin the fragmentation on /tmp. HugePages need contiguous physical memory, so having enough free memory in total doesn't guarantee that a new allocation will succeed.

If the application needs explicit HugePages, consider reserving them at boot with vm.nr_hugepages, when contiguous memory is generally easier to find. Check whether you mean that the reserved pool is being consumed or that increasing the pool later is failing. Those are different problems.

4y!plovergrommet_583:

Also check whether the workload uses explicit HugePages or Transparent Huge Pages. The reservation setting applies to the explicit pool, not THP.

Reply to this answer
Rilvado-9m

Moving /tmp to disk is a reasonable test, but I wouldn't expect it to eliminate fragmentation. Filesystem metadata caches and other allocations can fragment memory over time too. Compare the HugePage allocation behavior and memory usage under a similar workload before and after the change.

Reply to this answer
d.529+florvex

There are good reasons to use tmpfs, but it isn't free RAM. Temporary files compete with the application for memory, and a process writing a lot to /tmp can create pressure. A size limit helps contain how much the filesystem can hold, though you still need to decide what should happen when it fills up.

Tmpfs can use swap if swap is configured. Without swap, don't assume those files have somewhere else to go. Also don't treat tmpfs as a guarantee that sensitive data can never reach disk, since it may be swapped.

Reply to this answer
Tivdaro-6p

Disk-backed /tmp may be perfectly quick enough. Linux can cache file data in memory, so tmpfs isn't automatically a big win for every workload. The difference can be more noticeable when an application writes frequently and waits for data to be synced. Measure the actual workload before choosing based on speed.

Reply to this answer
Neravix-3t

Tmpfs can be convenient when temporary files should disappear at reboot. A separate /tmp mount also lets you set options such as noexec, nosuid and nodev, though that doesn't require tmpfs specifically. Those benefits need to be weighed against the memory budget on this server.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions