Re: What does drop_caches do?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 28, 2011 at 2:58 AM, Prateek Sharma <prateeks@xxxxxxxxxxxxxx> wrote:
> Hello everyone,
>        I've been trying to understand the role of the pagecache, starting with
> drop_caches and observing what it does.
>        From my understanding of the code (fs/drop_caches.c) , it walks over all
> the open files/inodes, and invalidates all the mapped pages.

Stepping up a little, I think you're missing
drop_caches_sysctl_handler() in that same file.  It is the entry point
I believe that implements the userspace ABI defined in
Documentation/sysctl/vm.txt.

==============================================================
 139
 140drop_caches
 141
 142Writing to this will cause the kernel to drop clean caches, dentries and
 143inodes from memory, causing that memory to become free.
 144
 145To free pagecache:
 146        echo 1 > /proc/sys/vm/drop_caches
 147To free dentries and inodes:
 148        echo 2 > /proc/sys/vm/drop_caches
 149To free pagecache, dentries and inodes:
 150        echo 3 > /proc/sys/vm/drop_caches
 151
 152As this is a non-destructive operation and dirty objects are not
freeable, the
 153user should run `sync' first.
 154
 155==============================================================

Note the corresponding logic in /fs/drop_caches.c that implements the
above binary logic.


  61              if (sysctl_drop_caches & 1)
  62                        iterate_supers(drop_pagecache_sb, NULL);
  63                if (sysctl_drop_caches & 2)
  64                        drop_slab();

Greg

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]