Re: [PATCH v9 02/15] tools/libperf: add properties to struct pollfd *entries objects

From: Alexey Budankov
Date: Mon Jul 06 2020 - 09:06:02 EST



On 06.07.2020 15:24, Jiri Olsa wrote:
> On Fri, Jul 03, 2020 at 10:41:45AM +0300, Alexey Budankov wrote:
>>
>> Store boolean properties per struct pollfd *entries object in a
>> bitmap of int size. Implement fdarray_prop__nonfilterable property
>> to skip object from counting by fdarray_filter().
>
> ok, I think can do it like this, few comments below
>
> thanks,
> jirka
>
>>
>> Signed-off-by: Alexey Budankov <alexey.budankov@xxxxxxxxxxxxxxx>
>> ---
>> tools/lib/api/fd/array.c | 17 +++++++++--------
>> tools/lib/api/fd/array.h | 18 +++++++++++++-----
>> tools/lib/perf/evlist.c | 10 +++++-----
>> tools/lib/perf/include/internal/evlist.h | 2 +-
>> tools/perf/tests/fdarray.c | 2 +-
>> tools/perf/util/evlist.c | 2 +-
>> 6 files changed, 30 insertions(+), 21 deletions(-)

<SNIP>

>>
>> diff --git a/tools/lib/api/fd/array.h b/tools/lib/api/fd/array.h
>> index b39557d1a88f..19b6a34aeea5 100644
>> --- a/tools/lib/api/fd/array.h
>> +++ b/tools/lib/api/fd/array.h
>> @@ -21,10 +21,18 @@ struct fdarray {
>> int nr_alloc;
>> int nr_autogrow;
>> struct pollfd *entries;
>> - union {
>> - int idx;
>> - void *ptr;
>> - } *priv;
>> + struct {
>> + union {
>> + int idx;
>> + void *ptr;
>> + } priv;
>> + int bits;
>> + } *prop;
>> +};
>
> why not keeping the 'priv' as a struct, like:
>
> struct {
> union {
> int idx;
> void *ptr;
> };
> unsigned int flags;
> } *priv;
>
> I think we would have much less changes, also please rename bits
> to flags and use some unsigned type for that

Well, I supposed that priv is short for private what means the layout
of struct priv object is opaque to fdarray implementation and it just
passes the object as a void pointer to external callbacks (e.g in __filter()).
So I preserved this semantics and wrapped and extended priv object
with with flags field. It can be implemented with struct priv if you like.

>
>> +
>> +enum fdarray_props {
>> + fdarray_prop__default = 0x00000000,
>> + fdarray_prop__nonfilterable = 0x00000001
>> };
>
> s/fdarray_props/fdarray_flag/

Accepted.

Alexey