From 3e793499b822a08fa1c00a7ebba1bca663476d5c Mon Sep 17 00:00:00 2001 From: pschwan Date: Sat, 9 Nov 2002 20:39:12 +0000 Subject: [PATCH] use vmalloc for OBD_ALLOCs above 16k, like we do in Portals --- lustre/include/linux/obd_support.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lustre/include/linux/obd_support.h b/lustre/include/linux/obd_support.h index a6eb4c2..d18341f 100644 --- a/lustre/include/linux/obd_support.h +++ b/lustre/include/linux/obd_support.h @@ -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); \ -- 1.8.3.1