Re: [PATCH] drop page cache of a single file

From: Vaidyanathan Srinivasan
Date: Sun Jan 28 2007 - 02:09:29 EST




Zhang, Yanmin wrote:
> Currently, by /proc/sys/vm/drop_caches, applications could drop pagecache,
> slab(dentries and inodes), or both, but applications couldn't choose to
> just drop the page cache of one file. An user of VOD (Video-On-Demand)
> needs this capability to have more detailed control on page cache release.
>
> Below patch against 2.6.19 implements it.
>
> Signed-off-by: Zhang Yanmin <yanmin.zhang@xxxxxxxxx>
>
> ---
>
> diff -Nraup linux-2.6.19/Documentation/filesystems/proc.txt linux-2.6.19_dropcache/Documentation/filesystems/proc.txt
> --- linux-2.6.19/Documentation/filesystems/proc.txt 2006-12-08 15:32:44.000000000 +0800
> +++ linux-2.6.19_dropcache/Documentation/filesystems/proc.txt 2006-12-28 10:20:39.000000000 +0800
> @@ -1320,6 +1320,8 @@ To free dentries and inodes:
> echo 2 > /proc/sys/vm/drop_caches
> To free pagecache, dentries and inodes:
> echo 3 > /proc/sys/vm/drop_caches
> +To free the pagecache of one file:
> + echo "4 /path/to/filename" > /proc/sys/vm/drop_caches
>
> As this is a non-destructive operation and dirty objects are not freeable, the
> user should run `sync' first.

"sync" is the most time consuming operation. Clean pagecache pages
are immediately reclaimable... they are actually free pages. Writing
out dirty pages consumes time.

Hence this approach may not provide the required performance benefits
since only clean pagecache pages are marked free. fadvise approach
would provide similar behavior.

--Vaidy

[snip]

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/