[PATCH 9/9] staging/lustre: clean up and remove libcfs/linux/linux-mem.c

Peng Tao bergwolf at gmail.com
Mon Jun 3 13:58:22 UTC 2013


Those are simple wrappers for numa allocator. We don't need them.

Signed-off-by: Peng Tao <tao.peng at emc.com>
Signed-off-by: Andreas Dilger <andreas.dilger at intel.com>
---
 .../lustre/include/linux/libcfs/libcfs_private.h   |    4 +-
 .../lustre/include/linux/libcfs/linux/linux-mem.h  |   19 -----
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    5 +-
 drivers/staging/lustre/lnet/lnet/router.c          |    5 +-
 drivers/staging/lustre/lnet/selftest/rpc.c         |    3 +-
 .../staging/lustre/lustre/include/obd_support.h    |   21 +++--
 drivers/staging/lustre/lustre/libcfs/Makefile      |    2 +-
 .../staging/lustre/lustre/libcfs/linux/linux-mem.c |   87 --------------------
 8 files changed, 21 insertions(+), 125 deletions(-)
 delete mode 100644 drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
index 62bf32f..c4f5907 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
@@ -161,8 +161,8 @@ do {									    \
 do {									    \
 	LIBCFS_ALLOC_PRE((size), (mask));				    \
 	(ptr) = (size) <= LIBCFS_VMALLOC_SIZE ?				    \
-		cfs_cpt_malloc((cptab), (cpt), (size), (mask)) :	    \
-		cfs_cpt_vmalloc((cptab), (cpt), (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)
 
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h
index f6cb463..042a2bc 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h
@@ -79,25 +79,6 @@
 	do { __oldfs = get_fs(); set_fs(get_ds());} while(0)
 #define MMSPACE_CLOSE	       set_fs(__oldfs)
 
-
-/*
- * NUMA allocators
- *
- * NB: we will rename these functions in a separate patch:
- * - rename kmalloc to cfs_malloc
- * - rename kmalloc/free_page to cfs_page_alloc/free
- * - rename kmalloc/free_large to cfs_vmalloc/vfree
- */
-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,
-			     size_t nr_bytes);
-extern struct page *cfs_page_cpt_alloc(struct cfs_cpt_table *cptab,
-				      int cpt, unsigned int flags);
-extern void *cfs_mem_cache_cpt_alloc(struct kmem_cache *cachep,
-				     struct cfs_cpt_table *cptab,
-				     int cpt, unsigned int flags);
-
 /*
  * Shrinker
  */
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index f4b958b..221d373 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1203,8 +1203,9 @@ kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages)
 	p->ibp_npages = npages;
 
 	for (i = 0; i < npages; i++) {
-		p->ibp_pages[i] = cfs_page_cpt_alloc(lnet_cpt_table(), cpt,
-						     __GFP_IO);
+		p->ibp_pages[i] = alloc_pages_node(
+				    cfs_cpt_spread_node(lnet_cpt_table(), cpt),
+				    __GFP_IO, 0);
 		if (p->ibp_pages[i] == NULL) {
 			CERROR("Can't allocate page %d of %d\n", i, npages);
 			kiblnd_free_pages(p);
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index c5ff97a..a326ce0 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -1247,8 +1247,9 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt)
 	rb->rb_pool = rbp;
 
 	for (i = 0; i < npages; i++) {
-		page = cfs_page_cpt_alloc(lnet_cpt_table(), cpt,
-					  __GFP_ZERO | GFP_IOFS);
+		page = alloc_pages_node(
+				cfs_cpt_spread_node(lnet_cpt_table(), cpt),
+				__GFP_ZERO | GFP_IOFS, 0);
 		if (page == NULL) {
 			while (--i >= 0)
 				__free_page(rb->rb_kiov[i].kiov_page);
diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c
index 91d83f4..bc1f38b 100644
--- a/drivers/staging/lustre/lnet/selftest/rpc.c
+++ b/drivers/staging/lustre/lnet/selftest/rpc.c
@@ -146,7 +146,8 @@ srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink)
 		struct page *pg;
 		int	    nob;
 
-		pg = cfs_page_cpt_alloc(lnet_cpt_table(), cpt, GFP_IOFS);
+		pg = alloc_pages_node(cfs_cpt_spread_node(lnet_cpt_table(), cpt),
+				      GFP_IOFS, 0);
 		if (pg == NULL) {
 			CERROR("Can't allocate page %d of %d\n", i, bulk_npg);
 			srpc_free_bulk(bk);
diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h
index ee70867..b5d40af 100644
--- a/drivers/staging/lustre/lustre/include/obd_support.h
+++ b/drivers/staging/lustre/lustre/include/obd_support.h
@@ -592,7 +592,7 @@ static inline void obd_pages_sub(int order)
 do {									      \
 	(ptr) = (cptab) == NULL ?					      \
 		kmalloc(size, flags) :				      \
-		cfs_cpt_malloc(cptab, cpt, size, flags);		      \
+		kmalloc_node(size, flags, cfs_cpt_spread_node(cptab, cpt));   \
 	if (unlikely((ptr) == NULL)) {					\
 		CERROR("kmalloc of '" #ptr "' (%d bytes) failed at %s:%d\n",  \
 		       (int)(size), __FILE__, __LINE__);		      \
@@ -614,14 +614,14 @@ do {									      \
 #define __OBD_MALLOC_VERBOSE(ptr, cptab, cpt, size, flags)		      \
 do {									      \
 	(ptr) = (cptab) == NULL ?					      \
-		kmalloc(size, flags) :				      \
-		cfs_cpt_malloc(cptab, cpt, size, flags);		      \
+		kmalloc(size, flags | __GFP_ZERO) :			      \
+		kmalloc_node(size, flags | __GFP_ZERO,			      \
+			     cfs_cpt_spread_node(cptab, cpt));		      \
 	if (likely((ptr) != NULL &&					   \
 		   (!HAS_FAIL_ALLOC_FLAG || obd_alloc_fail_rate == 0 ||       \
 		    !obd_alloc_fail(ptr, #ptr, "km", size,		    \
 				    __FILE__, __LINE__) ||		    \
 		    OBD_FREE_RTN0(ptr)))){				    \
-		memset(ptr, 0, size);					 \
 		OBD_ALLOC_POST(ptr, size, "kmalloced");		       \
 	}								     \
 } while (0)
@@ -647,15 +647,14 @@ do {									      \
 # define __OBD_VMALLOC_VEROBSE(ptr, cptab, cpt, size)			      \
 do {									      \
 	(ptr) = cptab == NULL ?						      \
-		vmalloc(size) :					      \
-		cfs_cpt_vmalloc(cptab, cpt, size);			      \
+		vzalloc(size) :						      \
+		vzalloc_node(size, cfs_cpt_spread_node(cptab, cpt));	      \
 	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)
@@ -756,14 +755,14 @@ do {									      \
 do {									      \
 	LASSERT(ergo((type) != GFP_ATOMIC, !in_interrupt()));	      \
 	(ptr) = (cptab) == NULL ?					      \
-		kmem_cache_alloc(slab, type) :			      \
-		cfs_mem_cache_cpt_alloc(slab, cptab, cpt, type);	      \
+		kmem_cache_alloc(slab, type | __GFP_ZERO) :		\
+		kmem_cache_alloc_node(slab, type | __GFP_ZERO,		\
+				      cfs_cpt_spread_node(cptab, cpt));	\
 	if (likely((ptr) != NULL &&					   \
 		   (!HAS_FAIL_ALLOC_FLAG || obd_alloc_fail_rate == 0 ||       \
 		    !obd_alloc_fail(ptr, #ptr, "slab-", size,		 \
 				    __FILE__, __LINE__) ||		    \
 		    OBD_SLAB_FREE_RTN0(ptr, slab)))) {			\
-		memset(ptr, 0, size);					 \
 		OBD_ALLOC_POST(ptr, size, "slab-alloced");		    \
 	}								     \
 } while(0)
@@ -811,7 +810,7 @@ do {									  \
 do {									      \
 	(ptr) = (cptab) == NULL ?					      \
 		alloc_page(gfp_mask) :				      \
-		cfs_page_cpt_alloc(cptab, cpt, gfp_mask);		      \
+		alloc_pages_node(cfs_cpt_spread_node(cptab, cpt), gfp_mask, 0);\
 	if (unlikely((ptr) == NULL)) {					\
 		CERROR("alloc_pages of '" #ptr "' %d page(s) / "LPU64" bytes "\
 		       "failed\n", (int)1,				    \
diff --git a/drivers/staging/lustre/lustre/libcfs/Makefile b/drivers/staging/lustre/lustre/libcfs/Makefile
index 0d2cb62..9d4c4b6 100644
--- a/drivers/staging/lustre/lustre/libcfs/Makefile
+++ b/drivers/staging/lustre/lustre/libcfs/Makefile
@@ -1,7 +1,7 @@
 obj-$(CONFIG_LUSTRE_FS) += libcfs.o
 
 libcfs-linux-objs := linux-tracefile.o linux-debug.o
-libcfs-linux-objs += linux-prim.o linux-mem.o linux-cpu.o
+libcfs-linux-objs += linux-prim.o linux-cpu.o
 libcfs-linux-objs += linux-tcpip.o
 libcfs-linux-objs += linux-proc.o linux-curproc.o
 libcfs-linux-objs += linux-module.o
diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c
deleted file mode 100644
index 3be3ede..0000000
--- a/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-#define DEBUG_SUBSYSTEM S_LNET
-
-#include <linux/mm.h>
-#include <linux/vmalloc.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-#include <linux/libcfs/libcfs.h>
-
-/*
- * NB: we will rename some of above functions in another patch:
- * - rename kmalloc to cfs_malloc
- * - rename kmalloc/free_page to cfs_page_alloc/free
- * - rename kmalloc/free_large to cfs_vmalloc/vfree
- */
-
-void *
-cfs_cpt_malloc(struct cfs_cpt_table *cptab, int cpt,
-	       size_t nr_bytes, unsigned int flags)
-{
-	void    *ptr;
-
-	ptr = kmalloc_node(nr_bytes, flags,
-			   cfs_cpt_spread_node(cptab, cpt));
-	if (ptr != NULL && (flags & __GFP_ZERO) != 0)
-		memset(ptr, 0, nr_bytes);
-
-	return ptr;
-}
-EXPORT_SYMBOL(cfs_cpt_malloc);
-
-void *
-cfs_cpt_vmalloc(struct cfs_cpt_table *cptab, int cpt, size_t nr_bytes)
-{
-	return vmalloc_node(nr_bytes, cfs_cpt_spread_node(cptab, cpt));
-}
-EXPORT_SYMBOL(cfs_cpt_vmalloc);
-
-struct page *
-cfs_page_cpt_alloc(struct cfs_cpt_table *cptab, int cpt, unsigned int flags)
-{
-	return alloc_pages_node(cfs_cpt_spread_node(cptab, cpt), flags, 0);
-}
-EXPORT_SYMBOL(cfs_page_cpt_alloc);
-
-void *
-cfs_mem_cache_cpt_alloc(struct kmem_cache *cachep, struct cfs_cpt_table *cptab,
-			int cpt, unsigned int flags)
-{
-	return kmem_cache_alloc_node(cachep, flags,
-				     cfs_cpt_spread_node(cptab, cpt));
-}
-EXPORT_SYMBOL(cfs_mem_cache_cpt_alloc);
-- 
1.7.9.5




More information about the devel mailing list