From: Christoph Lameter <clameter@sgi.com>
To: akpm@osdl.org
Cc: linux-mm@kvack.org, Christoph Lameter <clameter@sgi.com>
Subject: [SLUB 1/5] Fix object counting
Date: Tue, 10 Apr 2007 12:19:10 -0700 (PDT) [thread overview]
Message-ID: <20070410191910.8011.76133.sendpatchset@schroedinger.engr.sgi.com> (raw)
Object counting did not take into account that the number of full slabs
is the total number of slabs - number of partial - number of cpu slabs. As a
results the counts were off a bit. This issue surfaced when slab validation
was implemented.
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
mm/slub.c | 61 ++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 34 insertions(+), 27 deletions(-)
Index: linux-2.6.21-rc6-mm1/mm/slub.c
===================================================================
--- linux-2.6.21-rc6-mm1.orig/mm/slub.c 2007-04-09 22:29:21.000000000 -0700
+++ linux-2.6.21-rc6-mm1/mm/slub.c 2007-04-09 22:30:06.000000000 -0700
@@ -2318,23 +2318,34 @@ static unsigned long slab_objects(struct
int node;
int x;
unsigned long *nodes;
+ unsigned long *per_cpu;
- nodes = kmalloc(sizeof(unsigned long) * nr_node_ids, GFP_KERNEL);
+ nodes = kzalloc(2 * sizeof(unsigned long) * nr_node_ids, GFP_KERNEL);
+ per_cpu = nodes + nr_node_ids;
+
+ for_each_possible_cpu(cpu) {
+ struct page *page = s->cpu_slab[cpu];
+ int node;
+
+ if (page) {
+ node = page_to_nid(page);
+ if (flags & SO_CPU) {
+ int x = 0;
+
+ if (flags & SO_OBJECTS)
+ x = page->inuse;
+ else
+ x = 1;
+ total += x;
+ nodes[node] += x;
+ }
+ per_cpu[node]++;
+ }
+ }
for_each_online_node(node) {
struct kmem_cache_node *n = get_node(s, node);
- nodes[node] = 0;
-
- if (flags & SO_FULL) {
- if (flags & SO_OBJECTS)
- x = atomic_read(&n->nr_slabs)
- * s->objects;
- else
- x = atomic_read(&n->nr_slabs);
- total += x;
- nodes[node] += x;
- }
if (flags & SO_PARTIAL) {
if (flags & SO_OBJECTS)
x = count_partial(n);
@@ -2343,24 +2354,20 @@ static unsigned long slab_objects(struct
total += x;
nodes[node] += x;
}
- }
-
- if (flags & SO_CPU)
- for_each_possible_cpu(cpu) {
- struct page *page = s->cpu_slab[cpu];
- if (page) {
- int x = 0;
- int node = page_to_nid(page);
+ if (flags & SO_FULL) {
+ int full_slabs = atomic_read(&n->nr_slabs)
+ - per_cpu[node]
+ - n->nr_partial;
- if (flags & SO_OBJECTS)
- x = page->inuse;
- else
- x = 1;
- total += x;
- nodes[node] += x;
- }
+ if (flags & SO_OBJECTS)
+ x = full_slabs * s->objects;
+ else
+ x = full_slabs;
+ total += x;
+ nodes[node] += x;
}
+ }
x = sprintf(buf, "%lu", total);
#ifdef CONFIG_NUMA
--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2007-04-10 19:19 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-10 19:19 Christoph Lameter [this message]
2007-04-10 19:19 ` [SLUB 2/5] Enable tracking of full slabs Christoph Lameter
2007-04-10 19:19 ` [SLUB 3/5] Validation of slabs (metadata and guard zones) Christoph Lameter
2007-04-10 20:31 ` Andrew Morton
2007-04-10 20:47 ` Dave Jones
2007-04-10 21:42 ` Andrew Morton
2007-04-10 21:10 ` Christoph Lameter
2007-04-10 21:13 ` Christoph Lameter
2007-04-10 21:14 ` Christoph Lameter
2007-04-10 21:15 ` Christoph Lameter
2007-04-10 21:21 ` Christoph Lameter
2007-04-10 21:40 ` Christoph Lameter
2007-04-10 22:49 ` Christoph Lameter
2007-04-10 23:43 ` Andrew Morton
2007-04-10 23:17 ` Christoph Lameter
2007-04-10 23:38 ` Christoph Lameter
2007-04-11 0:00 ` Christoph Lameter
2007-04-11 0:15 ` Christoph Lameter
2007-04-11 6:24 ` question on mmap sameer sameer
2007-04-13 17:59 ` Hugh Dickins
2007-04-11 2:24 ` [SLUB 3/5] Validation of slabs (metadata and guard zones) Christoph Lameter
2007-04-11 3:08 ` Andrew Morton
2007-04-10 19:19 ` [SLUB 4/5] Add ability to list alloc / free callers per slab Christoph Lameter
2007-04-10 19:19 ` [SLUB 5/5] Drop version number Christoph Lameter
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=20070410191910.8011.76133.sendpatchset@schroedinger.engr.sgi.com \
--to=clameter@sgi.com \
--cc=akpm@osdl.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox