All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Brzezinski <adrian.brzezinski@eo.pl>
To: <linux-kernel@vger.kernel.org>
Cc: <adrian.brzezinski@eo.pl>
Subject: [PATCH 1/1] fs/proc: cached = pagecache - shmem
Date: Wed, 24 Jul 2013 20:12:11 +0200	[thread overview]
Message-ID: <51F018FB.1050106@eo.pl> (raw)


Cached value taken from /proc/meminfo counts also shmem pages.
This can be very confusing when we encounter OOM problems.

Maybe the better solution would be, to not increment NR_FILE_PAGES,
when we have NR_SHMEM page? Should I rewrote and resend this patch?

Signed-off-by: Adrian Brzezinski <adrian.brzezinski@eo.pl>
---
 fs/proc/meminfo.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
index 5aa847a..d00aef5 100644
--- a/fs/proc/meminfo.c
+++ b/fs/proc/meminfo.c
@@ -40,7 +40,12 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
        allowed = ((totalram_pages - hugetlb_total_pages())
                * sysctl_overcommit_ratio / 100) + total_swap_pages;

+       /*
+        * NR_SHMEM pages can't be treated as a cache,
+        * but they are counted in NR_FILE_PAGES
+        */
        cached = global_page_state(NR_FILE_PAGES) -
+                       global_page_state(NR_SHMEM) -
                        total_swapcache_pages() - i.bufferram;
        if (cached < 0)
                cached = 0;
@@ -59,6 +64,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
                "Buffers:        %8lu kB\n"
                "Cached:         %8lu kB\n"
                "SwapCached:     %8lu kB\n"
+               "PageCache:      %8lu kB\n"
                "Active:         %8lu kB\n"
                "Inactive:       %8lu kB\n"
                "Active(anon):   %8lu kB\n"
@@ -111,6 +117,7 @@ static int meminfo_proc_show(struct seq_file *m,
void *v)
                K(i.bufferram),
                K(cached),
                K(total_swapcache_pages()),
+               K(global_page_state(NR_FILE_PAGES)),
                K(pages[LRU_ACTIVE_ANON]   + pages[LRU_ACTIVE_FILE]),
                K(pages[LRU_INACTIVE_ANON] + pages[LRU_INACTIVE_FILE]),
                K(pages[LRU_ACTIVE_ANON]),
--
1.7.1

             reply	other threads:[~2013-07-24 18:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-24 18:12 Adrian Brzezinski [this message]
2013-08-08 11:12 ` [PATCH 1/1] fs/proc: cached = pagecache - shmem tingwei liu

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=51F018FB.1050106@eo.pl \
    --to=adrian.brzezinski@eo.pl \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.