aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf/arraymap.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-08-20 00:35:44 -0400
committerDavid S. Miller <davem@davemloft.net>2017-08-20 00:35:44 -0400
commit06d0a11f6e4a1f576937758f7fbbbe8ad398e0ef (patch)
treed6350b4b468bb9ca5ebb40f73758af26ec36082f /kernel/bpf/arraymap.c
parentbd76b87962833f6e55264030a227be0f090b1286 (diff)
parentad17d0e6c708805bf9e6686eb747cc528b702e67 (diff)
Merge branch 'bpf-Allow-selecting-numa-node-during-map-creation'
Martin KaFai Lau says: ==================== bpf: Allow selecting numa node during map creation This series allows user to pick the numa node during map creation. The first patch has the details ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel/bpf/arraymap.c')
-rw-r--r--kernel/bpf/arraymap.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index d771a3872500..96e9c5c1dfc9 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -49,13 +49,15 @@ static int bpf_array_alloc_percpu(struct bpf_array *array)
49static struct bpf_map *array_map_alloc(union bpf_attr *attr) 49static struct bpf_map *array_map_alloc(union bpf_attr *attr)
50{ 50{
51 bool percpu = attr->map_type == BPF_MAP_TYPE_PERCPU_ARRAY; 51 bool percpu = attr->map_type == BPF_MAP_TYPE_PERCPU_ARRAY;
52 int numa_node = bpf_map_attr_numa_node(attr);
52 struct bpf_array *array; 53 struct bpf_array *array;
53 u64 array_size; 54 u64 array_size;
54 u32 elem_size; 55 u32 elem_size;
55 56
56 /* check sanity of attributes */ 57 /* check sanity of attributes */
57 if (attr->max_entries == 0 || attr->key_size != 4 || 58 if (attr->max_entries == 0 || attr->key_size != 4 ||
58 attr->value_size == 0 || attr->map_flags) 59 attr->value_size == 0 || attr->map_flags & ~BPF_F_NUMA_NODE ||
60 (percpu && numa_node != NUMA_NO_NODE))
59 return ERR_PTR(-EINVAL); 61 return ERR_PTR(-EINVAL);
60 62
61 if (attr->value_size > KMALLOC_MAX_SIZE) 63 if (attr->value_size > KMALLOC_MAX_SIZE)
@@ -77,7 +79,7 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr)
77 return ERR_PTR(-ENOMEM); 79 return ERR_PTR(-ENOMEM);
78 80
79 /* allocate all map elements and zero-initialize them */ 81 /* allocate all map elements and zero-initialize them */
80 array = bpf_map_area_alloc(array_size); 82 array = bpf_map_area_alloc(array_size, numa_node);
81 if (!array) 83 if (!array)
82 return ERR_PTR(-ENOMEM); 84 return ERR_PTR(-ENOMEM);
83 85
@@ -87,6 +89,7 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr)
87 array->map.value_size = attr->value_size; 89 array->map.value_size = attr->value_size;
88 array->map.max_entries = attr->max_entries; 90 array->map.max_entries = attr->max_entries;
89 array->map.map_flags = attr->map_flags; 91 array->map.map_flags = attr->map_flags;
92 array->map.numa_node = numa_node;
90 array->elem_size = elem_size; 93 array->elem_size = elem_size;
91 94
92 if (!percpu) 95 if (!percpu)