diff options
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r-- | kernel/bpf/syscall.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index b8cb1b3c9bfb..9378f3ba2cbf 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c | |||
@@ -105,7 +105,7 @@ static struct bpf_map *find_and_alloc_map(union bpf_attr *attr) | |||
105 | return map; | 105 | return map; |
106 | } | 106 | } |
107 | 107 | ||
108 | void *bpf_map_area_alloc(size_t size) | 108 | void *bpf_map_area_alloc(size_t size, int numa_node) |
109 | { | 109 | { |
110 | /* We definitely need __GFP_NORETRY, so OOM killer doesn't | 110 | /* We definitely need __GFP_NORETRY, so OOM killer doesn't |
111 | * trigger under memory pressure as we really just want to | 111 | * trigger under memory pressure as we really just want to |
@@ -115,12 +115,13 @@ void *bpf_map_area_alloc(size_t size) | |||
115 | void *area; | 115 | void *area; |
116 | 116 | ||
117 | if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { | 117 | if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) { |
118 | area = kmalloc(size, GFP_USER | flags); | 118 | area = kmalloc_node(size, GFP_USER | flags, numa_node); |
119 | if (area != NULL) | 119 | if (area != NULL) |
120 | return area; | 120 | return area; |
121 | } | 121 | } |
122 | 122 | ||
123 | return __vmalloc(size, GFP_KERNEL | flags, PAGE_KERNEL); | 123 | return __vmalloc_node_flags_caller(size, numa_node, GFP_KERNEL | flags, |
124 | __builtin_return_address(0)); | ||
124 | } | 125 | } |
125 | 126 | ||
126 | void bpf_map_area_free(void *area) | 127 | void bpf_map_area_free(void *area) |
@@ -309,10 +310,11 @@ int bpf_map_new_fd(struct bpf_map *map) | |||
309 | offsetof(union bpf_attr, CMD##_LAST_FIELD) - \ | 310 | offsetof(union bpf_attr, CMD##_LAST_FIELD) - \ |
310 | sizeof(attr->CMD##_LAST_FIELD)) != NULL | 311 | sizeof(attr->CMD##_LAST_FIELD)) != NULL |
311 | 312 | ||
312 | #define BPF_MAP_CREATE_LAST_FIELD inner_map_fd | 313 | #define BPF_MAP_CREATE_LAST_FIELD numa_node |
313 | /* called via syscall */ | 314 | /* called via syscall */ |
314 | static int map_create(union bpf_attr *attr) | 315 | static int map_create(union bpf_attr *attr) |
315 | { | 316 | { |
317 | int numa_node = bpf_map_attr_numa_node(attr); | ||
316 | struct bpf_map *map; | 318 | struct bpf_map *map; |
317 | int err; | 319 | int err; |
318 | 320 | ||
@@ -320,6 +322,10 @@ static int map_create(union bpf_attr *attr) | |||
320 | if (err) | 322 | if (err) |
321 | return -EINVAL; | 323 | return -EINVAL; |
322 | 324 | ||
325 | if (numa_node != NUMA_NO_NODE && | ||
326 | (numa_node >= nr_node_ids || !node_online(numa_node))) | ||
327 | return -EINVAL; | ||
328 | |||
323 | /* find map type and init map: hashtable vs rbtree vs bloom vs ... */ | 329 | /* find map type and init map: hashtable vs rbtree vs bloom vs ... */ |
324 | map = find_and_alloc_map(attr); | 330 | map = find_and_alloc_map(attr); |
325 | if (IS_ERR(map)) | 331 | if (IS_ERR(map)) |