Whamcloud - gitweb
8cdf07dc361f8843876c6e8e2addf07a0f252ba3
[fs/lustre-release.git] / libcfs / libcfs / linux / linux-mem.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
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.
9  *
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).
15  *
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
19  *
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
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2012, Intel Corporation.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36 #define DEBUG_SUBSYSTEM S_LNET
37
38 #include <linux/mm.h>
39 #include <linux/vmalloc.h>
40 #include <linux/slab.h>
41 #include <linux/highmem.h>
42 #include <libcfs/libcfs.h>
43
44 void *
45 cfs_cpt_malloc(struct cfs_cpt_table *cptab, int cpt,
46                size_t nr_bytes, unsigned int flags)
47 {
48         return kmalloc_node(nr_bytes, flags,
49                             cfs_cpt_spread_node(cptab, cpt));
50 }
51 EXPORT_SYMBOL(cfs_cpt_malloc);
52
53 void *
54 cfs_cpt_vzalloc(struct cfs_cpt_table *cptab, int cpt, size_t nr_bytes)
55 {
56         return vzalloc_node(nr_bytes, cfs_cpt_spread_node(cptab, cpt));
57 }
58 EXPORT_SYMBOL(cfs_cpt_vzalloc);
59
60 struct page *
61 cfs_page_cpt_alloc(struct cfs_cpt_table *cptab, int cpt, unsigned int flags)
62 {
63         return alloc_pages_node(cfs_cpt_spread_node(cptab, cpt), flags, 0);
64 }
65 EXPORT_SYMBOL(cfs_page_cpt_alloc);
66
67 void *
68 cfs_mem_cache_cpt_alloc(struct kmem_cache *cachep, struct cfs_cpt_table *cptab,
69                         int cpt, unsigned int flags)
70 {
71         return kmem_cache_alloc_node(cachep, flags,
72                                      cfs_cpt_spread_node(cptab, cpt));
73 }
74 EXPORT_SYMBOL(cfs_mem_cache_cpt_alloc);