1KMALLOC_ARRAY(9) Memory Management in Linux KMALLOC_ARRAY(9)
2
3
4
6 kmalloc_array - allocate memory for an array.
7
9 void * kmalloc_array(size_t n, size_t size, gfp_t flags);
10
12 n
13 number of elements.
14
15 size
16 element size.
17
18 flags
19 the type of memory to allocate.
20
22 The flags argument may be one of:
23
24 GFP_USER - Allocate memory on behalf of user. May sleep.
25
26 GFP_KERNEL - Allocate normal kernel ram. May sleep.
27
28 GFP_ATOMIC - Allocation will not sleep. May use emergency pools. For
29 example, use this inside interrupt handlers.
30
31 GFP_HIGHUSER - Allocate pages from high memory.
32
33 GFP_NOIO - Do not do any I/O at all while trying to get memory.
34
35 GFP_NOFS - Do not make any fs calls while trying to get memory.
36
37 GFP_NOWAIT - Allocation will not sleep.
38
39 __GFP_THISNODE - Allocate node-local memory only.
40
41 GFP_DMA - Allocation suitable for DMA. Should only be used for kmalloc
42 caches. Otherwise, use a slab created with SLAB_DMA.
43
44 Also it is possible to set different flags by OR'ing in one or more of
45 the following additional flags:
46
47 __GFP_COLD - Request cache-cold pages instead of trying to return
48 cache-warm pages.
49
50 __GFP_HIGH - This allocation has high priority and may use emergency
51 pools.
52
53 __GFP_NOFAIL - Indicate that this allocation is in no way allowed to
54 fail (think twice before using).
55
56 __GFP_NORETRY - If memory is not immediately available, then give up at
57 once.
58
59 __GFP_NOWARN - If allocation fails, don't issue any warnings.
60
61 __GFP_REPEAT - If allocation fails initially, try once more before
62 failing.
63
64 There are other flags available as well, but these are not intended for
65 general use, and so are not documented here. For a full list of
66 potential flags, always refer to linux/gfp.h.
67
69Kernel Hackers Manual 3.10 June 2019 KMALLOC_ARRAY(9)