Whamcloud - gitweb
use vmalloc for OBD_ALLOCs above 16k, like we do in Portals
authorpschwan <pschwan>
Sat, 9 Nov 2002 20:39:12 +0000 (20:39 +0000)
committerpschwan <pschwan>
Sat, 9 Nov 2002 20:39:12 +0000 (20:39 +0000)
lustre/include/linux/obd_support.h

index a6eb4c2..d18341f 100644 (file)
@@ -150,10 +150,15 @@ static inline void OBD_FAIL_WRITE(int id, kdev_t dev)
         }
 }
 
+#define OBD_VMALLOC_SIZE        16384
+
 #define OBD_ALLOC(ptr, size)                                            \
 do {                                                                    \
         long s = (size);                                                \
-        (ptr) = kmalloc(s, GFP_KERNEL);                                 \
+        if (s > OBD_VMALLOC_SIZE)                                       \
+                (ptr) = vmalloc(s);                                     \
+        else                                                            \
+                (ptr) = kmalloc(s, GFP_KERNEL);                         \
         if ((ptr) == NULL) {                                            \
                 CERROR("kmalloc of '" #ptr "' (%ld bytes) failed "      \
                        "at %s:%d\n", s, __FILE__, __LINE__);            \
@@ -169,7 +174,10 @@ do {                                                                    \
 do {                                                                    \
         int s = (size);                                                 \
         LASSERT(ptr);                                                   \
-        kfree((ptr));                                                   \
+        if (s > OBD_VMALLOC_SIZE)                                       \
+                vfree(ptr);                                             \
+        else                                                            \
+                kfree(ptr);                                             \
         obd_memory -= s;                                                \
         CDEBUG(D_MALLOC, "kfreed '" #ptr "': %d at %p (tot %ld).\n",    \
                s, (ptr), obd_memory);                                   \