linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Greg Freemyer <greg.freemyer@gmail.com>
To: Prateek Sharma <prateeks@cse.iitb.ac.in>
Cc: linux-mm@kvack.org, kernelnewbies@kernelnewbies.org
Subject: Re: What does drop_caches do?
Date: Wed, 24 Aug 2011 03:18:25 -0400	[thread overview]
Message-ID: <CAGpXXZJwL1R9RFFu4kQfkVA1eu=2FoS0Mrvag0PSw=2_1zSipw@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1107281215550.14640@nsl-11>

On Thu, Jul 28, 2011 at 2:58 AM, Prateek Sharma <prateeks@cse.iitb.ac.in> 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@kvack.org.  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=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2011-08-24  7:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-28  6:58 Prateek Sharma
2011-08-24  7:18 ` Greg Freemyer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGpXXZJwL1R9RFFu4kQfkVA1eu=2FoS0Mrvag0PSw=2_1zSipw@mail.gmail.com' \
    --to=greg.freemyer@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    --cc=linux-mm@kvack.org \
    --cc=prateeks@cse.iitb.ac.in \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox