summaryrefslogtreecommitdiff
path: root/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/lustre/include/linux/libcfs/libcfs_private.h')
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_private.h130
1 files changed, 15 insertions, 115 deletions
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
index 2f4ff595fac9..491d5971d199 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
@@ -43,13 +43,6 @@
# define DEBUG_SUBSYSTEM S_UNDEFINED
#endif
-/*
- * When this is on, LASSERT macro includes check for assignment used instead
- * of equality check, but doesn't have unlikely(). Turn this on from time to
- * time to make test-builds. This shouldn't be on for production release.
- */
-#define LASSERT_CHECKED (0)
-
#define LASSERTF(cond, fmt, ...) \
do { \
if (unlikely(!(cond))) { \
@@ -74,8 +67,6 @@ do { \
# define LINVRNT(exp) ((void)sizeof !!(exp))
#endif
-#define KLASSERT(e) LASSERT(e)
-
void __noreturn lbug_with_loc(struct libcfs_debug_msg_data *msg);
#define LBUG() \
@@ -84,74 +75,24 @@ do { \
lbug_with_loc(&msgdata); \
} while (0)
-#ifndef LIBCFS_VMALLOC_SIZE
-#define LIBCFS_VMALLOC_SIZE (2 << PAGE_SHIFT) /* 2 pages */
-#endif
-
-#define LIBCFS_ALLOC_PRE(size, mask) \
- LASSERT(!in_interrupt() || ((size) <= LIBCFS_VMALLOC_SIZE && \
- !gfpflags_allow_blocking(mask)))
-
-#define LIBCFS_ALLOC_POST(ptr, size) \
-do { \
- if (unlikely(!(ptr))) { \
- CERROR("LNET: out of memory at %s:%d (tried to alloc '" \
- #ptr "' = %d)\n", __FILE__, __LINE__, (int)(size)); \
- } else { \
- memset((ptr), 0, (size)); \
- } \
-} while (0)
-
-/**
- * allocate memory with GFP flags @mask
- */
-#define LIBCFS_ALLOC_GFP(ptr, size, mask) \
-do { \
- LIBCFS_ALLOC_PRE((size), (mask)); \
- (ptr) = (size) <= LIBCFS_VMALLOC_SIZE ? \
- kmalloc((size), (mask)) : vmalloc(size); \
- LIBCFS_ALLOC_POST((ptr), (size)); \
-} while (0)
-
-/**
- * default allocator
- */
-#define LIBCFS_ALLOC(ptr, size) \
- LIBCFS_ALLOC_GFP(ptr, size, GFP_NOFS)
-
-/**
- * non-sleeping allocator
+/*
+ * Use #define rather than inline, as lnet_cpt_table() might
+ * not be defined yet
*/
-#define LIBCFS_ALLOC_ATOMIC(ptr, size) \
- LIBCFS_ALLOC_GFP(ptr, size, GFP_ATOMIC)
+#define kmalloc_cpt(size, flags, cpt) \
+ kmalloc_node(size, flags, cfs_cpt_spread_node(lnet_cpt_table(), cpt))
-/**
- * allocate memory for specified CPU partition
- * \a cptab != NULL, \a cpt is CPU partition id of \a cptab
- * \a cptab == NULL, \a cpt is HW NUMA node id
- */
-#define LIBCFS_CPT_ALLOC_GFP(ptr, cptab, cpt, size, mask) \
-do { \
- LIBCFS_ALLOC_PRE((size), (mask)); \
- (ptr) = (size) <= LIBCFS_VMALLOC_SIZE ? \
- kmalloc_node((size), (mask), cfs_cpt_spread_node(cptab, cpt)) :\
- vmalloc_node(size, cfs_cpt_spread_node(cptab, cpt)); \
- LIBCFS_ALLOC_POST((ptr), (size)); \
-} while (0)
+#define kzalloc_cpt(size, flags, cpt) \
+ kmalloc_node(size, flags | __GFP_ZERO, \
+ cfs_cpt_spread_node(lnet_cpt_table(), cpt))
-/** default numa allocator */
-#define LIBCFS_CPT_ALLOC(ptr, cptab, cpt, size) \
- LIBCFS_CPT_ALLOC_GFP(ptr, cptab, cpt, size, GFP_NOFS)
+#define kvmalloc_cpt(size, flags, cpt) \
+ kvmalloc_node(size, flags, \
+ cfs_cpt_spread_node(lnet_cpt_table(), cpt))
-#define LIBCFS_FREE(ptr, size) \
-do { \
- if (unlikely(!(ptr))) { \
- CERROR("LIBCFS: free NULL '" #ptr "' (%d bytes) at " \
- "%s:%d\n", (int)(size), __FILE__, __LINE__); \
- break; \
- } \
- kvfree(ptr); \
-} while (0)
+#define kvzalloc_cpt(size, flags, cpt) \
+ kvmalloc_node(size, flags | __GFP_ZERO, \
+ cfs_cpt_spread_node(lnet_cpt_table(), cpt))
/******************************************************************************/
@@ -242,59 +183,18 @@ do { \
#define LASSERT_ATOMIC_ZERO(a) LASSERT_ATOMIC_EQ(a, 0)
#define LASSERT_ATOMIC_POS(a) LASSERT_ATOMIC_GT(a, 0)
-#define CFS_ALLOC_PTR(ptr) LIBCFS_ALLOC(ptr, sizeof(*(ptr)))
-#define CFS_FREE_PTR(ptr) LIBCFS_FREE(ptr, sizeof(*(ptr)))
-
-/* max value for numeric network address */
-#define MAX_NUMERIC_VALUE 0xffffffff
-
/* implication */
#define ergo(a, b) (!(a) || (b))
/* logical equivalence */
#define equi(a, b) (!!(a) == !!(b))
-/* --------------------------------------------------------------------
- * Light-weight trace
- * Support for temporary event tracing with minimal Heisenberg effect.
- * --------------------------------------------------------------------
- */
-
-#define MKSTR(ptr) ((ptr)) ? (ptr) : ""
-
-static inline size_t cfs_size_round4(int val)
-{
- return (val + 3) & (~0x3);
-}
-
#ifndef HAVE_CFS_SIZE_ROUND
static inline size_t cfs_size_round(int val)
{
- return (val + 7) & (~0x7);
+ return round_up(val, 8);
}
#define HAVE_CFS_SIZE_ROUND
#endif
-static inline size_t cfs_size_round16(int val)
-{
- return (val + 0xf) & (~0xf);
-}
-
-static inline size_t cfs_size_round32(int val)
-{
- return (val + 0x1f) & (~0x1f);
-}
-
-static inline size_t cfs_size_round0(int val)
-{
- if (!val)
- return 0;
- return (val + 1 + 7) & (~0x7);
-}
-
-static inline size_t cfs_round_strlen(char *fset)
-{
- return cfs_size_round((int)strlen(fset) + 1);
-}
-
#endif