Changed __OBD_VMALLOC_VERBOSE to use vzalloc instead of vmalloc + memset.
Changed LIBCFS_ALLOC_GFP / LIBCFS_ALLOC_POST to use kzalloc or vzalloc,
instead of the regular kmalloc/vmalloc followed by a memset.
Fixed a minor typo (VEROBSE->VERBOSE) in the vicinity.
Change-Id: Ie8ef6036c24bc4557a88d1aa04f34f6ec0c13109
Signed-off-by: Frank Zago <fzago@cray.com>
Reviewed-on: http://review.whamcloud.com/11029
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
CERROR("LNET: %d total bytes allocated by lnet\n", \
libcfs_kmem_read()); \
} else { \
- memset((ptr), 0, (size)); \
libcfs_kmem_inc((ptr), (size)); \
CDEBUG(D_MALLOC, "alloc '" #ptr "': %d at %p (tot %d).\n", \
(int)(size), (ptr), libcfs_kmem_read()); \
/**
* allocate memory with GFP flags @mask
+ * The allocated memory is zeroed-out.
*/
#define LIBCFS_ALLOC_GFP(ptr, size, mask) \
do { \
LIBCFS_ALLOC_PRE((size), (mask)); \
(ptr) = (size) <= LIBCFS_VMALLOC_SIZE ? \
- kmalloc((size), (mask)) : vmalloc(size); \
+ kzalloc((size), (mask)) : vzalloc(size); \
LIBCFS_ALLOC_POST((ptr), (size)); \
} while (0)
* 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
+ * The allocated memory is zeroed-out.
*/
#define LIBCFS_CPT_ALLOC_GFP(ptr, cptab, cpt, size, mask) \
do { \
LIBCFS_ALLOC_PRE((size), (mask)); \
(ptr) = (size) <= LIBCFS_VMALLOC_SIZE ? \
- cfs_cpt_malloc((cptab), (cpt), (size), (mask)) : \
- cfs_cpt_vmalloc((cptab), (cpt), (size)); \
+ cfs_cpt_malloc((cptab), (cpt), (size), (mask) | __GFP_ZERO) : \
+ cfs_cpt_vzalloc((cptab), (cpt), (size)); \
LIBCFS_ALLOC_POST((ptr), (size)); \
} while (0)
extern void *cfs_cpt_malloc(struct cfs_cpt_table *cptab, int cpt,
size_t nr_bytes, unsigned int flags);
-extern void *cfs_cpt_vmalloc(struct cfs_cpt_table *cptab, int cpt,
+extern void *cfs_cpt_vzalloc(struct cfs_cpt_table *cptab, int cpt,
size_t nr_bytes);
extern struct page *cfs_page_cpt_alloc(struct cfs_cpt_table *cptab,
int cpt, unsigned int flags);
EXPORT_SYMBOL(cfs_cpt_malloc);
void *
-cfs_cpt_vmalloc(struct cfs_cpt_table *cptab, int cpt, size_t nr_bytes)
+cfs_cpt_vzalloc(struct cfs_cpt_table *cptab, int cpt, size_t nr_bytes)
{
- return vmalloc_node(nr_bytes, cfs_cpt_spread_node(cptab, cpt));
+ return vzalloc_node(nr_bytes, cfs_cpt_spread_node(cptab, cpt));
}
-EXPORT_SYMBOL(cfs_cpt_vmalloc);
+EXPORT_SYMBOL(cfs_cpt_vzalloc);
struct page *
cfs_page_cpt_alloc(struct cfs_cpt_table *cptab, int cpt, unsigned int flags)
#define OBD_CPT_ALLOC_PTR(ptr, cptab, cpt) \
OBD_CPT_ALLOC(ptr, cptab, cpt, sizeof *(ptr))
-# define __OBD_VMALLOC_VEROBSE(ptr, cptab, cpt, size) \
+# define __OBD_VMALLOC_VERBOSE(ptr, cptab, cpt, size) \
do { \
(ptr) = cptab == NULL ? \
- vmalloc(size) : \
- cfs_cpt_vmalloc(cptab, cpt, size); \
+ vzalloc(size) : \
+ cfs_cpt_vzalloc(cptab, cpt, size); \
if (unlikely((ptr) == NULL)) { \
CERROR("vmalloc of '" #ptr "' (%d bytes) failed\n", \
(int)(size)); \
CERROR(LPU64" total bytes allocated by Lustre, %d by LNET\n", \
obd_memory_sum(), atomic_read(&libcfs_kmemory)); \
} else { \
- memset(ptr, 0, size); \
OBD_ALLOC_POST(ptr, size, "vmalloced"); \
} \
} while(0)
# define OBD_VMALLOC(ptr, size) \
- __OBD_VMALLOC_VEROBSE(ptr, NULL, 0, size)
+ __OBD_VMALLOC_VERBOSE(ptr, NULL, 0, size)
# define OBD_CPT_VMALLOC(ptr, cptab, cpt, size) \
- __OBD_VMALLOC_VEROBSE(ptr, cptab, cpt, size)
+ __OBD_VMALLOC_VERBOSE(ptr, cptab, cpt, size)
#ifdef __KERNEL__