Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1191393 > unrolled thread

Re: [PATCH v3 3/3] samples/bpf: example of get selected PMU counter value

Started byAlexei Starovoitov <ast@plumgrid.com>
First post2015-07-24 01:10 +0200
Last post2015-07-24 04:30 +0200
Articles 3 — 2 participants

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.


Contents

  Re: [PATCH v3 3/3] samples/bpf: example of get selected PMU counter  value Alexei Starovoitov <ast@plumgrid.com> - 2015-07-24 01:10 +0200
    Re: [PATCH v3 3/3] samples/bpf: example of get selected PMU counter  value xiakaixu <xiakaixu@huawei.com> - 2015-07-24 04:00 +0200
      Re: [PATCH v3 3/3] samples/bpf: example of get selected PMU counter  value Alexei Starovoitov <ast@plumgrid.com> - 2015-07-24 04:30 +0200

#1191393 — Re: [PATCH v3 3/3] samples/bpf: example of get selected PMU counter value

FromAlexei Starovoitov <ast@plumgrid.com>
Date2015-07-24 01:10 +0200
SubjectRe: [PATCH v3 3/3] samples/bpf: example of get selected PMU counter value
Message-ID<pPxMJ-4tL-11@gated-at.bofh.it>
On 7/23/15 2:42 AM, Kaixu Xia wrote:
> This is a simple example and shows how to use the new ability
> to get the selected Hardware PMU counter value.
>
> Signed-off-by: Kaixu Xia <xiakaixu@huawei.com>
...
> +struct bpf_map_def SEC("maps") my_map = {
> +	.type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
> +	.key_size = sizeof(int),
> +	.value_size = sizeof(unsigned long),
> +	.max_entries = 32,
> +};

wait. how did it work here? value_size should be u32.

--
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/

[toc] | [next] | [standalone]


#1191431

Fromxiakaixu <xiakaixu@huawei.com>
Date2015-07-24 04:00 +0200
Message-ID<pPArf-85G-7@gated-at.bofh.it>
In reply to#1191393
于 2015/7/24 6:59, Alexei Starovoitov 写道:
> On 7/23/15 2:42 AM, Kaixu Xia wrote:
>> This is a simple example and shows how to use the new ability
>> to get the selected Hardware PMU counter value.
>>
>> Signed-off-by: Kaixu Xia <xiakaixu@huawei.com>
> ...
>> +struct bpf_map_def SEC("maps") my_map = {
>> +    .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
>> +    .key_size = sizeof(int),
>> +    .value_size = sizeof(unsigned long),
>> +    .max_entries = 32,
>> +};
> 
> wait. how did it work here? value_size should be u32.

I tested the whole thing on ARM board. You are ringt, it
should be u32.
When create the array map, we choose the array->elem_size as
round_up(attr->value_size, 8), why 8?

Thanks!
> 
> 
> 


--
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/

[toc] | [prev] | [next] | [standalone]


#1191455

FromAlexei Starovoitov <ast@plumgrid.com>
Date2015-07-24 04:30 +0200
Message-ID<pPAUi-xE-7@gated-at.bofh.it>
In reply to#1191431
On 7/23/15 6:54 PM, xiakaixu wrote:
> 于 2015/7/24 6:59, Alexei Starovoitov 写道:
>> On 7/23/15 2:42 AM, Kaixu Xia wrote:
>>> This is a simple example and shows how to use the new ability
>>> to get the selected Hardware PMU counter value.
>>>
>>> Signed-off-by: Kaixu Xia <xiakaixu@huawei.com>
>> ...
>>> +struct bpf_map_def SEC("maps") my_map = {
>>> +    .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
>>> +    .key_size = sizeof(int),
>>> +    .value_size = sizeof(unsigned long),
>>> +    .max_entries = 32,
>>> +};
>>
>> wait. how did it work here? value_size should be u32.
>
> I tested the whole thing on ARM board. You are ringt, it
> should be u32.
> When create the array map, we choose the array->elem_size as
> round_up(attr->value_size, 8), why 8?

because from user space point of view we're storing FDs
which are u32, but kernel stores pointers.
but round_up(attr->value_size, 8) is done because there
can be 8 byte fields in there and we have 8-byte load/store insns.
So whether pointer is 32 or 64-bit they still fit.
--
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/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web