diff options
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r-- | kernel/bpf/syscall.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 62f6bced3a3c..afca36f53c49 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c | |||
@@ -136,21 +136,29 @@ static struct bpf_map *find_and_alloc_map(union bpf_attr *attr) | |||
136 | 136 | ||
137 | void *bpf_map_area_alloc(size_t size, int numa_node) | 137 | void *bpf_map_area_alloc(size_t size, int numa_node) |
138 | { | 138 | { |
139 | /* We definitely need __GFP_NORETRY, so OOM killer doesn't | 139 | /* We really just want to fail instead of triggering OOM killer |
140 | * trigger under memory pressure as we really just want to | 140 | * under memory pressure, therefore we set __GFP_NORETRY to kmalloc, |
141 | * fail instead. | 141 | * which is used for lower order allocation requests. |
142 | * | ||
143 | * It has been observed that higher order allocation requests done by | ||
144 | * vmalloc with __GFP_NORETRY being set might fail due to not trying | ||
145 | * to reclaim memory from the page cache, thus we set | ||
146 | * __GFP_RETRY_MAYFAIL to avoid such situations. | ||
142 | */ | 147 | */ |
143 | const gfp_t flags = __GFP_NOWARN | __GFP_NORETRY | __GFP_ZERO; | 148 | |
149 | const gfp_t flags = __GFP_NOWARN | __GFP_ZERO; | ||
144 | void *area; | 150 | void *area; |
145 | 151 | ||
146 | if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { | 152 | if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { |
147 | area = kmalloc_node(size, GFP_USER | flags, numa_node); | 153 | area = kmalloc_node(size, GFP_USER | __GFP_NORETRY | flags, |
154 | numa_node); | ||
148 | if (area != NULL) | 155 | if (area != NULL) |
149 | return area; | 156 | return area; |
150 | } | 157 | } |
151 | 158 | ||
152 | return __vmalloc_node_flags_caller(size, numa_node, GFP_KERNEL | flags, | 159 | return __vmalloc_node_flags_caller(size, numa_node, |
153 | __builtin_return_address(0)); | 160 | GFP_KERNEL | __GFP_RETRY_MAYFAIL | |
161 | flags, __builtin_return_address(0)); | ||
154 | } | 162 | } |
155 | 163 | ||
156 | void bpf_map_area_free(void *area) | 164 | void bpf_map_area_free(void *area) |