#define OBD_CPT_VMALLOC(ptr, cptab, cpt, size) \
__OBD_VMALLOC_VERBOSE(ptr, cptab, cpt, size)
-/* Allocations above this size are considered too big and could not be done
- * atomically.
- *
- * Be very careful when changing this value, especially when decreasing it,
- * since vmalloc in Linux doesn't perform well on multi-cores system, calling
- * vmalloc in critical path would hurt performance badly. See LU-66.
- */
-#define OBD_ALLOC_BIG (4 * PAGE_CACHE_SIZE)
-
#define OBD_ALLOC_LARGE(ptr, size) \
do { \
- if (size > OBD_ALLOC_BIG) \
+ OBD_ALLOC_GFP(ptr, size, GFP_NOFS | __GFP_NOWARN); \
+ if (ptr == NULL) \
OBD_VMALLOC(ptr, size); \
- else \
- OBD_ALLOC(ptr, size); \
} while (0)
#define OBD_CPT_ALLOC_LARGE(ptr, cptab, cpt, size) \
do { \
- if (size > OBD_ALLOC_BIG) \
+ OBD_CPT_ALLOC_GFP(ptr, cptab, cpt, size, GFP_NOFS | __GFP_NOWARN); \
+ if (ptr == NULL) \
OBD_CPT_VMALLOC(ptr, cptab, cpt, size); \
- else \
- OBD_CPT_ALLOC(ptr, cptab, cpt, size); \
} while (0)
-#define OBD_FREE_LARGE(ptr, size) \
-do { \
- if (size > OBD_ALLOC_BIG) \
- OBD_VFREE(ptr, size); \
- else \
- OBD_FREE(ptr, size); \
-} while (0)
+#define OBD_FREE_LARGE(ptr, size) OBD_FREE(ptr, size)
#ifdef CONFIG_DEBUG_SLAB
#define POISON(ptr, c, s) do {} while (0)
#define OBD_FREE(ptr, size) \
do { \
- OBD_FREE_PRE(ptr, size, "kfreed"); \
- kfree(ptr); \
- POISON_PTR(ptr); \
+ if (is_vmalloc_addr(ptr)) { \
+ OBD_FREE_PRE(ptr, size, "vfreed"); \
+ vfree(ptr); \
+ } else { \
+ OBD_FREE_PRE(ptr, size, "kfreed"); \
+ kfree(ptr); \
+ } \
+ POISON_PTR(ptr); \
} while(0)
-
#define OBD_FREE_RCU(ptr, size, handle) \
do { \
struct portals_handle *__h = (handle); \
POISON_PTR(ptr); \
} while(0)
-#define OBD_VFREE(ptr, size) \
- do { \
- OBD_FREE_PRE(ptr, size, "vfreed"); \
- vfree(ptr); \
- POISON_PTR(ptr); \
- } while (0)
-
/* we memset() the slab object to 0 when allocation succeeds, so DO NOT
* HAVE A CTOR THAT DOES ANYTHING. its work will be cleared here. we'd
* love to assert on that, but slab.c keeps kmem_cache_s all to itself. */
rc, PFID(mdd_object_fid(mdd_obj)));
}
- if (ldata->ld_buf && ldata->ld_buf->lb_len > OBD_ALLOC_BIG)
+ if (is_vmalloc_addr(ldata->ld_buf))
/* if we vmalloced a large buffer drop it */
lu_buf_free(ldata->ld_buf);
stop:
mdd_trans_stop(env, mdd, rc, handle);
- if (ldata->ld_buf && ldata->ld_buf->lb_len > OBD_ALLOC_BIG)
+ if (is_vmalloc_addr(ldata->ld_buf))
/* if we vmalloced a large buffer drop it */
lu_buf_free(ldata->ld_buf);
out_pending:
if (rc == 0)
rc = rc2;
out_free:
- if (ldata->ld_buf && ldata->ld_buf->lb_len > OBD_ALLOC_BIG)
+ if (is_vmalloc_addr(ldata->ld_buf))
/* if we vmalloced a large buffer drop it */
lu_buf_free(ldata->ld_buf);