bpf: introduce bpf_perf_event_output() helper
[deliverable/linux.git] / kernel / bpf / arraymap.c
index 29ace107f2365c05b97f8f8aba54defeb59a6a78..e3cfe46b074f38379136c1cf147a648959af12da 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/filter.h>
+#include <linux/perf_event.h>
 
 /* Called from syscall */
 static struct bpf_map *array_map_alloc(union bpf_attr *attr)
@@ -48,7 +49,7 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr)
        array->map.key_size = attr->key_size;
        array->map.value_size = attr->value_size;
        array->map.max_entries = attr->max_entries;
-
+       array->map.pages = round_up(array_size, PAGE_SIZE) >> PAGE_SHIFT;
        array->elem_size = elem_size;
 
        return &array->map;
@@ -294,6 +295,8 @@ static void *perf_event_fd_array_get_ptr(struct bpf_map *map, int fd)
                return (void *)attr;
 
        if (attr->type != PERF_TYPE_RAW &&
+           !(attr->type == PERF_TYPE_SOFTWARE &&
+             attr->config == PERF_COUNT_SW_BPF_OUTPUT) &&
            attr->type != PERF_TYPE_HARDWARE) {
                perf_event_release_kernel(event);
                return ERR_PTR(-EINVAL);
This page took 0.04206 seconds and 5 git commands to generate.