All of lore.kernel.org
 help / color / mirror / Atom feed
* [SLUB 1/5] Fix object counting
@ 2007-04-10 19:19 Christoph Lameter
  2007-04-10 19:19 ` [SLUB 2/5] Enable tracking of full slabs Christoph Lameter
                   ` (3 more replies)
  0 siblings, 4 replies; 24+ messages in thread
From: Christoph Lameter @ 2007-04-10 19:19 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, Christoph Lameter

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>

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2007-04-13 17:59 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-10 19:19 [SLUB 1/5] Fix object counting Christoph Lameter
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

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.