Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1159944ybe; Fri, 13 Sep 2019 12:00:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7AuPmHg805vEVFFQAcg2nKJFQrNDH1EpmjHpVK+jMQxK2sCT79k1nUFNrxKGOyKeU5Ia1 X-Received: by 2002:a50:ec84:: with SMTP id e4mr50528728edr.193.1568401246540; Fri, 13 Sep 2019 12:00:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568401246; cv=none; d=google.com; s=arc-20160816; b=kUhaT/3uq7XBpGzg/tKmiQ6KMcONDZ76PW7KsHefDrVGJj6X5HA9wzGWeqvblLquw8 EuJ9RQ5va7an9UBcH/pbkmNPyzaTx5iJu3M8jWFFeHozK4SHl6dlXS28wqBt23KmXZ17 BzL7nuXQUa5iR0JC9Fqi9qPVxqotTTKRZE1RiKNuwvZPGjGdo8tAQC1vwgnKTToGigdp SY1+6AiYYLw1pPcWWy3TEr6AwA7P4o3Beumd7JKzKUZLlI3f3vja7/oMg73R/KWw49mW IvTNKlzpS9fVvaQiIFjzuhwuY/gHlIEgoCCMG1AL508EMzxBs4lwehXjwina2m4l3XnC KeVw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rZS/KWnYyiDHfosT8o4lAnKrDm0DHu6QiK+FiwSZ3b8=; b=mZ66hnPLH4f+mLZGMsUQNOS+T/DBrfVqtaQ58QSOwLlv3NXvCQs+/5subkNUJfbO9M nryr4WZUsM8cQzbR5rZtkX8avmgfkD7E5n2U4sg5GJmtZWecjjcESebKnzIIb/dk7/FY VMG+9eSApXPcMfJivnCxmNoL48rxuttGovQqush1DXd5g8cQWwgx6zqfeRrTN6Cw2k5D CH40EwDqAatt79UhLGsPHrW8Q1/cxVBVkbtlSieiHRD94ju5UHb4WGK5Qgf8OupCbYkx WrN2P+9cJ8a4UMfhMu1CXoc6ZDJn7Dz8HONtz+N4j7m0ZCdSCZt9BZka0YqqLzXwBgBW hXOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f30si17903143ede.435.2019.09.13.12.00.22; Fri, 13 Sep 2019 12:00:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390901AbfIMNY5 (ORCPT + 99 others); Fri, 13 Sep 2019 09:24:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59056 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391246AbfIMNYy (ORCPT ); Fri, 13 Sep 2019 09:24:54 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 19D8C307D853; Fri, 13 Sep 2019 13:24:54 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C0D05C22F; Fri, 13 Sep 2019 13:24:51 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH 22/73] libperf: Move pollfd from struct evlist to struct perf_evlist Date: Fri, 13 Sep 2019 15:23:04 +0200 Message-Id: <20190913132355.21634-23-jolsa@kernel.org> In-Reply-To: <20190913132355.21634-1-jolsa@kernel.org> References: <20190913132355.21634-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 13 Sep 2019 13:24:54 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Moving pollfd from struct evlist to struct perf_evlist it will be used in following patches. Link: http://lkml.kernel.org/n/tip-g6auuaej31nsusuevuhcgxli@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/builtin-kvm.c | 2 +- tools/perf/lib/include/internal/evlist.h | 2 ++ tools/perf/util/evlist.c | 18 +++++++++--------- tools/perf/util/evlist.h | 1 - tools/perf/util/python.c | 6 +++--- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 2b8e71d0a722..66acac16bcb2 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -978,7 +978,7 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm) evlist__enable(kvm->evlist); while (!done) { - struct fdarray *fda = &kvm->evlist->pollfd; + struct fdarray *fda = &kvm->evlist->core.pollfd; int rc; rc = perf_kvm__mmap_read(kvm); diff --git a/tools/perf/lib/include/internal/evlist.h b/tools/perf/lib/include/internal/evlist.h index 01b813616440..8a4eb66fbf3a 100644 --- a/tools/perf/lib/include/internal/evlist.h +++ b/tools/perf/lib/include/internal/evlist.h @@ -3,6 +3,7 @@ #define __LIBPERF_INTERNAL_EVLIST_H #include +#include struct perf_cpu_map; struct perf_thread_map; @@ -15,6 +16,7 @@ struct perf_evlist { struct perf_thread_map *threads; int nr_mmaps; size_t mmap_len; + struct fdarray pollfd; }; /** diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 07f02afa3407..8f5b28eefde7 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -60,7 +60,7 @@ void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus, INIT_HLIST_HEAD(&evlist->heads[i]); perf_evlist__init(&evlist->core); perf_evlist__set_maps(&evlist->core, cpus, threads); - fdarray__init(&evlist->pollfd, 64); + fdarray__init(&evlist->core.pollfd, 64); evlist->workload.pid = -1; evlist->bkw_mmap_state = BKW_MMAP_NOTREADY; } @@ -141,7 +141,7 @@ void evlist__exit(struct evlist *evlist) { zfree(&evlist->mmap); zfree(&evlist->overwrite_mmap); - fdarray__exit(&evlist->pollfd); + fdarray__exit(&evlist->core.pollfd); } void evlist__delete(struct evlist *evlist) @@ -415,8 +415,8 @@ int perf_evlist__alloc_pollfd(struct evlist *evlist) nfds += nr_cpus * nr_threads; } - if (fdarray__available_entries(&evlist->pollfd) < nfds && - fdarray__grow(&evlist->pollfd, nfds) < 0) + if (fdarray__available_entries(&evlist->core.pollfd) < nfds && + fdarray__grow(&evlist->core.pollfd, nfds) < 0) return -ENOMEM; return 0; @@ -425,13 +425,13 @@ int perf_evlist__alloc_pollfd(struct evlist *evlist) static int __perf_evlist__add_pollfd(struct evlist *evlist, int fd, struct mmap *map, short revent) { - int pos = fdarray__add(&evlist->pollfd, fd, revent | POLLERR | POLLHUP); + int pos = fdarray__add(&evlist->core.pollfd, fd, revent | POLLERR | POLLHUP); /* * Save the idx so that when we filter out fds POLLHUP'ed we can * close the associated evlist->mmap[] entry. */ if (pos >= 0) { - evlist->pollfd.priv[pos].ptr = map; + evlist->core.pollfd.priv[pos].ptr = map; fcntl(fd, F_SETFL, O_NONBLOCK); } @@ -455,13 +455,13 @@ static void perf_evlist__munmap_filtered(struct fdarray *fda, int fd, int perf_evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask) { - return fdarray__filter(&evlist->pollfd, revents_and_mask, + return fdarray__filter(&evlist->core.pollfd, revents_and_mask, perf_evlist__munmap_filtered, NULL); } int perf_evlist__poll(struct evlist *evlist, int timeout) { - return fdarray__poll(&evlist->pollfd, timeout); + return fdarray__poll(&evlist->core.pollfd, timeout); } static void perf_evlist__id_hash(struct evlist *evlist, @@ -1008,7 +1008,7 @@ int evlist__mmap_ex(struct evlist *evlist, unsigned int pages, if (!evlist->mmap) return -ENOMEM; - if (evlist->pollfd.entries == NULL && perf_evlist__alloc_pollfd(evlist) < 0) + if (evlist->core.pollfd.entries == NULL && perf_evlist__alloc_pollfd(evlist) < 0) return -ENOMEM; evlist->core.mmap_len = evlist__mmap_size(pages); diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 3767866e98c1..b8f03452196f 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -36,7 +36,6 @@ struct evlist { int cork_fd; pid_t pid; } workload; - struct fdarray pollfd; struct mmap *mmap; struct mmap *overwrite_mmap; struct evsel *selected; diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index b71b899407df..fdc787cfa9f7 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -935,17 +935,17 @@ static PyObject *pyrf_evlist__get_pollfd(struct pyrf_evlist *pevlist, PyObject *list = PyList_New(0); int i; - for (i = 0; i < evlist->pollfd.nr; ++i) { + for (i = 0; i < evlist->core.pollfd.nr; ++i) { PyObject *file; #if PY_MAJOR_VERSION < 3 - FILE *fp = fdopen(evlist->pollfd.entries[i].fd, "r"); + FILE *fp = fdopen(evlist->core.pollfd.entries[i].fd, "r"); if (fp == NULL) goto free_list; file = PyFile_FromFile(fp, "perf", "r", NULL); #else - file = PyFile_FromFd(evlist->pollfd.entries[i].fd, "perf", "r", -1, + file = PyFile_FromFd(evlist->core.pollfd.entries[i].fd, "perf", "r", -1, NULL, NULL, NULL, 0); #endif if (file == NULL) -- 2.21.0