Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp336626ybt; Wed, 8 Jul 2020 00:55:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW7ohI/FBeRkQqAZEUzDhMP6o6TRfPx3nDK8IL1UTaxXvWuTwoNWpCpW6c8eo+S3CaXVwB X-Received: by 2002:a50:e047:: with SMTP id g7mr64117865edl.290.1594194947981; Wed, 08 Jul 2020 00:55:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594194947; cv=none; d=google.com; s=arc-20160816; b=fKAhnPNqRj7qbBkrx7s4fdiMx1F+s8O3JvDm6r8uuUM/rE42crqYUITgX3NY40SXWq K7TIkBt40O8oMzVyB5WfjsZsWY76eHgZCRnA8THzNFxCjRegvGaiD5IxL2hon6AZb2ml eOwqxlrgNrUk+TuLIxLt2H8rSYu/jqNvmPjjXhp/EXRYVXjg+uyqc1GXOES8Ix0PYmBC ecPprbosZ0qN8f9B6X/d7PSiXpOsxVhKVXDiXNDjRkdRjLbKVgs0r+HTvmIveFuMhbDo p94a1jISfCXnJauQ4TH713RKLZhB+YuDCgIhGAsqtQBfuhzMb2pbSbSaPMsqV0aWwikp KYoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:references:cc:to:from:subject:ironport-sdr :ironport-sdr; bh=QI8egYpjtzlMB9HsNH+pGS5gapL5zEag/R5ieyq7hRc=; b=n94zAiaze+QIaCgCen5EEPuB86sXnsvzeFFSL7zREki62Lw7AyB1QGJHlT/sRqspiF lFeqoHrdzPp7MPUWziG5rEGFuzwu+Ao21pvDqF0a6nX5ymmQ8X8O2ymUUTEYRzUbuV2D pAlNtedKOPgDh6SSDAnH/VzHJzgnQ1v86FBtuATQuJroJE2W6c/qKdEDs34ia+EA50fd LZqus+bbJV9JwBv3iUnG4hFljdayIRHoodoXPE4+iOyvZhsmkdwPePgnye7ECowC7fX6 asYg23QeBzaDQ1z91DSZXAedQFu0jkG/VzMpYDBQ5ToGNG+dYnnuwh0aFOCTLdLWh5ls o/pQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i18si16387311edr.67.2020.07.08.00.55.25; Wed, 08 Jul 2020 00:55:47 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727007AbgGHHq3 (ORCPT + 99 others); Wed, 8 Jul 2020 03:46:29 -0400 Received: from mga07.intel.com ([134.134.136.100]:8907 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726936AbgGHHq2 (ORCPT ); Wed, 8 Jul 2020 03:46:28 -0400 IronPort-SDR: NWrJJP/gc/V6nq3AeMA4N2Jbaqv1Zpx+YYhTOkgjwSYreeehEKLtz0F+P73qFsdpppaJ5XMZ3o 3bmIrEhEfv2Q== X-IronPort-AV: E=McAfee;i="6000,8403,9675"; a="212697996" X-IronPort-AV: E=Sophos;i="5.75,327,1589266800"; d="scan'208";a="212697996" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2020 00:46:28 -0700 IronPort-SDR: 262ateI08tZ7kwQk86xiuiDgYWBsZsnu16kmrPUbD+wjZIegTzVS6WHHR7ERJYHU9xEEWksEFC edNSm7UWiqDw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,327,1589266800"; d="scan'208";a="305957785" Received: from linux.intel.com ([10.54.29.200]) by fmsmga004.fm.intel.com with ESMTP; 08 Jul 2020 00:46:28 -0700 Received: from [10.249.226.44] (abudanko-mobl.ccr.corp.intel.com [10.249.226.44]) by linux.intel.com (Postfix) with ESMTP id AF71F5807FC; Wed, 8 Jul 2020 00:46:25 -0700 (PDT) Subject: [PATCH v10 02/15] tools/libperf: add flags to fdarray fds objects From: Alexey Budankov To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: <4af50c95-36f6-7a61-5a22-2949970fe7a5@linux.intel.com> Organization: Intel Corp. Message-ID: <4c0e05df-8eb7-306e-033b-47e1a6b06924@linux.intel.com> Date: Wed, 8 Jul 2020 10:46:24 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <4af50c95-36f6-7a61-5a22-2949970fe7a5@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Store flags per struct pollfd *entries object in a bitmap of int size. Implement fdarray_flag__nonfilterable flag to skip object from counting by fdarray__filter(). Signed-off-by: Alexey Budankov --- tools/lib/api/fd/array.c | 3 ++- tools/lib/api/fd/array.h | 16 ++++++++++++---- tools/lib/perf/evlist.c | 6 +++--- tools/lib/perf/include/internal/evlist.h | 2 +- tools/perf/tests/fdarray.c | 2 +- tools/perf/util/evlist.c | 2 +- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/tools/lib/api/fd/array.c b/tools/lib/api/fd/array.c index 89f9a2193c2d..37f291e6fc21 100644 --- a/tools/lib/api/fd/array.c +++ b/tools/lib/api/fd/array.c @@ -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_flags flags) { 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->priv[fda->nr].flags = flags; fda->nr++; return pos; } diff --git a/tools/lib/api/fd/array.h b/tools/lib/api/fd/array.h index b39557d1a88f..7f517a33af6f 100644 --- a/tools/lib/api/fd/array.h +++ b/tools/lib/api/fd/array.h @@ -21,19 +21,27 @@ struct fdarray { int nr_alloc; int nr_autogrow; struct pollfd *entries; - union { - int idx; - void *ptr; + struct { + union { + int idx; + void *ptr; + }; + unsigned int flags; } *priv; }; +enum fdarray_flags { + fdarray_flag__default = 0x00000000, + fdarray_flag__nonfilterable = 0x00000001 +}; + void fdarray__init(struct fdarray *fda, int nr_autogrow); 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_flags flags); 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..2208444ecb44 100644 --- a/tools/lib/perf/evlist.c +++ b/tools/lib/perf/evlist.c @@ -305,9 +305,9 @@ int perf_evlist__alloc_pollfd(struct perf_evlist *evlist) } int perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, - void *ptr, short revent) + void *ptr, short revent, enum fdarray_flags flags) { - int pos = fdarray__add(&evlist->pollfd, fd, revent | POLLERR | POLLHUP); + int pos = fdarray__add(&evlist->pollfd, fd, revent | POLLERR | POLLHUP, flags); if (pos >= 0) { evlist->pollfd.priv[pos].ptr = ptr; @@ -488,7 +488,7 @@ mmap_per_evsel(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops, revent = !overwrite ? POLLIN : 0; if (!evsel->system_wide && - perf_evlist__add_pollfd(evlist, fd, map, revent) < 0) { + perf_evlist__add_pollfd(evlist, fd, map, revent, fdarray_flag__default) < 0) { perf_mmap__put(map); return -1; } diff --git a/tools/lib/perf/include/internal/evlist.h b/tools/lib/perf/include/internal/evlist.h index 74dc8c3f0b66..2d0fa02b036f 100644 --- a/tools/lib/perf/include/internal/evlist.h +++ b/tools/lib/perf/include/internal/evlist.h @@ -45,7 +45,7 @@ struct perf_evlist_mmap_ops { int perf_evlist__alloc_pollfd(struct perf_evlist *evlist); int perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, - void *ptr, short revent); + void *ptr, short revent, enum fdarray_flags flags); int perf_evlist__mmap_ops(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops, diff --git a/tools/perf/tests/fdarray.c b/tools/perf/tests/fdarray.c index d0c8a05aab2f..d9eca8e86a6b 100644 --- a/tools/perf/tests/fdarray.c +++ b/tools/perf/tests/fdarray.c @@ -112,7 +112,7 @@ int test__fdarray__add(struct test *test __maybe_unused, int subtest __maybe_unu } #define FDA_ADD(_idx, _fd, _revents, _nr) \ - if (fdarray__add(fda, _fd, _revents) < 0) { \ + if (fdarray__add(fda, _fd, _revents, fdarray_flag__default) < 0) { \ pr_debug("\n%d: fdarray__add(fda, %d, %d) failed!", \ __LINE__,_fd, _revents); \ goto out_delete; \ diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 1b884695b4d3..bcbe0cb8482e 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -497,7 +497,7 @@ int perf_evlist__enable_event_idx(struct evlist *evlist, int evlist__add_pollfd(struct evlist *evlist, int fd) { - return perf_evlist__add_pollfd(&evlist->core, fd, NULL, POLLIN); + return perf_evlist__add_pollfd(&evlist->core, fd, NULL, POLLIN, fdarray_flag__default); } int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask) -- 2.24.1