Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp115247ybt; Mon, 6 Jul 2020 05:28:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe1wmumSx61JGk5KjqYseaKVRIqOrvUzEnhdwgQJNq9WmRqV5yBUAm7aycJN17Kk4XEtGx X-Received: by 2002:a17:906:7d9:: with SMTP id m25mr42315555ejc.25.1594038492044; Mon, 06 Jul 2020 05:28:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594038492; cv=none; d=google.com; s=arc-20160816; b=Z6IPehCg9H6Aw39y5PJm7003MdzbAbK34pE4vtP+KIlAZeCmqT92CLFIwcm41pVHdV cpBiUR3uy16/cx5i88dUkhLItP53zx+Hr5OjoB1w9uowInS1Hs9P+O1SdtsNe+0JSqTn 7PMBTJnKtb5oMyytCk8HLbgBXiNxiCcY/ArRQj3Mz5LbezYrWxVZq23GBbbE2XNp9sou Tt0KGynGmogXxcCWFlIPFsXtl0zLXscOlHE82lrmfRYz7Jpi4K32DTS7qch/d0vQhyQt 0mc3VJeHeeYM0ofY1SixBhUOlJK+i2jVtst61YDhnA9Gdz8THPLOREeDL/HBI4h5ohoF BxNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=j2XQ3Uf19JtmVY8IcDpt2UAD19LvHsUmGskneEF0Q2k=; b=PDLlugNwxHmPw4Rd8U0HhIZWZ+mtryI5cPSNKr/SaUAxbJuE3SK6qwlUbP/CiNks2I ds+a8F+OxvNahyIhuQNsVbzTqHCz9vHdmLEMzxekk+MhAQDKWP819/ICOjj1VDiXa8IR yI32awcBWA3ngz9VdfOVdfup49e4UOhLtQ3YVFs3Oftz/Jwhx6j7gzdx6AbJLKJHflEV sqW98KjvfGoMvsUF4yeJTB55w29gJcelKmrXIXdjofZK3IWUu6c/4Jsv2cx6xp4KEsoA FPCm/T/UCzUrQV48/cx+YePRULgOlgHtlGUCvqBU40PjPFMXT6zG1nBtaHyC7xWa6q7f jVnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gGCL075U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si13260232edt.8.2020.07.06.05.27.49; Mon, 06 Jul 2020 05:28:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gGCL075U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729082AbgGFMYV (ORCPT + 99 others); Mon, 6 Jul 2020 08:24:21 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:28513 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729015AbgGFMYV (ORCPT ); Mon, 6 Jul 2020 08:24:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594038259; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=j2XQ3Uf19JtmVY8IcDpt2UAD19LvHsUmGskneEF0Q2k=; b=gGCL075UaR46idQYQOj3qW/bfRaZuosbhflVc0KQHNUut3miFJNlPH8kyRLGqpgEP1UmZU LU5yXXw5pl3CcQ+DT8N/x+C2BFt/0cqro/a7+JHZ6kbFlBHrjNsyQwLOeCh+4JsaBUwb4D fLRnojpehqk0rOnZVze5CkiQPv++Ohg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-224-j9i9UN2fNGm2l7pIGGqkxQ-1; Mon, 06 Jul 2020 08:24:17 -0400 X-MC-Unique: j9i9UN2fNGm2l7pIGGqkxQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7330818FE860; Mon, 6 Jul 2020 12:24:16 +0000 (UTC) Received: from krava (unknown [10.40.193.8]) by smtp.corp.redhat.com (Postfix) with SMTP id A8DDD19D7B; Mon, 6 Jul 2020 12:24:14 +0000 (UTC) Date: Mon, 6 Jul 2020 14:24:13 +0200 From: Jiri Olsa To: Alexey Budankov Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel Subject: Re: [PATCH v9 02/15] tools/libperf: add properties to struct pollfd *entries objects Message-ID: <20200706122413.GB3401866@krava> References: <09bbbc85-7ef9-ff9f-9865-fce6a1a4e903@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <09bbbc85-7ef9-ff9f-9865-fce6a1a4e903@linux.intel.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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(-) > > diff --git a/tools/lib/api/fd/array.c b/tools/lib/api/fd/array.c > index 89f9a2193c2d..a4223f8cb1ce 100644 > --- a/tools/lib/api/fd/array.c > +++ b/tools/lib/api/fd/array.c > @@ -12,31 +12,31 @@ > void fdarray__init(struct fdarray *fda, int nr_autogrow) > { > fda->entries = NULL; > - fda->priv = NULL; > + fda->prop = NULL; > fda->nr = fda->nr_alloc = 0; > fda->nr_autogrow = nr_autogrow; > } > > int fdarray__grow(struct fdarray *fda, int nr) > { > - void *priv; > + void *prop; > int nr_alloc = fda->nr_alloc + nr; > - size_t psize = sizeof(fda->priv[0]) * nr_alloc; > + size_t psize = sizeof(fda->prop[0]) * nr_alloc; > size_t size = sizeof(struct pollfd) * nr_alloc; > struct pollfd *entries = realloc(fda->entries, size); > > if (entries == NULL) > return -ENOMEM; > > - priv = realloc(fda->priv, psize); > - if (priv == NULL) { > + prop = realloc(fda->prop, psize); > + if (prop == NULL) { > free(entries); > return -ENOMEM; > } > > fda->nr_alloc = nr_alloc; > fda->entries = entries; > - fda->priv = priv; > + fda->prop = prop; > return 0; > } > > @@ -59,7 +59,7 @@ struct fdarray *fdarray__new(int nr_alloc, int nr_autogrow) > void fdarray__exit(struct fdarray *fda) > { > free(fda->entries); > - free(fda->priv); > + free(fda->prop); > fdarray__init(fda, 0); > } > > @@ -69,7 +69,7 @@ void fdarray__delete(struct fdarray *fda) > free(fda); > } > > -int fdarray__add(struct fdarray *fda, int fd, short revents) > +int fdarray__add(struct fdarray *fda, int fd, short revents, enum fdarray_props props) > { > int pos = fda->nr; > > @@ -79,6 +79,7 @@ int fdarray__add(struct fdarray *fda, int fd, short revents) > > fda->entries[fda->nr].fd = fd; > fda->entries[fda->nr].events = revents; > + fda->prop[fda->nr].bits = props; > fda->nr++; > return pos; > } > 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 > + > +enum fdarray_props { > + fdarray_prop__default = 0x00000000, > + fdarray_prop__nonfilterable = 0x00000001 > }; s/fdarray_props/fdarray_flag/ > > void fdarray__init(struct fdarray *fda, int nr_autogrow); > @@ -33,7 +41,7 @@ void fdarray__exit(struct fdarray *fda); > struct fdarray *fdarray__new(int nr_alloc, int nr_autogrow); > void fdarray__delete(struct fdarray *fda); > > -int fdarray__add(struct fdarray *fda, int fd, short revents); > +int fdarray__add(struct fdarray *fda, int fd, short revents, enum fdarray_props props); > int fdarray__poll(struct fdarray *fda, int timeout); > int fdarray__filter(struct fdarray *fda, short revents, > void (*entry_destructor)(struct fdarray *fda, int fd, void *arg), > diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c > index 6a875a0f01bb..25e76e458afb 100644 SNIP