[PATCH 3/3] Array alloc test code

From: Christoph Lameter
Date: Tue Feb 10 2015 - 14:48:32 EST


Some simply thrown in thing that allocates 100 objects and frees them again.

Spews out complaints about interrupts disabled since we are in an initcall.
But it shows that it works.

Signed-off-by: Christoph Lameter <cl@xxxxxxxxx>

Index: linux/mm/slub.c
===================================================================
--- linux.orig/mm/slub.c
+++ linux/mm/slub.c
@@ -5308,6 +5308,22 @@ static int __init slab_sysfs_init(void)

mutex_unlock(&slab_mutex);
resiliency_test();
+
+ /* Test array alloc */
+ {
+ void *arr[100];
+ int nr;
+
+ printk(KERN_INFO "Array allocation test\n");
+ printk(KERN_INFO "---------------------\n");
+ printk(KERN_INFO "Allocation 100 objects\n");
+ nr = kmem_cache_alloc_array(kmem_cache_node, GFP_KERNEL, 100, arr);
+ printk(KERN_INFO "Number allocated = %d\n", nr);
+ printk(KERN_INFO "Freeing the objects\n");
+ kmem_cache_free_array(kmem_cache_node, 100, arr);
+ printk(KERN_INFO "Array allocation test done.\n");
+ }
+
return 0;
}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/