RE: [PATCH 9/9] samples/bpf: test percpu array map

From: David Laight
Date: Tue Jan 12 2016 - 10:47:56 EST


From: Ming Lei
> Sent: 11 January 2016 15:57
...
> ---
> samples/bpf/test_maps.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 110 insertions(+)
>
> diff --git a/samples/bpf/test_maps.c b/samples/bpf/test_maps.c
> index 6299ee9..ff5d373 100644
> --- a/samples/bpf/test_maps.c
> +++ b/samples/bpf/test_maps.c
> @@ -142,6 +142,106 @@ static void test_arraymap_sanity(int i, void *data)
> close(map_fd);
> }
>
> +static int handle_one_cpu(unsigned cpu, void *val_cpu, void *val)
> +{
> + unsigned long *cnt = val;
> +
> + *cnt += *(long *)val_cpu;

Integer pointer casts ring big alarm bells - they are accidents
waiting to happen.

If the pointers are 'pointer to long' then define them as such.

David