4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2012, 2014, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 #define DEBUG_SUBSYSTEM S_LNET
39 #include <linux/vmalloc.h>
40 #include <linux/slab.h>
41 #include <linux/highmem.h>
42 #include <libcfs/libcfs.h>
45 cfs_cpt_malloc(struct cfs_cpt_table *cptab, int cpt,
46 size_t nr_bytes, gfp_t flags)
48 return kmalloc_node(nr_bytes, flags,
49 cfs_cpt_spread_node(cptab, cpt));
51 EXPORT_SYMBOL(cfs_cpt_malloc);
54 cfs_cpt_vzalloc(struct cfs_cpt_table *cptab, int cpt, size_t nr_bytes)
56 /* vzalloc_node() sets __GFP_FS by default but no current Kernel
57 * exported entry-point allows for both a NUMA node specification
58 * and a custom allocation flags mask. This may be an issue since
59 * __GFP_FS usage can cause some deadlock situations in our code,
60 * like when memory reclaim started, within the same context of a
61 * thread doing FS operations, that can also attempt conflicting FS
64 return vzalloc_node(nr_bytes, cfs_cpt_spread_node(cptab, cpt));
66 EXPORT_SYMBOL(cfs_cpt_vzalloc);
69 cfs_page_cpt_alloc(struct cfs_cpt_table *cptab, int cpt, gfp_t flags)
71 return alloc_pages_node(cfs_cpt_spread_node(cptab, cpt), flags, 0);
73 EXPORT_SYMBOL(cfs_page_cpt_alloc);
76 cfs_mem_cache_cpt_alloc(struct kmem_cache *cachep, struct cfs_cpt_table *cptab,
79 return kmem_cache_alloc_node(cachep, flags,
80 cfs_cpt_spread_node(cptab, cpt));
82 EXPORT_SYMBOL(cfs_mem_cache_cpt_alloc);