On 11/21/2011 10:33 PM, John Stultz wrote:This patch provides new fadvise flags that can be used to mark
file pages as volatile, which will allow it to be discarded if the
kernel wants to reclaim memory.
This is useful for userspace to allocate things like caches, and lets
the kernel destructively (but safely) reclaim them when there's memory
pressure.
Right now, we can simply throw away pages if they are clean (backed
by a current on-disk copy). That only happens for anonymous/tmpfs/shmfs
pages when they're swapped out. This patch lets userspace select
dirty pages which can be simply thrown away instead of writing them
to disk first. See the mm/shmem.c for this bit of code. It's
different from FADV_DONTNEED since the pages are not immediately
discarded; they are only discarded under pressure.
I've got a few questions:
1) How do you tell userspace some of its data got
discarded?
2) How do you prevent the situation where every
volatile object gets a few pages discarded, making
them all unusable?
(better to throw away an entire object at once)
3) Isn't it too slow for something like Firefox to
create a new tmpfs object for every single throw-away
cache object?