From: Andrew Morton <akpm@osdl.org>
To: Martin Hicks <mort@sgi.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] meminfo: add Cached underflow check
Date: Mon, 4 Apr 2005 15:10:49 -0700 [thread overview]
Message-ID: <20050404151049.53a30133.akpm@osdl.org> (raw)
In-Reply-To: <20050404151105.GG10693@localhost>
Martin Hicks <mort@sgi.com> wrote:
>
> Working on some code lately I've been getting huge values
> for "Cached". The cause is that get_page_cache_size() is an
> approximate value, and for a sufficiently small returned value
> of get_page_cache_size() the value underflows.
OK..
I think I'd prefer to do it this way - it's simpler and the original patch
had a teeny race wrt changes in total_swapcache_pages.
diff -puN fs/proc/proc_misc.c~meminfo-add-cached-underflow-check fs/proc/proc_misc.c
--- 25/fs/proc/proc_misc.c~meminfo-add-cached-underflow-check Mon Apr 4 15:06:38 2005
+++ 25-akpm/fs/proc/proc_misc.c Mon Apr 4 15:10:24 2005
@@ -126,6 +126,7 @@ static int meminfo_read_proc(char *page,
unsigned long committed;
unsigned long allowed;
struct vmalloc_info vmi;
+ long cached;
get_page_state(&ps);
get_zone_counts(&active, &inactive, &free);
@@ -140,6 +141,10 @@ static int meminfo_read_proc(char *page,
allowed = ((totalram_pages - hugetlb_total_pages())
* sysctl_overcommit_ratio / 100) + total_swap_pages;
+ cached = get_page_cache_size() - total_swapcache_pages - i.bufferram;
+ if (cached < 0)
+ cached = 0;
+
get_vmalloc_info(&vmi);
/*
@@ -172,7 +177,7 @@ static int meminfo_read_proc(char *page,
K(i.totalram),
K(i.freeram),
K(i.bufferram),
- K(get_page_cache_size()-total_swapcache_pages-i.bufferram),
+ K(cached),
K(total_swapcache_pages),
K(active),
K(inactive),
_
next prev parent reply other threads:[~2005-04-04 22:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-04 15:11 Martin Hicks
2005-04-04 22:10 ` Andrew Morton [this message]
2005-04-04 22:41 ` Martin Hicks
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=20050404151049.53a30133.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mort@sgi.com \
/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
Powered by JetHome