kmalloc_powerof2()
Ensures that the returned address will be power of 2 aligned.
kmalloc_cachealign()
Ensures that the returned address will be cacheline size aligned.
It is useful to allocate structs declared with __cachealign
attribute.
These two function probably should _not_ be used on the hot code path
due to the computational cost to find the nearest power of 2 size.
crit_exit();
}
+void *
+kmalloc_powerof2(unsigned long size_alloc, struct malloc_type *type, int flags)
+{
+ unsigned long size;
+
+ for (size = 1; size < size_alloc; size <<= 1)
+ ; /* EMPTY */
+ return kmalloc(size, type, flags);
+}
+
+void *
+kmalloc_cachealign(unsigned long size_alloc, struct malloc_type *type,
+ int flags)
+{
+ if (size_alloc < __VM_CACHELINE_SIZE)
+ size_alloc = __VM_CACHELINE_SIZE;
+ return kmalloc_powerof2(size_alloc, type, flags);
+}
#define kstrdup_debug(str, type, file, line) \
kstrdup(str, type)
#endif
+void *kmalloc_powerof2 (unsigned long size, struct malloc_type *type,
+ int flags);
+void *kmalloc_cachealign (unsigned long size, struct malloc_type *type,
+ int flags);
void kfree (void *addr, struct malloc_type *type);
long kmalloc_limit (struct malloc_type *type);