mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] slub: /proc/slabinfo ABI compatibility
@ 2007-12-22 12:47 Pekka J Enberg
  2007-12-22 13:14 ` Ingo Molnar
  2007-12-22 13:16 ` Ingo Molnar
  0 siblings, 2 replies; 11+ messages in thread
From: Pekka J Enberg @ 2007-12-22 12:47 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, mingo, andi, clameter, a.p.zijlstra

From: Pekka Enberg <penberg@cs.helsinki.fi>

This adds a read-only /proc/slabinfo file that is ABI compatible with SLAB for
SLUB.

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Christoph Lameter <clameter@sgi.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
 fs/proc/proc_misc.c      |   17 ++++++++++
 include/linux/slub_def.h |    2 +
 mm/slub.c                |   79 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 98 insertions(+)

Index: linux-2.6/fs/proc/proc_misc.c
===================================================================
--- linux-2.6.orig/fs/proc/proc_misc.c	2007-12-22 14:43:48.000000000 +0200
+++ linux-2.6/fs/proc/proc_misc.c	2007-12-22 14:44:11.000000000 +0200
@@ -451,6 +451,20 @@
 #endif
 #endif
 
+#ifdef CONFIG_SLUB
+static int slabinfo_open(struct inode *inode, struct file *file)
+{
+	return seq_open(file, &slabinfo_op);
+}
+
+static const struct file_operations proc_slabinfo_operations = {
+	.open		= slabinfo_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= seq_release,
+};
+#endif
+
 static int show_stat(struct seq_file *p, void *v)
 {
 	int i;
@@ -734,6 +748,9 @@
 	create_seq_entry("slab_allocators", 0 ,&proc_slabstats_operations);
 #endif
 #endif
+#ifdef CONFIG_SLUB
+	create_seq_entry("slabinfo", S_IWUSR|S_IRUGO, &proc_slabinfo_operations);
+#endif
 	create_seq_entry("buddyinfo",S_IRUGO, &fragmentation_file_operations);
 	create_seq_entry("pagetypeinfo", S_IRUGO, &pagetypeinfo_file_ops);
 	create_seq_entry("vmstat",S_IRUGO, &proc_vmstat_file_operations);
Index: linux-2.6/include/linux/slub_def.h
===================================================================
--- linux-2.6.orig/include/linux/slub_def.h	2007-12-22 14:43:48.000000000 +0200
+++ linux-2.6/include/linux/slub_def.h	2007-12-22 14:44:11.000000000 +0200
@@ -200,4 +200,6 @@
 }
 #endif
 
+extern const struct seq_operations slabinfo_op;
+
 #endif /* _LINUX_SLUB_DEF_H */
Index: linux-2.6/mm/slub.c
===================================================================
--- linux-2.6.orig/mm/slub.c	2007-12-22 14:43:48.000000000 +0200
+++ linux-2.6/mm/slub.c	2007-12-22 14:44:37.000000000 +0200
@@ -4123,3 +4123,82 @@
 
 __initcall(slab_sysfs_init);
 #endif
+
+/*
+ * The /proc/slabinfo ABI
+ */
+#ifdef CONFIG_PROC_FS
+
+static void print_slabinfo_header(struct seq_file *m)
+{
+	seq_puts(m, "slabinfo - version: 2.1\n");
+	seq_puts(m, "# name            <active_objs> <num_objs> <objsize> "
+		 "<objperslab> <pagesperslab>");
+	seq_puts(m, " : tunables <limit> <batchcount> <sharedfactor>");
+	seq_puts(m, " : slabdata <active_slabs> <num_slabs> <sharedavail>");
+	seq_putc(m, '\n');
+}
+
+static void *s_start(struct seq_file *m, loff_t *pos)
+{
+	loff_t n = *pos;
+
+	down_read(&slub_lock);
+	if (!n)
+		print_slabinfo_header(m);
+
+	return seq_list_start(&slab_caches, *pos);
+}
+
+static void *s_next(struct seq_file *m, void *p, loff_t *pos)
+{
+	return seq_list_next(p, &slab_caches, pos);
+}
+
+static void s_stop(struct seq_file *m, void *p)
+{
+	up_read(&slub_lock);
+}
+
+static int s_show(struct seq_file *m, void *p)
+{
+	unsigned long nr_partials = 0;
+	unsigned long nr_slabs = 0;
+	unsigned long nr_inuse = 0;
+	unsigned long nr_objs;
+	struct kmem_cache *s;
+	int node;
+
+	s = list_entry(p, struct kmem_cache, list);
+
+	for_each_online_node(node) {
+		struct kmem_cache_node *n = get_node(s, node);
+
+		if (!n)
+			continue;
+
+		nr_partials += n->nr_partial;
+		nr_slabs += atomic_long_read(&n->nr_slabs);
+		nr_inuse += count_partial(n);
+	}
+
+	nr_objs = nr_slabs * s->objects;
+	nr_inuse += (nr_slabs - nr_partials) * s->objects;
+
+	seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d", s->name, nr_inuse,
+		   nr_objs, s->size, s->objects, (1 << s->order));
+	seq_printf(m, " : tunables %4u %4u %4u", 0, 0, 0);
+	seq_printf(m, " : slabdata %6lu %6lu %6lu", nr_slabs, nr_slabs,
+		   0UL);
+	seq_putc(m, '\n');
+	return 0;
+}
+
+const struct seq_operations slabinfo_op = {
+	.start = s_start,
+	.next = s_next,
+	.stop = s_stop,
+	.show = s_show,
+};
+
+#endif /* CONFIG_PROC_FS */

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

* Re: [PATCH] slub: /proc/slabinfo ABI compatibility
  2007-12-22 12:47 [PATCH] slub: /proc/slabinfo ABI compatibility Pekka J Enberg
@ 2007-12-22 13:14 ` Ingo Molnar
  2007-12-22 13:31   ` Pekka Enberg
  2007-12-22 13:16 ` Ingo Molnar
  1 sibling, 1 reply; 11+ messages in thread
From: Ingo Molnar @ 2007-12-22 13:14 UTC (permalink / raw)
  To: Pekka J Enberg; +Cc: akpm, linux-kernel, andi, clameter, a.p.zijlstra


* Pekka J Enberg <penberg@cs.helsinki.fi> wrote:

> From: Pekka Enberg <penberg@cs.helsinki.fi>
> 
> This adds a read-only /proc/slabinfo file that is ABI compatible with 
> SLAB for SLUB.

cool :-) I tried your patch and slabtop works just fine:

 ------------------>
 Active / Total Objects (% used)    : 31939 / 32363 (98.7%)
 Active / Total Slabs (% used)      : 2082 / 2082 (100.0%)
 Active / Total Caches (% used)     : 87 / 165 (52.7%)
 Active / Total Size (% used)       : 9225.02K / 9325.23K (98.9%)
 Minimum / Average / Maximum Object : 0.08K / 0.29K / 4.12K

  OBJS ACTIVE  USE OBJ SIZE  SLABS OBJ/SLAB CACHE SIZE NAME
  7618   7610  99%    0.15K    293       26      1172K sysfs_dir_cache
  3045   3045 100%    0.27K    203       15       812K dentry
  2856   2852  99%    0.14K    102       28       408K selinux_inode_security
  2760   2721  98%    0.17K    120       23       480K buffer_head
  2737   2736  99%    0.23K    161       17       644K vm_area_struct
 <------------------

 Tested-by: Ingo Molnar <mingo@elte.hu>

Also please apply the cleanup patch below, it fixes 34 checkpatch errors 
and warnings in mm/slub.c.

	Ingo

------------------------>
Subject: SLUB: fix checkpatch warnings
From: Ingo Molnar <mingo@elte.hu>

fix checkpatch --file mm/slub.c errors and warnings.

 $ q-code-quality-compare
                                      errors   lines of code   errors/KLOC
 mm/slub.c      [before]                  22            4204           5.2
 mm/slub.c      [after]                    0            4210             0

no code changed:

    text    data     bss     dec     hex filename
   22195    8634     136   30965    78f5 slub.o.before
   22195    8634     136   30965    78f5 slub.o.after

   md5:
     93cdfbec2d6450622163c590e1064358  slub.o.before.asm
     93cdfbec2d6450622163c590e1064358  slub.o.after.asm

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 mm/slub.c |   92 +++++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 49 insertions(+), 43 deletions(-)

Index: linux/mm/slub.c
===================================================================
--- linux.orig/mm/slub.c
+++ linux/mm/slub.c
@@ -354,22 +354,22 @@ static void print_section(char *text, u8
 			printk(KERN_ERR "%8s 0x%p: ", text, addr + i);
 			newline = 0;
 		}
-		printk(" %02x", addr[i]);
+		printk(KERN_CONT " %02x", addr[i]);
 		offset = i % 16;
 		ascii[offset] = isgraph(addr[i]) ? addr[i] : '.';
 		if (offset == 15) {
-			printk(" %s\n",ascii);
+			printk(KERN_CONT " %s\n", ascii);
 			newline = 1;
 		}
 	}
 	if (!newline) {
 		i %= 16;
 		while (i < 16) {
-			printk("   ");
+			printk(KERN_CONT "   ");
 			ascii[i] = ' ';
 			i++;
 		}
-		printk(" %s\n", ascii);
+		printk(KERN_CONT " %s\n", ascii);
 	}
 }
 
@@ -529,7 +529,7 @@ static void init_object(struct kmem_cach
 
 	if (s->flags & __OBJECT_POISON) {
 		memset(p, POISON_FREE, s->objsize - 1);
-		p[s->objsize -1] = POISON_END;
+		p[s->objsize - 1] = POISON_END;
 	}
 
 	if (s->flags & SLAB_RED_ZONE)
@@ -558,7 +558,7 @@ static void restore_bytes(struct kmem_ca
 
 static int check_bytes_and_report(struct kmem_cache *s, struct page *page,
 			u8 *object, char *what,
-			u8* start, unsigned int value, unsigned int bytes)
+			u8 *start, unsigned int value, unsigned int bytes)
 {
 	u8 *fault;
 	u8 *end;
@@ -682,9 +682,10 @@ static int check_object(struct kmem_cach
 			endobject, red, s->inuse - s->objsize))
 			return 0;
 	} else {
-		if ((s->flags & SLAB_POISON) && s->objsize < s->inuse)
-			check_bytes_and_report(s, page, p, "Alignment padding", endobject,
-				POISON_INUSE, s->inuse - s->objsize);
+		if ((s->flags & SLAB_POISON) && s->objsize < s->inuse) {
+			check_bytes_and_report(s, page, p, "Alignment padding",
+				endobject, POISON_INUSE, s->inuse - s->objsize);
+		}
 	}
 
 	if (s->flags & SLAB_POISON) {
@@ -692,7 +693,7 @@ static int check_object(struct kmem_cach
 			(!check_bytes_and_report(s, page, p, "Poison", p,
 					POISON_FREE, s->objsize - 1) ||
 			 !check_bytes_and_report(s, page, p, "Poison",
-			 	p + s->objsize -1, POISON_END, 1)))
+				p + s->objsize - 1, POISON_END, 1)))
 			return 0;
 		/*
 		 * check_pad_bytes cleans up on its own.
@@ -781,7 +782,8 @@ static int on_freelist(struct kmem_cache
 	return search == NULL;
 }
 
-static void trace(struct kmem_cache *s, struct page *page, void *object, int alloc)
+static void
+trace(struct kmem_cache *s, struct page *page, void *object, int alloc)
 {
 	if (s->flags & SLAB_TRACE) {
 		printk(KERN_INFO "TRACE %s %s 0x%p inuse=%d fp=0x%p\n",
@@ -891,17 +893,15 @@ static int free_debug_processing(struct 
 		return 0;
 
 	if (unlikely(s != page->slab)) {
-		if (!PageSlab(page))
+		if (!PageSlab(page)) {
 			slab_err(s, page, "Attempt to free object(0x%p) "
 				"outside of slab", object);
-		else
-		if (!page->slab) {
+		} else if (!page->slab) {
 			printk(KERN_ERR
 				"SLUB <none>: no slab for object 0x%p.\n",
 						object);
 			dump_stack();
-		}
-		else
+		} else
 			object_err(s, page, object,
 					"page slab pointer corrupt.");
 		goto fail;
@@ -947,7 +947,7 @@ static int __init setup_slub_debug(char 
 	/*
 	 * Determine which debug features should be switched on
 	 */
-	for ( ;*str && *str != ','; str++) {
+	for ( ; *str && *str != ','; str++) {
 		switch (tolower(*str)) {
 		case 'f':
 			slub_debug |= SLAB_DEBUG_FREE;
@@ -966,7 +966,7 @@ static int __init setup_slub_debug(char 
 			break;
 		default:
 			printk(KERN_ERR "slub_debug option '%c' "
-				"unknown. skipped\n",*str);
+				"unknown. skipped\n", *str);
 		}
 	}
 
@@ -1005,7 +1005,7 @@ static unsigned long kmem_cache_flags(un
 		 */
 		if (slub_debug && (!slub_debug_slabs ||
 		    strncmp(slub_debug_slabs, name,
-		    	strlen(slub_debug_slabs)) == 0))
+			strlen(slub_debug_slabs)) == 0))
 				flags |= slub_debug;
 	}
 
@@ -1039,7 +1039,7 @@ static inline unsigned long kmem_cache_f
  */
 static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
 {
-	struct page * page;
+	struct page *page;
 	int pages = 1 << s->order;
 
 	if (s->order)
@@ -1134,8 +1134,7 @@ static void __free_slab(struct kmem_cach
 
 	mod_zone_page_state(page_zone(page),
 		(s->flags & SLAB_RECLAIM_ACCOUNT) ?
-		NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE,
-		- pages);
+		NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE, -pages);
 
 	__free_pages(page, s->order);
 }
@@ -1227,7 +1226,8 @@ static void remove_partial(struct kmem_c
  *
  * Must hold list_lock.
  */
-static inline int lock_and_freeze_slab(struct kmem_cache_node *n, struct page *page)
+static inline int
+lock_and_freeze_slab(struct kmem_cache_node *n, struct page *page)
 {
 	if (slab_trylock(page)) {
 		list_del(&page->lru);
@@ -1295,8 +1295,8 @@ static struct page *get_any_partial(stru
 	if (!s->defrag_ratio || get_cycles() % 1024 > s->defrag_ratio)
 		return NULL;
 
-	zonelist = &NODE_DATA(slab_node(current->mempolicy))
-					->node_zonelists[gfp_zone(flags)];
+	zonelist = &NODE_DATA(
+		slab_node(current->mempolicy))->node_zonelists[gfp_zone(flags)];
 	for (z = zonelist->zones; *z; z++) {
 		struct kmem_cache_node *n;
 
@@ -1539,8 +1539,8 @@ debug:
  *
  * Otherwise we can simply pick the next object from the lockless free list.
  */
-static void __always_inline *slab_alloc(struct kmem_cache *s,
-		gfp_t gfpflags, int node, void *addr)
+static __always_inline void *
+slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, void *addr)
 {
 	void **object;
 	unsigned long flags;
@@ -1647,8 +1647,8 @@ debug:
  * If fastpath is not possible then fall back to __slab_free where we deal
  * with all sorts of special processing.
  */
-static void __always_inline slab_free(struct kmem_cache *s,
-			struct page *page, void *x, void *addr)
+static __always_inline void
+slab_free(struct kmem_cache *s, struct page *page, void *x, void *addr)
 {
 	void **object = (void *)x;
 	unsigned long flags;
@@ -2228,7 +2228,7 @@ error:
  */
 int kmem_ptr_validate(struct kmem_cache *s, const void *object)
 {
-	struct page * page;
+	struct page *page;
 
 	page = get_object_page(object);
 
@@ -2341,7 +2341,7 @@ static struct kmem_cache *kmalloc_caches
 
 static int __init setup_slub_min_order(char *str)
 {
-	get_option (&str, &slub_min_order);
+	get_option(&str, &slub_min_order);
 
 	return 1;
 }
@@ -2350,7 +2350,7 @@ __setup("slub_min_order=", setup_slub_mi
 
 static int __init setup_slub_max_order(char *str)
 {
-	get_option (&str, &slub_max_order);
+	get_option(&str, &slub_max_order);
 
 	return 1;
 }
@@ -2359,7 +2359,7 @@ __setup("slub_max_order=", setup_slub_ma
 
 static int __init setup_slub_min_objects(char *str)
 {
-	get_option (&str, &slub_min_objects);
+	get_option(&str, &slub_min_objects);
 
 	return 1;
 }
@@ -2437,7 +2437,8 @@ static noinline struct kmem_cache *dma_k
 		goto unlock_out;
 
 	realsize = kmalloc_caches[index].objsize;
-	text = kasprintf(flags & ~SLUB_DMA, "kmalloc_dma-%d", (unsigned int)realsize),
+	text = kasprintf(flags & ~SLUB_DMA, "kmalloc_dma-%d",
+			 (unsigned int)realsize);
 	s = kmalloc(kmem_size, flags & ~SLUB_DMA);
 
 	if (!s || !text || !kmem_cache_open(s, flags, text,
@@ -2874,7 +2875,8 @@ void __init kmem_cache_init(void)
 #endif
 
 
-	printk(KERN_INFO "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
+	printk(KERN_INFO
+		"SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
 		" CPUs=%d, Nodes=%d\n",
 		caches, cache_line_size(),
 		slub_min_order, slub_max_order, slub_min_objects,
@@ -2931,7 +2933,7 @@ static struct kmem_cache *find_mergeable
 		 * Check if alignment is compatible.
 		 * Courtesy of Adrian Drzewiecki
 		 */
-		if ((s->size & ~(align -1)) != s->size)
+		if ((s->size & ~(align - 1)) != s->size)
 			continue;
 
 		if (s->size - size >= sizeof(void *))
@@ -3040,8 +3042,9 @@ static int __cpuinit slab_cpuup_callback
 	return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata slab_notifier =
-	{ &slab_cpuup_callback, NULL, 0 };
+static struct notifier_block __cpuinitdata slab_notifier = {
+	.notifier_call = slab_cpuup_callback
+};
 
 #endif
 
@@ -3198,8 +3201,9 @@ static void resiliency_test(void)
 	p = kzalloc(32, GFP_KERNEL);
 	p[32 + sizeof(void *)] = 0x34;
 	printk(KERN_ERR "\n2. kmalloc-32: Clobber next pointer/next slab"
-		 	" 0x34 -> -0x%p\n", p);
-	printk(KERN_ERR "If allocated object is overwritten then not detectable\n\n");
+			" 0x34 -> -0x%p\n", p);
+	printk(KERN_ERR
+		"If allocated object is overwritten then not detectable\n\n");
 
 	validate_slab_cache(kmalloc_caches + 5);
 	p = kzalloc(64, GFP_KERNEL);
@@ -3207,7 +3211,8 @@ static void resiliency_test(void)
 	*p = 0x56;
 	printk(KERN_ERR "\n3. kmalloc-64: corrupting random byte 0x56->0x%p\n",
 									p);
-	printk(KERN_ERR "If allocated object is overwritten then not detectable\n\n");
+	printk(KERN_ERR
+		"If allocated object is overwritten then not detectable\n\n");
 	validate_slab_cache(kmalloc_caches + 6);
 
 	printk(KERN_ERR "\nB. Corruption after free\n");
@@ -3220,7 +3225,8 @@ static void resiliency_test(void)
 	p = kzalloc(256, GFP_KERNEL);
 	kfree(p);
 	p[50] = 0x9a;
-	printk(KERN_ERR "\n2. kmalloc-256: Clobber 50th byte 0x9a->0x%p\n\n", p);
+	printk(KERN_ERR "\n2. kmalloc-256: Clobber 50th byte 0x9a->0x%p\n\n",
+			p);
 	validate_slab_cache(kmalloc_caches + 8);
 
 	p = kzalloc(512, GFP_KERNEL);
@@ -3865,7 +3871,7 @@ static ssize_t defrag_ratio_store(struct
 SLAB_ATTR(defrag_ratio);
 #endif
 
-static struct attribute * slab_attrs[] = {
+static struct attribute *slab_attrs[] = {
 	&slab_size_attr.attr,
 	&object_size_attr.attr,
 	&objs_per_slab_attr.attr,

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

* Re: [PATCH] slub: /proc/slabinfo ABI compatibility
  2007-12-22 12:47 [PATCH] slub: /proc/slabinfo ABI compatibility Pekka J Enberg
  2007-12-22 13:14 ` Ingo Molnar
@ 2007-12-22 13:16 ` Ingo Molnar
  2007-12-22 13:37   ` Ingo Molnar
  1 sibling, 1 reply; 11+ messages in thread
From: Ingo Molnar @ 2007-12-22 13:16 UTC (permalink / raw)
  To: Pekka J Enberg; +Cc: akpm, linux-kernel, andi, clameter, a.p.zijlstra


* Pekka J Enberg <penberg@cs.helsinki.fi> wrote:

> From: Pekka Enberg <penberg@cs.helsinki.fi>
> 
> This adds a read-only /proc/slabinfo file that is ABI compatible with 
> SLAB for SLUB.
> 
> Cc: Ingo Molnar <mingo@elte.hu>

Tested-by: Ingo Molnar <mingo@elte.hu>

	Ingo

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

* Re: [PATCH] slub: /proc/slabinfo ABI compatibility
  2007-12-22 13:14 ` Ingo Molnar
@ 2007-12-22 13:31   ` Pekka Enberg
  2007-12-22 13:40     ` Ingo Molnar
  0 siblings, 1 reply; 11+ messages in thread
From: Pekka Enberg @ 2007-12-22 13:31 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: akpm, linux-kernel, andi, clameter, a.p.zijlstra

Hi Ingo,

On Dec 22, 2007 3:14 PM, Ingo Molnar <mingo@elte.hu> wrote:
> Also please apply the cleanup patch below, it fixes 34 checkpatch errors
> and warnings in mm/slub.c.

Those are already fixed in -mm:

http://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.24-rc5/2.6.24-rc5-mm1/broken-out/slub-fix-coding-style-violations.patch
http://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.24-rc5/2.6.24-rc5-mm1/broken-out/slub-fix-coding-style-violations-checkpatch-fixes.patch

                                Pekka

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

* Re: [PATCH] slub: /proc/slabinfo ABI compatibility
  2007-12-22 13:16 ` Ingo Molnar
@ 2007-12-22 13:37   ` Ingo Molnar
  2007-12-22 13:42     ` Pekka Enberg
  2007-12-24 19:12     ` Christoph Lameter
  0 siblings, 2 replies; 11+ messages in thread
From: Ingo Molnar @ 2007-12-22 13:37 UTC (permalink / raw)
  To: Pekka J Enberg; +Cc: akpm, linux-kernel, andi, clameter, a.p.zijlstra


* Ingo Molnar <mingo@elte.hu> wrote:

> > From: Pekka Enberg <penberg@cs.helsinki.fi>
> > 
> > This adds a read-only /proc/slabinfo file that is ABI compatible with 
> > SLAB for SLUB.
> > 
> > Cc: Ingo Molnar <mingo@elte.hu>
> 
> Tested-by: Ingo Molnar <mingo@elte.hu>

Pekka, i stuck your patch into the x86.git random-test-grid, and it 
found the following build error after a few iterations:

  mm/slub.c: In function 's_show':
  mm/slub.c:4188: error: implicit declaration of function 'count_partial'

find the (tested) fix below.

	Ingo

----------------->
Subject: SLUB: build fix
From: Ingo Molnar <mingo@elte.hu>

fix:

 mm/slub.c: In function 's_show':
 mm/slub.c:4188: error: implicit declaration of function 'count_partial'

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 mm/slub.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

Index: linux/mm/slub.c
===================================================================
--- linux.orig/mm/slub.c
+++ linux/mm/slub.c
@@ -3079,6 +3079,19 @@ void *__kmalloc_node_track_caller(size_t
 	return slab_alloc(s, gfpflags, node, caller);
 }
 
+static unsigned long count_partial(struct kmem_cache_node *n)
+{
+	unsigned long flags;
+	unsigned long x = 0;
+	struct page *page;
+
+	spin_lock_irqsave(&n->list_lock, flags);
+	list_for_each_entry(page, &n->partial, lru)
+		x += page->inuse;
+	spin_unlock_irqrestore(&n->list_lock, flags);
+	return x;
+}
+
 #if defined(CONFIG_SYSFS) && defined(CONFIG_SLUB_DEBUG)
 static int validate_slab(struct kmem_cache *s, struct page *page,
 						unsigned long *map)
@@ -3464,19 +3477,6 @@ static int list_locations(struct kmem_ca
 	return n;
 }
 
-static unsigned long count_partial(struct kmem_cache_node *n)
-{
-	unsigned long flags;
-	unsigned long x = 0;
-	struct page *page;
-
-	spin_lock_irqsave(&n->list_lock, flags);
-	list_for_each_entry(page, &n->partial, lru)
-		x += page->inuse;
-	spin_unlock_irqrestore(&n->list_lock, flags);
-	return x;
-}
-
 enum slab_stat_type {
 	SL_FULL,
 	SL_PARTIAL,

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

* Re: [PATCH] slub: /proc/slabinfo ABI compatibility
  2007-12-22 13:31   ` Pekka Enberg
@ 2007-12-22 13:40     ` Ingo Molnar
  2007-12-22 13:49       ` Pekka Enberg
  0 siblings, 1 reply; 11+ messages in thread
From: Ingo Molnar @ 2007-12-22 13:40 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: akpm, linux-kernel, andi, clameter, a.p.zijlstra


* Pekka Enberg <penberg@cs.helsinki.fi> wrote:

> Hi Ingo,
> 
> On Dec 22, 2007 3:14 PM, Ingo Molnar <mingo@elte.hu> wrote:
> > Also please apply the cleanup patch below, it fixes 34 checkpatch errors
> > and warnings in mm/slub.c.
> 
> Those are already fixed in -mm:
> 
> http://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.24-rc5/2.6.24-rc5-mm1/broken-out/slub-fix-coding-style-violations.patch
> http://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.24-rc5/2.6.24-rc5-mm1/broken-out/slub-fix-coding-style-violations-checkpatch-fixes.patch

ah, didnt see that. Could you pick up bits of my patch because it seems 
to do a better job, such as proper c99 initializer:

+static struct notifier_block __cpuinitdata slab_notifier = {
+       .notifier_call = slab_cpuup_callback
+};

instead of your:

+static struct notifier_block __cpuinitdata slab_notifier = {
+       &slab_cpuup_callback, NULL, 0
+};

also, my patch fixes all the warnings as well, not just the errors. So 
please give it a second look ;-)

	Ingo

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

* Re: [PATCH] slub: /proc/slabinfo ABI compatibility
  2007-12-22 13:37   ` Ingo Molnar
@ 2007-12-22 13:42     ` Pekka Enberg
  2007-12-24 19:12     ` Christoph Lameter
  1 sibling, 0 replies; 11+ messages in thread
From: Pekka Enberg @ 2007-12-22 13:42 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: akpm, linux-kernel, andi, clameter, a.p.zijlstra

Hi Ingo,

On Dec 22, 2007 3:37 PM, Ingo Molnar <mingo@elte.hu> wrote:
> Pekka, i stuck your patch into the x86.git random-test-grid, and it
> found the following build error after a few iterations:
>
>   mm/slub.c: In function 's_show':
>   mm/slub.c:4188: error: implicit declaration of function 'count_partial'

Looks good. Thanks!

Reviewed-by: Pekka Enberg <penberg@cs.helsinki.fi>

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

* Re: [PATCH] slub: /proc/slabinfo ABI compatibility
  2007-12-22 13:40     ` Ingo Molnar
@ 2007-12-22 13:49       ` Pekka Enberg
  0 siblings, 0 replies; 11+ messages in thread
From: Pekka Enberg @ 2007-12-22 13:49 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: akpm, linux-kernel, andi, clameter, a.p.zijlstra

Hi Ingo,

On Dec 22, 2007 3:40 PM, Ingo Molnar <mingo@elte.hu> wrote:
> ah, didnt see that. Could you pick up bits of my patch because it seems
> to do a better job, such as proper c99 initializer:

[snip]

> also, my patch fixes all the warnings as well, not just the errors. So
> please give it a second look ;-)

Sure, I'm fine with that. Can you Andrew please drop mine and use
Ingo's instead?

Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>

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

* Re: [PATCH] slub: /proc/slabinfo ABI compatibility
  2007-12-22 13:37   ` Ingo Molnar
  2007-12-22 13:42     ` Pekka Enberg
@ 2007-12-24 19:12     ` Christoph Lameter
  2007-12-24 20:59       ` Pekka Enberg
  1 sibling, 1 reply; 11+ messages in thread
From: Christoph Lameter @ 2007-12-24 19:12 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Pekka J Enberg, akpm, linux-kernel, andi, a.p.zijlstra

On Sat, 22 Dec 2007, Ingo Molnar wrote:

> Pekka, i stuck your patch into the x86.git random-test-grid, and it 
> found the following build error after a few iterations:
> 
>   mm/slub.c: In function 's_show':
>   mm/slub.c:4188: error: implicit declaration of function 'count_partial'
> 
> find the (tested) fix below.

Hmmm... What is the combination of config variables that causes this? I 
moved the count_partial function in mm in order to make the merge of slab 
defrag easier.

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

* Re: [PATCH] slub: /proc/slabinfo ABI compatibility
  2007-12-24 19:12     ` Christoph Lameter
@ 2007-12-24 20:59       ` Pekka Enberg
  2007-12-26 21:28         ` Christoph Lameter
  0 siblings, 1 reply; 11+ messages in thread
From: Pekka Enberg @ 2007-12-24 20:59 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: Ingo Molnar, akpm, linux-kernel, andi, a.p.zijlstra

On Dec 24, 2007 9:12 PM, Christoph Lameter <clameter@sgi.com> wrote:
> Hmmm... What is the combination of config variables that causes this? I
> moved the count_partial function in mm in order to make the merge of slab
> defrag easier.

I think it's CONFIG_PROC_FS without CONFIG_SYSFS.

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

* Re: [PATCH] slub: /proc/slabinfo ABI compatibility
  2007-12-24 20:59       ` Pekka Enberg
@ 2007-12-26 21:28         ` Christoph Lameter
  0 siblings, 0 replies; 11+ messages in thread
From: Christoph Lameter @ 2007-12-26 21:28 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: Ingo Molnar, akpm, linux-kernel, andi, a.p.zijlstra

On Mon, 24 Dec 2007, Pekka Enberg wrote:

> On Dec 24, 2007 9:12 PM, Christoph Lameter <clameter@sgi.com> wrote:
> > Hmmm... What is the combination of config variables that causes this? I
> > moved the count_partial function in mm in order to make the merge of slab
> > defrag easier.
> 
> I think it's CONFIG_PROC_FS without CONFIG_SYSFS.

The only user of count_partial is in slab_objects() which is in a 
section that is

#if defined(CONFIG_SYSFS) && defined(CONFIG_SLUB_DEBUG)

There should be no use if CONFIG_SYSFS is not set. I think we get a 
warning about a function that is never called when compiling the current 
mm code without SLUB_DEBUG or CONFIG_SYSFS (because the slab defrag use 
has not been merged yet).

In mm count_partial() is always defined. In Linus tree count_partial() 
comes just before slab_objects().


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

end of thread, other threads:[~2007-12-26 21:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-22 12:47 [PATCH] slub: /proc/slabinfo ABI compatibility Pekka J Enberg
2007-12-22 13:14 ` Ingo Molnar
2007-12-22 13:31   ` Pekka Enberg
2007-12-22 13:40     ` Ingo Molnar
2007-12-22 13:49       ` Pekka Enberg
2007-12-22 13:16 ` Ingo Molnar
2007-12-22 13:37   ` Ingo Molnar
2007-12-22 13:42     ` Pekka Enberg
2007-12-24 19:12     ` Christoph Lameter
2007-12-24 20:59       ` Pekka Enberg
2007-12-26 21:28         ` Christoph Lameter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®