+#define __vmem_alloc(size, flags) \
+({ void *_ptr_; \
+ \
+ BUG_ON(flags != KM_SLEEP); \
+ \
+ _ptr_ = (void *)vmalloc((size)); \
+ if (_ptr_ == NULL) { \
+ printk("Warning: vmem_alloc(%d, 0x%x) failed at %s:%d " \
+ "(%d/%d)\n", (int)(size), (int)(flags), \
+ __FILE__, __LINE__, \
+ atomic_read(&vmem_alloc_used), vmem_alloc_max); \
+ atomic_add((size), &vmem_alloc_used); \
+ if (unlikely(atomic_read(&vmem_alloc_used) > vmem_alloc_max)) \
+ vmem_alloc_max = atomic_read(&vmem_alloc_used); \
+ } \
+ \
+ _ptr_; \
+})
+
+#define vmem_alloc(size, flags) __vmem_alloc(size, flags)
+
+#define vmem_free(ptr, size) \
+({ \
+ BUG_ON(!(ptr) || (size) < 0); \
+ atomic_sub((size), &vmem_alloc_used); \
+ memset(ptr, 0x5a, (size)); /* Poison */ \
+ vfree(ptr); \
+})