$ cat /proc/mounts | egrep ' /tmp 'tmpfs /tmp tmpfs rw,nosuid,nodev,relatime 0 0$ dd if=/dev/zero bs=1M count=3000 of=/tmp/q3000+0 records in3000+0 records out3145728000 bytes (3.1 GB) copied, 1.04961 s, 3.0 GB/s$ time rm /tmp/qreal    0m0.296suser    0m0.000ssys     0m0.290sWhy not 0.000s? There is no disk involved, just marking that memory is not used anymore.
Why deleting big files from tmpfs is not instantaneous?
linux;filesystems;virtual memory;tmpfs
The marking that memory as unused is a function of how much work the unlinkat(2) system call has to do, which in turn scales linearly with the size of the file. For a default tmpfs on a RHEL 6 system with ~4G of memory, this can be demonstrated as follows.$ sudo mkdir /tmpfs; sudo mount -t tmpfs -o size=75% tmpfs /tmpfs; cd /tmpfs$ dd if=/dev/zero bs=1M of=blah count=2859...$ strace -c rm blah 2>&1 | head -3% time     seconds  usecs/call     calls    errors syscall------ ----------- ----------- --------- --------- ----------------100.00    0.241964      241964         1           unlinkat$ for c in 500 1000 1500 2000 2500; do dd if=/dev/zero bs=1M of=blah count=$c 2>/dev/null; echo -n $c ; strace -c rm blah 2>&1 | awk '/unlinkat/{print $3}'; done500 539921000 889861500 1359802000 1749742500 222966As to what the unlinkat(2) system call is doing in particular, that would require digging around in the source code; my guess is that the data structure that represents the file in memory (a linked list?) is being looped over as the file is removed, thus accounting for the linear growth of operation time with file size.