Deleted Added
full compact
gfp.h (271127) gfp.h (282513)
1/*-
2 * Copyright (c) 2010 Isilon Systems, Inc.
3 * Copyright (c) 2010 iX Systems, Inc.
4 * Copyright (c) 2010 Panasas, Inc.
5 * Copyright (c) 2013 Mellanox Technologies, Ltd.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 16 unchanged lines hidden (view full) ---

25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef _LINUX_GFP_H_
31#define _LINUX_GFP_H_
32
1/*-
2 * Copyright (c) 2010 Isilon Systems, Inc.
3 * Copyright (c) 2010 iX Systems, Inc.
4 * Copyright (c) 2010 Panasas, Inc.
5 * Copyright (c) 2013 Mellanox Technologies, Ltd.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 16 unchanged lines hidden (view full) ---

25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef _LINUX_GFP_H_
31#define _LINUX_GFP_H_
32
33#include <sys/cdefs.h>
34#include <sys/types.h>
33#include <sys/systm.h>
34#include <sys/malloc.h>
35
36#include <linux/page.h>
37
38#include <vm/vm_param.h>
39#include <vm/vm_object.h>
40#include <vm/vm_extern.h>

--- 57 unchanged lines hidden (view full) ---

98 size_t size;
99
100 if (m == NULL)
101 return;
102 size = PAGE_SIZE << order;
103 kmem_free(kmem_arena, (vm_offset_t)page_address(m), size);
104}
105
35#include <sys/systm.h>
36#include <sys/malloc.h>
37
38#include <linux/page.h>
39
40#include <vm/vm_param.h>
41#include <vm/vm_object.h>
42#include <vm/vm_extern.h>

--- 57 unchanged lines hidden (view full) ---

100 size_t size;
101
102 if (m == NULL)
103 return;
104 size = PAGE_SIZE << order;
105 kmem_free(kmem_arena, (vm_offset_t)page_address(m), size);
106}
107
108static inline void free_pages(uintptr_t addr, unsigned int order)
109{
110 if (addr == 0)
111 return;
112 __free_pages(virt_to_page((void *)addr), order);
113}
114
106/*
107 * Alloc pages allocates directly from the buddy allocator on linux so
108 * order specifies a power of two bucket of pages and the results
109 * are expected to be aligned on the size as well.
110 */
111static inline struct page *
112alloc_pages(gfp_t gfp_mask, unsigned int order)
113{
114 unsigned long page;
115 size_t size;
116
117 size = PAGE_SIZE << order;
118 page = kmem_alloc_contig(kmem_arena, size, gfp_mask, 0, -1,
119 size, 0, VM_MEMATTR_DEFAULT);
120 if (page == 0)
121 return (NULL);
122 return (virt_to_page(page));
123}
124
115/*
116 * Alloc pages allocates directly from the buddy allocator on linux so
117 * order specifies a power of two bucket of pages and the results
118 * are expected to be aligned on the size as well.
119 */
120static inline struct page *
121alloc_pages(gfp_t gfp_mask, unsigned int order)
122{
123 unsigned long page;
124 size_t size;
125
126 size = PAGE_SIZE << order;
127 page = kmem_alloc_contig(kmem_arena, size, gfp_mask, 0, -1,
128 size, 0, VM_MEMATTR_DEFAULT);
129 if (page == 0)
130 return (NULL);
131 return (virt_to_page(page));
132}
133
134static inline uintptr_t __get_free_pages(gfp_t gfp_mask, unsigned int order)
135{
136 struct page *page;
137
138 page = alloc_pages(gfp_mask, order);
139 if (page == NULL)
140 return (0);
141 return ((uintptr_t)page_address(page));
142}
143
125#define alloc_pages_node(node, mask, order) alloc_pages(mask, order)
126
127#define kmalloc_node(chunk, mask, node) kmalloc(chunk, mask)
128
129#endif /* _LINUX_GFP_H_ */
144#define alloc_pages_node(node, mask, order) alloc_pages(mask, order)
145
146#define kmalloc_node(chunk, mask, node) kmalloc(chunk, mask)
147
148#endif /* _LINUX_GFP_H_ */