3 #include <linux/malloc.h>
4 #include <linux/vmalloc.h>
11 /* global variables */
12 extern int obd_debug_level;
13 extern int obd_print_entry;
16 #define D_PSDEV 1 /* debug information from psdev.c */
21 #define D_WARNING 32 /* misc warnings */
22 #define D_EXT2 64 /* anything from ext2_debug */
23 #define D_MALLOC 128 /* print malloc, free information */
24 #define D_CACHE 256 /* cache-related items */
25 #define D_INFO 512 /* general information, especially from interface.c */
26 #define D_IOCTL 1024 /* ioctl related information */
27 #define D_BLOCKS 2048 /* ext2 block allocation */
30 #define CDEBUG(mask, format, a...) \
32 if (obd_debug_level & mask) { \
33 printk("(%s,l. %d): ", __FUNCTION__, __LINE__); \
34 printk(format, ## a); } \
38 if (obd_print_entry) \
39 printk("Process %d entered %s\n", current->pid, __FUNCTION__)
42 if (obd_print_entry) \
43 printk("Process %d leaving %s\n", current->pid, __FUNCTION__)
45 #else /* SIM_OBD_DEBUG */
51 #endif /* SIM_OBD_DEBUG */
55 #define OBD_ALLOC(ptr, cast, size) \
58 ptr = (cast)kmalloc((unsigned long) size, GFP_KERNEL); \
59 CDEBUG(D_MALLOC, "kmalloced: %x at %x.\n", \
60 (int) size, (int) ptr); \
62 ptr = (cast)vmalloc((unsigned long) size); \
63 CDEBUG(D_MALLOC, "vmalloced: %x at %x.\n", \
64 (int) size, (int) ptr); \
67 printk("kernel malloc returns 0 at %s:%d\n", \
68 __FILE__, __LINE__); \
70 memset(ptr, 0, size); \
73 #define OBD_FREE(ptr,size) \
76 kfree_s((ptr), (size)); \
77 CDEBUG(D_MALLOC, "kfreed: %x at %x.\n", \
78 (int) size, (int) ptr); \
81 CDEBUG(D_MALLOC, "vfreed: %x at %x.\n", \
82 (int) size, (int) ptr); \