Commit 49c02a75 authored by Peng Tao's avatar Peng Tao Committed by Greg Kroah-Hartman

staging/lustre: clean up and remove libcfs/linux/linux-mem.c

Those are simple wrappers for numa allocator. We don't need them.
Signed-off-by: default avatarPeng Tao <tao.peng@emc.com>
Signed-off-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c3dbb781
...@@ -161,8 +161,8 @@ do { \ ...@@ -161,8 +161,8 @@ do { \
do { \ do { \
LIBCFS_ALLOC_PRE((size), (mask)); \ LIBCFS_ALLOC_PRE((size), (mask)); \
(ptr) = (size) <= LIBCFS_VMALLOC_SIZE ? \ (ptr) = (size) <= LIBCFS_VMALLOC_SIZE ? \
cfs_cpt_malloc((cptab), (cpt), (size), (mask)) : \ kmalloc_node((size), (mask), cfs_cpt_spread_node(cptab, cpt)) :\
cfs_cpt_vmalloc((cptab), (cpt), (size)); \ vmalloc_node(size, cfs_cpt_spread_node(cptab, cpt)); \
LIBCFS_ALLOC_POST((ptr), (size)); \ LIBCFS_ALLOC_POST((ptr), (size)); \
} while (0) } while (0)
......
...@@ -79,25 +79,6 @@ ...@@ -79,25 +79,6 @@
do { __oldfs = get_fs(); set_fs(get_ds());} while(0) do { __oldfs = get_fs(); set_fs(get_ds());} while(0)
#define MMSPACE_CLOSE set_fs(__oldfs) #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 * Shrinker
*/ */
......
...@@ -1203,8 +1203,9 @@ kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages) ...@@ -1203,8 +1203,9 @@ kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages)
p->ibp_npages = npages; p->ibp_npages = npages;
for (i = 0; i < npages; i++) { for (i = 0; i < npages; i++) {
p->ibp_pages[i] = cfs_page_cpt_alloc(lnet_cpt_table(), cpt, p->ibp_pages[i] = alloc_pages_node(
__GFP_IO); cfs_cpt_spread_node(lnet_cpt_table(), cpt),
__GFP_IO, 0);
if (p->ibp_pages[i] == NULL) { if (p->ibp_pages[i] == NULL) {
CERROR("Can't allocate page %d of %d\n", i, npages); CERROR("Can't allocate page %d of %d\n", i, npages);
kiblnd_free_pages(p); kiblnd_free_pages(p);
......
...@@ -1247,8 +1247,9 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt) ...@@ -1247,8 +1247,9 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt)
rb->rb_pool = rbp; rb->rb_pool = rbp;
for (i = 0; i < npages; i++) { for (i = 0; i < npages; i++) {
page = cfs_page_cpt_alloc(lnet_cpt_table(), cpt, page = alloc_pages_node(
__GFP_ZERO | GFP_IOFS); cfs_cpt_spread_node(lnet_cpt_table(), cpt),
__GFP_ZERO | GFP_IOFS, 0);
if (page == NULL) { if (page == NULL) {
while (--i >= 0) while (--i >= 0)
__free_page(rb->rb_kiov[i].kiov_page); __free_page(rb->rb_kiov[i].kiov_page);
......
...@@ -146,7 +146,8 @@ srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink) ...@@ -146,7 +146,8 @@ srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink)
struct page *pg; struct page *pg;
int nob; 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) { if (pg == NULL) {
CERROR("Can't allocate page %d of %d\n", i, bulk_npg); CERROR("Can't allocate page %d of %d\n", i, bulk_npg);
srpc_free_bulk(bk); srpc_free_bulk(bk);
......
...@@ -592,7 +592,7 @@ static inline void obd_pages_sub(int order) ...@@ -592,7 +592,7 @@ static inline void obd_pages_sub(int order)
do { \ do { \
(ptr) = (cptab) == NULL ? \ (ptr) = (cptab) == NULL ? \
kmalloc(size, flags) : \ kmalloc(size, flags) : \
cfs_cpt_malloc(cptab, cpt, size, flags); \ kmalloc_node(size, flags, cfs_cpt_spread_node(cptab, cpt)); \
if (unlikely((ptr) == NULL)) { \ if (unlikely((ptr) == NULL)) { \
CERROR("kmalloc of '" #ptr "' (%d bytes) failed at %s:%d\n", \ CERROR("kmalloc of '" #ptr "' (%d bytes) failed at %s:%d\n", \
(int)(size), __FILE__, __LINE__); \ (int)(size), __FILE__, __LINE__); \
...@@ -614,14 +614,14 @@ do { \ ...@@ -614,14 +614,14 @@ do { \
#define __OBD_MALLOC_VERBOSE(ptr, cptab, cpt, size, flags) \ #define __OBD_MALLOC_VERBOSE(ptr, cptab, cpt, size, flags) \
do { \ do { \
(ptr) = (cptab) == NULL ? \ (ptr) = (cptab) == NULL ? \
kmalloc(size, flags) : \ kmalloc(size, flags | __GFP_ZERO) : \
cfs_cpt_malloc(cptab, cpt, size, flags); \ kmalloc_node(size, flags | __GFP_ZERO, \
cfs_cpt_spread_node(cptab, cpt)); \
if (likely((ptr) != NULL && \ if (likely((ptr) != NULL && \
(!HAS_FAIL_ALLOC_FLAG || obd_alloc_fail_rate == 0 || \ (!HAS_FAIL_ALLOC_FLAG || obd_alloc_fail_rate == 0 || \
!obd_alloc_fail(ptr, #ptr, "km", size, \ !obd_alloc_fail(ptr, #ptr, "km", size, \
__FILE__, __LINE__) || \ __FILE__, __LINE__) || \
OBD_FREE_RTN0(ptr)))){ \ OBD_FREE_RTN0(ptr)))){ \
memset(ptr, 0, size); \
OBD_ALLOC_POST(ptr, size, "kmalloced"); \ OBD_ALLOC_POST(ptr, size, "kmalloced"); \
} \ } \
} while (0) } while (0)
...@@ -647,15 +647,14 @@ do { \ ...@@ -647,15 +647,14 @@ do { \
# define __OBD_VMALLOC_VEROBSE(ptr, cptab, cpt, size) \ # define __OBD_VMALLOC_VEROBSE(ptr, cptab, cpt, size) \
do { \ do { \
(ptr) = cptab == NULL ? \ (ptr) = cptab == NULL ? \
vmalloc(size) : \ vzalloc(size) : \
cfs_cpt_vmalloc(cptab, cpt, size); \ vzalloc_node(size, cfs_cpt_spread_node(cptab, cpt)); \
if (unlikely((ptr) == NULL)) { \ if (unlikely((ptr) == NULL)) { \
CERROR("vmalloc of '" #ptr "' (%d bytes) failed\n", \ CERROR("vmalloc of '" #ptr "' (%d bytes) failed\n", \
(int)(size)); \ (int)(size)); \
CERROR(LPU64" total bytes allocated by Lustre, %d by LNET\n", \ CERROR(LPU64" total bytes allocated by Lustre, %d by LNET\n", \
obd_memory_sum(), atomic_read(&libcfs_kmemory)); \ obd_memory_sum(), atomic_read(&libcfs_kmemory)); \
} else { \ } else { \
memset(ptr, 0, size); \
OBD_ALLOC_POST(ptr, size, "vmalloced"); \ OBD_ALLOC_POST(ptr, size, "vmalloced"); \
} \ } \
} while(0) } while(0)
...@@ -756,14 +755,14 @@ do { \ ...@@ -756,14 +755,14 @@ do { \
do { \ do { \
LASSERT(ergo((type) != GFP_ATOMIC, !in_interrupt())); \ LASSERT(ergo((type) != GFP_ATOMIC, !in_interrupt())); \
(ptr) = (cptab) == NULL ? \ (ptr) = (cptab) == NULL ? \
kmem_cache_alloc(slab, type) : \ kmem_cache_alloc(slab, type | __GFP_ZERO) : \
cfs_mem_cache_cpt_alloc(slab, cptab, cpt, type); \ kmem_cache_alloc_node(slab, type | __GFP_ZERO, \
cfs_cpt_spread_node(cptab, cpt)); \
if (likely((ptr) != NULL && \ if (likely((ptr) != NULL && \
(!HAS_FAIL_ALLOC_FLAG || obd_alloc_fail_rate == 0 || \ (!HAS_FAIL_ALLOC_FLAG || obd_alloc_fail_rate == 0 || \
!obd_alloc_fail(ptr, #ptr, "slab-", size, \ !obd_alloc_fail(ptr, #ptr, "slab-", size, \
__FILE__, __LINE__) || \ __FILE__, __LINE__) || \
OBD_SLAB_FREE_RTN0(ptr, slab)))) { \ OBD_SLAB_FREE_RTN0(ptr, slab)))) { \
memset(ptr, 0, size); \
OBD_ALLOC_POST(ptr, size, "slab-alloced"); \ OBD_ALLOC_POST(ptr, size, "slab-alloced"); \
} \ } \
} while(0) } while(0)
...@@ -811,7 +810,7 @@ do { \ ...@@ -811,7 +810,7 @@ do { \
do { \ do { \
(ptr) = (cptab) == NULL ? \ (ptr) = (cptab) == NULL ? \
alloc_page(gfp_mask) : \ 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)) { \ if (unlikely((ptr) == NULL)) { \
CERROR("alloc_pages of '" #ptr "' %d page(s) / "LPU64" bytes "\ CERROR("alloc_pages of '" #ptr "' %d page(s) / "LPU64" bytes "\
"failed\n", (int)1, \ "failed\n", (int)1, \
......
obj-$(CONFIG_LUSTRE_FS) += libcfs.o obj-$(CONFIG_LUSTRE_FS) += libcfs.o
libcfs-linux-objs := linux-tracefile.o linux-debug.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-tcpip.o
libcfs-linux-objs += linux-proc.o linux-curproc.o libcfs-linux-objs += linux-proc.o linux-curproc.o
libcfs-linux-objs += linux-module.o libcfs-linux-objs += linux-module.o
......
/*
* 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);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment