It's used to find out the effective allocation size of objects allocated
by kmalloc(). This is needed by the uClinux ports in many places but
seems also usefull for mmu-using ports.
--- 1.13/include/linux/slab.h Wed Sep 25 20:41:05 2002
+++ edited/include/linux/slab.h Sun Nov 3 03:08:32 2002
@@ -60,6 +60,7 @@
extern void *kmalloc(size_t, int);
extern void kfree(const void *);
+extern unsigned int ksize(const void *);
extern int FASTCALL(kmem_cache_reap(int));
--- 1.156/kernel/ksyms.c Thu Oct 31 10:28:34 2002
+++ edited/kernel/ksyms.c Sun Nov 3 03:09:00 2002
@@ -104,6 +104,7 @@
EXPORT_SYMBOL(remove_shrinker);
EXPORT_SYMBOL(kmalloc);
EXPORT_SYMBOL(kfree);
+EXPORT_SYMBOL(ksize);
EXPORT_SYMBOL(vfree);
EXPORT_SYMBOL(__vmalloc);
EXPORT_SYMBOL(vmalloc);
--- 1.46/mm/slab.c Fri Nov 1 16:34:38 2002
+++ edited/mm/slab.c Sun Nov 3 13:18:29 2002
@@ -1871,6 +1871,22 @@
return cachep->objsize;
}
+unsigned int ksize(const void *objp)
+{
+ kmem_cache_t *c;
+ unsigned long flags;
+ unsigned int size = 0;
+
+ if (objp) {
+ local_irq_save(flags);
+ c = GET_PAGE_CACHE(virt_to_page(objp));
+ size = kmem_cache_size(c);
+ local_irq_restore(flags);
+ }
+
+ return size;
+}
+
kmem_cache_t * kmem_find_general_cachep (size_t size, int gfpflags)
{
struct cache_sizes *csizep = malloc_sizes;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Thu Nov 07 2002 - 22:00:29 EST