Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1197180 > unrolled thread
| Started by | Alexei Starovoitov <ast@plumgrid.com> |
|---|---|
| First post | 2015-07-31 18:50 +0200 |
| Last post | 2015-07-31 18:50 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v5 3/4] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter Alexei Starovoitov <ast@plumgrid.com> - 2015-07-31 18:50 +0200
| From | Alexei Starovoitov <ast@plumgrid.com> |
|---|---|
| Date | 2015-07-31 18:50 +0200 |
| Subject | Re: [PATCH v5 3/4] bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter |
| Message-ID | <pSlFo-33y-5@gated-at.bofh.it> |
On 7/31/15 4:59 AM, Kaixu Xia wrote:
> +static int check_func_limit(struct bpf_map **mapp, int func_id)
> +{
> + struct bpf_map *map = *mapp;
> +
> + if (map && map->map_type == BPF_MAP_TYPE_PROG_ARRAY &&
> + func_id != BPF_FUNC_tail_call)
> + /* prog_array map type needs extra care:
> + * only allow to pass it into bpf_tail_call() for now.
> + * bpf_map_delete_elem() can be allowed in the future,
> + * while bpf_map_update_elem() must only be done via syscall
> + */
> + return -EINVAL;
> +
> + if (func_id == BPF_FUNC_tail_call &&
> + map->map_type != BPF_MAP_TYPE_PROG_ARRAY)
> + /* don't allow any other map type to be passed into
> + * bpf_tail_call()
> + */
> + return -EINVAL;
> +
> + if (map && map->map_type == BPF_MAP_TYPE_PERF_EVENT_ARRAY &&
> + func_id != BPF_FUNC_perf_event_read)
> + /* perf_event_array map type needs extra care:
> + * only allow to pass it into bpf_perf_event_read() for now.
> + * bpf_map_update/delete_elem() must only be done via syscall
> + */
> + return -EINVAL;
> +
> + if (func_id == BPF_FUNC_perf_event_read &&
> + map->map_type != BPF_MAP_TYPE_PERF_EVENT_ARRAY)
> + /* don't allow any other map type to be passed into
> + * bpf_perf_event_read()
> + */
> + return -EINVAL;
copy paste of comments is too much.
The whole thing probably can be better generalized with an array
{{BPF_MAP_TYPE_PROG_ARRAY, BPF_FUNC_tail_call},
{BPF_MAP_TYPE_PERF_EVENT_ARRAY, BPF_FUNC_perf_event_read},
}
and a loop?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top | Article view | linux.kernel
csiph-web