Subversion Repositories shark

Rev

Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 1
#ifndef __LINUX_GFP_H
2
#define __LINUX_GFP_H
3
 
4
#include <linux/mmzone.h>
5
#include <linux/stddef.h>
6
#include <linux/linkage.h>
7
/*
8
 * GFP bitmasks..
9
 */
10
/* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low two bits) */
11
#define __GFP_DMA       0x01
12
#define __GFP_HIGHMEM   0x02
13
 
14
/*
15
 * Action modifiers - doesn't change the zoning
16
 *
17
 * __GFP_REPEAT: Try hard to allocate the memory, but the allocation attempt
18
 * _might_ fail.  This depends upon the particular VM implementation.
19
 *
20
 * __GFP_NOFAIL: The VM implementation _must_ retry infinitely: the caller
21
 * cannot handle allocation failures.
22
 *
23
 * __GFP_NORETRY: The VM implementation must not retry indefinitely.
24
 */
25
#define __GFP_WAIT      0x10    /* Can wait and reschedule? */
26
#define __GFP_HIGH      0x20    /* Should access emergency pools? */
27
#define __GFP_IO        0x40    /* Can start physical IO? */
28
#define __GFP_FS        0x80    /* Can call down to low-level FS? */
29
#define __GFP_COLD      0x100   /* Cache-cold page required */
30
#define __GFP_NOWARN    0x200   /* Suppress page allocation failure warning */
31
#define __GFP_REPEAT    0x400   /* Retry the allocation.  Might fail */
32
#define __GFP_NOFAIL    0x800   /* Retry for ever.  Cannot fail */
33
#define __GFP_NORETRY   0x1000  /* Do not retry.  Might fail */
34
#define __GFP_NO_GROW   0x2000  /* Slab internal usage */
35
 
36
#define __GFP_BITS_SHIFT 16     /* Room for 16 __GFP_FOO bits */
37
#define __GFP_BITS_MASK ((1 << __GFP_BITS_SHIFT) - 1)
38
 
39
#define GFP_ATOMIC      (__GFP_HIGH)
40
#define GFP_NOIO        (__GFP_WAIT)
41
#define GFP_NOFS        (__GFP_WAIT | __GFP_IO)
42
#define GFP_KERNEL      (__GFP_WAIT | __GFP_IO | __GFP_FS)
43
#define GFP_USER        (__GFP_WAIT | __GFP_IO | __GFP_FS)
44
#define GFP_HIGHUSER    (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HIGHMEM)
45
 
46
/* Flag - indicates that the buffer will be suitable for DMA.  Ignored on some
47
   platforms, used as appropriate on others */
48
 
49
#define GFP_DMA         __GFP_DMA
50
 
51
 
52
/*
53
 * There is only one page-allocator function, and two main namespaces to
54
 * it. The alloc_page*() variants return 'struct page *' and as such
55
 * can allocate highmem pages, the *get*page*() variants return
56
 * virtual kernel addresses to the allocated page(s).
57
 */
58
 
59
/*
60
 * We get the zone list from the current node and the gfp_mask.
61
 * This zone list contains a maximum of MAXNODES*MAX_NR_ZONES zones.
62
 *
63
 * For the normal case of non-DISCONTIGMEM systems the NODE_DATA() gets
64
 * optimized to &contig_page_data at compile-time.
65
 */
66
extern struct page * FASTCALL(__alloc_pages(unsigned int, unsigned int, struct zonelist *));
67
static inline struct page * alloc_pages_node(int nid, unsigned int gfp_mask, unsigned int order)
68
{
69
        if (unlikely(order >= MAX_ORDER))
70
                return NULL;
71
 
72
        return __alloc_pages(gfp_mask, order, NODE_DATA(nid)->node_zonelists + (gfp_mask & GFP_ZONEMASK));
73
}
74
 
75
#define alloc_pages(gfp_mask, order) \
76
                alloc_pages_node(numa_node_id(), gfp_mask, order)
77
#define alloc_page(gfp_mask) \
78
                alloc_pages_node(numa_node_id(), gfp_mask, 0)
79
 
80
extern unsigned long FASTCALL(__get_free_pages(unsigned int gfp_mask, unsigned int order));
81
extern unsigned long FASTCALL(get_zeroed_page(unsigned int gfp_mask));
82
 
83
#define __get_free_page(gfp_mask) \
84
                __get_free_pages((gfp_mask),0)
85
 
86
#define __get_dma_pages(gfp_mask, order) \
87
                __get_free_pages((gfp_mask) | GFP_DMA,(order))
88
 
89
extern void FASTCALL(__free_pages(struct page *page, unsigned int order));
90
extern void FASTCALL(free_pages(unsigned long addr, unsigned int order));
91
extern void FASTCALL(free_hot_page(struct page *page));
92
extern void FASTCALL(free_cold_page(struct page *page));
93
 
94
#define __free_page(page) __free_pages((page), 0)
95
#define free_page(addr) free_pages((addr),0)
96
 
97
void page_alloc_init(void);
98
 
99
#endif /* __LINUX_GFP_H */