From: Arun Sharma <asharma@fb.com>
To: linux-mm@kvack.org
Subject: Accounting for "missing RAM"
Date: Thu, 6 Oct 2011 12:23:31 -0700 [thread overview]
Message-ID: <4E8E0033.70602@fb.com> (raw)
I wrote a script to parse /proc/zoneinfo to figure out how memory on my
server was getting used.
On many machines this is able to account for RAM +/- 10MB (which I
consider within the margin of error).
But on many machines, there is 2-3GB of RAM that's unaccounted for and
mysteriously missing from zoneinfo as well as /proc/meminfo.
When I parse /proc/kpageflags, pages with flags==0 correspond to
nr_free_pages and pages with flags=KPF_BUDDY correspond to the number of
"missing ram pages".
As far as I understand, KPF_BUDDY is set only on the first page of a
higher order page. So if for some reason, we were counting an order=3
page as 7 pages instead of 8, it'd explain what I am seeing.
-Arun
#!/usr/bin/env python
import sys, re, string, os
class NestedDict(dict):
"""Implementation of perl's autovivification feature."""
def __getitem__(self, item):
try:
return dict.__getitem__(self, item)
except KeyError:
value = self[item] = type(self)()
return value
sep = re.compile('^Node (.*)')
pages = re.compile('.*nr.*pages.*')
slab = re.compile('.*nr.*slab.*')
present = re.compile('.*present.*')
pcpu_pageset_count = re.compile('.*count:.*')
zone = None
page_size = os.sysconf('SC_PAGESIZE')
zones = NestedDict()
for line in open('/proc/zoneinfo').readlines():
m = sep.match(line)
if m:
zone = m.group(1)
zones[zone]['pcpu_pageset'] = 0
# Old kernels don't have this in /proc/zoneinfo
zones[zone]['nr_free_pages'] = 0
m1 = pages.match(line)
m2 = slab.match(line)
m3 = present.match(line)
if m1 or m2 or m3:
name, val = string.split(line)
val = int(val)
zones[zone][name] = val
continue
m4 = pcpu_pageset_count.match(line)
if m4:
name, val = string.split(line)
val = int(val)
zones[zone]['pcpu_pageset'] += val
global_diff = 0L
for z in zones.keys():
allocated = zones[z]['present'] - zones[z]['nr_free_pages']
if allocated < 0: continue
print '##############'
print z
accounted = 0
for k in ('nr_file_pages', 'nr_anon_pages',
'nr_slab_reclaimable', 'nr_slab_unreclaimable',
'nr_page_table_pages', 'pcpu_pageset'):
val = zones[z][k]
print k, val
accounted += val
print "allocated", "accounted", "diff"
print allocated, accounted, allocated - accounted
global_diff += (allocated - accounted)
vmalloc = 0L
vmalloc_re = re.compile('.*VmallocUsed:\s+(\d+).*')
for line in open('/proc/meminfo').readlines():
m = vmalloc_re.match(line)
if m:
vmalloc_kb = int(m.group(1))
vmalloc = vmalloc_kb * 1024/page_size
print '##############'
print 'vmalloc', vmalloc
print "missing ram: ", (global_diff - vmalloc) * page_size
--
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-10-06 19:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4E8E0033.70602@fb.com \
--to=asharma@fb.com \
--cc=linux-mm@kvack.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.