Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5880275ybi; Sun, 21 Jul 2019 04:34:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDNb0o0yS5kSjwG0exjiU1wkwPk3qpCtbw731Z1Vko5VMRfFVn28sASTh1J2hp/Xhg1goF X-Received: by 2002:a17:902:ff05:: with SMTP id f5mr67295374plj.116.1563708842726; Sun, 21 Jul 2019 04:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563708842; cv=none; d=google.com; s=arc-20160816; b=uMBGEhe7jXJ6kT1BJE38ked4cUZUn31mdig07V/lSceN4gy7jnXlki6XKX6EF9krcX h8v3l+8z/EBWZsAQCOZ3O+0R6SIrv3eQrS07uSQmRIXKoRv2DkCDi7TmbwL9ELHgKgPt XcxtnfmfcWjy0SRbbgvfg7omTjNo5JoUTvR0NJVtgxQC1zlOu8Kr1txq0f44QF+z42qi AezBIc6r61TFPWMgT1VZoJo0xCqsz0QbrWdPE1+Fbt6/656UR6IU7V75RpVgt0OKZrxT eFMMHOj/Ut8X77lMbkAkRJB2Y/dRMF2f8183dzyQr/LS8WWBw+5jNbyMa0kGJrw8a8t7 2cbA== 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=A3hxfHyhlqaxTNwSmBh9TF64xL7qfSvHoB3ZbXTIJlU=; b=Gc7aFjM00xnEhMDJeI7ukUTG8AVZD69n2O5E7rptD29v9ae+Rn5geHirdOvksleXHL /8/qA75lLLRFjALnGM/UIITtjlaXgVQ7bNvZK1mVPd07cMM8cMLsoAlsRQe7T2bvDirv dQ4q/UNe/joa0rib1n4hK4zZxZRWbQ+cERb4nJeCXGbQE+8zcSyyEcbd48QXdVy9yynt q6UeDvDehVNGyqqGIbe3Kk7UA6z6S+P5vE2RR9O6kkkpNWaPcu/4NI3VsNBlRFGAwasj TkXMeiz5MaQiZfggsvVYqBQ0NBTr81EXMWwCsjD5pSn2GFYe9gMQbWd4CV0YHXIN7laY We8Q== 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 s5si8264419plq.219.2019.07.21.04.33.46; Sun, 21 Jul 2019 04:34:02 -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 S1727359AbfGULbd (ORCPT + 99 others); Sun, 21 Jul 2019 07:31:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39826 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726701AbfGULbc (ORCPT ); Sun, 21 Jul 2019 07:31:32 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F1B1C3082DDD; Sun, 21 Jul 2019 11:31:31 +0000 (UTC) Received: from krava.redhat.com (ovpn-204-23.brq.redhat.com [10.40.204.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE35E5D9D3; Sun, 21 Jul 2019 11:31:27 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Andi Kleen , Alexey Budankov , Michael Petlan Subject: [PATCH 58/79] libperf: Add fd array to struct perf_evsel Date: Sun, 21 Jul 2019 13:24:45 +0200 Message-Id: <20190721112506.12306-59-jolsa@kernel.org> In-Reply-To: <20190721112506.12306-1-jolsa@kernel.org> References: <20190721112506.12306-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sun, 21 Jul 2019 11:31:32 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Moving fd array from evsel into perf_evsel struct. Link: http://lkml.kernel.org/n/tip-1seqb25x5pqzr2s1dl4if2p8@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/lib/include/internal/evsel.h | 1 + tools/perf/util/bpf-loader.c | 2 +- tools/perf/util/evlist.c | 10 ++++----- tools/perf/util/evsel.c | 30 ++++++++++++------------- tools/perf/util/evsel.h | 1 - 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tools/perf/lib/include/internal/evsel.h b/tools/perf/lib/include/internal/evsel.h index 8340fd883a3d..df4078194e9a 100644 --- a/tools/perf/lib/include/internal/evsel.h +++ b/tools/perf/lib/include/internal/evsel.h @@ -14,6 +14,7 @@ struct perf_evsel { struct perf_cpu_map *cpus; struct perf_cpu_map *own_cpus; struct perf_thread_map *threads; + struct xyarray *fd; }; #endif /* __LIBPERF_INTERNAL_EVSEL_H */ diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 4df8bdea14ac..9c219d413e57 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -1403,7 +1403,7 @@ static int apply_config_evsel_for_key(const char *name, int map_fd, void *pkey, struct evsel *evsel) { - struct xyarray *xy = evsel->fd; + struct xyarray *xy = evsel->core.fd; struct perf_event_attr *attr; unsigned int key, events; bool check_pass = false; diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 20e22596d4cf..453c401606cc 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -40,7 +40,7 @@ int sigqueue(pid_t pid, int sig, const union sigval value); #endif -#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) +#define FD(e, x, y) (*(int *)xyarray__entry(e->core.fd, x, y)) #define SID(e, x, y) xyarray__entry(e->sample_id, x, y) void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus, @@ -321,7 +321,7 @@ void evlist__disable(struct evlist *evlist) struct evsel *pos; evlist__for_each_entry(evlist, pos) { - if (pos->disabled || !perf_evsel__is_group_leader(pos) || !pos->fd) + if (pos->disabled || !perf_evsel__is_group_leader(pos) || !pos->core.fd) continue; evsel__disable(pos); } @@ -334,7 +334,7 @@ void evlist__enable(struct evlist *evlist) struct evsel *pos; evlist__for_each_entry(evlist, pos) { - if (!perf_evsel__is_group_leader(pos) || !pos->fd) + if (!perf_evsel__is_group_leader(pos) || !pos->core.fd) continue; evsel__enable(pos); } @@ -353,7 +353,7 @@ static int perf_evlist__enable_event_cpu(struct evlist *evlist, int thread; int nr_threads = perf_evlist__nr_threads(evlist, evsel); - if (!evsel->fd) + if (!evsel->core.fd) return -EINVAL; for (thread = 0; thread < nr_threads; thread++) { @@ -371,7 +371,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist, int cpu; int nr_cpus = cpu_map__nr(evlist->core.cpus); - if (!evsel->fd) + if (!evsel->core.fd) return -EINVAL; for (cpu = 0; cpu < nr_cpus; cpu++) { diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index f7758ce0dd5c..8d087d0e55f1 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -90,7 +90,7 @@ int perf_evsel__object_config(size_t object_size, return 0; } -#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) +#define FD(e, x, y) (*(int *)xyarray__entry(e->core.fd, x, y)) int __perf_evsel__sample_size(u64 sample_type) { @@ -1155,9 +1155,9 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts, static int perf_evsel__alloc_fd(struct evsel *evsel, int ncpus, int nthreads) { - evsel->fd = xyarray__new(ncpus, nthreads, sizeof(int)); + evsel->core.fd = xyarray__new(ncpus, nthreads, sizeof(int)); - if (evsel->fd) { + if (evsel->core.fd) { int cpu, thread; for (cpu = 0; cpu < ncpus; cpu++) { for (thread = 0; thread < nthreads; thread++) { @@ -1166,7 +1166,7 @@ static int perf_evsel__alloc_fd(struct evsel *evsel, int ncpus, int nthreads) } } - return evsel->fd != NULL ? 0 : -ENOMEM; + return evsel->core.fd != NULL ? 0 : -ENOMEM; } static int perf_evsel__run_ioctl(struct evsel *evsel, @@ -1174,8 +1174,8 @@ static int perf_evsel__run_ioctl(struct evsel *evsel, { int cpu, thread; - for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) { - for (thread = 0; thread < xyarray__max_y(evsel->fd); thread++) { + for (cpu = 0; cpu < xyarray__max_x(evsel->core.fd); cpu++) { + for (thread = 0; thread < xyarray__max_y(evsel->core.fd); thread++) { int fd = FD(evsel, cpu, thread), err = ioctl(fd, ioc, arg); @@ -1283,8 +1283,8 @@ int perf_evsel__alloc_id(struct evsel *evsel, int ncpus, int nthreads) static void perf_evsel__free_fd(struct evsel *evsel) { - xyarray__delete(evsel->fd); - evsel->fd = NULL; + xyarray__delete(evsel->core.fd); + evsel->core.fd = NULL; } static void perf_evsel__free_id(struct evsel *evsel) @@ -1309,8 +1309,8 @@ void perf_evsel__close_fd(struct evsel *evsel) { int cpu, thread; - for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) - for (thread = 0; thread < xyarray__max_y(evsel->fd); ++thread) { + for (cpu = 0; cpu < xyarray__max_x(evsel->core.fd); cpu++) + for (thread = 0; thread < xyarray__max_y(evsel->core.fd); ++thread) { close(FD(evsel, cpu, thread)); FD(evsel, cpu, thread) = -1; } @@ -1555,7 +1555,7 @@ static int get_group_fd(struct evsel *evsel, int cpu, int thread) * Leader must be already processed/open, * if not it's a bug. */ - BUG_ON(!leader->fd); + BUG_ON(!leader->core.fd); fd = FD(leader, cpu, thread); BUG_ON(fd == -1); @@ -1865,7 +1865,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus, else nthreads = threads->nr; - if (evsel->fd == NULL && + if (evsel->core.fd == NULL && perf_evsel__alloc_fd(evsel, cpus->nr, nthreads) < 0) return -ENOMEM; @@ -2075,7 +2075,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus, void perf_evsel__close(struct evsel *evsel) { - if (evsel->fd == NULL) + if (evsel->core.fd == NULL) return; perf_evsel__close_fd(evsel); @@ -3048,8 +3048,8 @@ static int store_evsel_ids(struct evsel *evsel, struct evlist *evlist) { int cpu, thread; - for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++) { - for (thread = 0; thread < xyarray__max_y(evsel->fd); + for (cpu = 0; cpu < xyarray__max_x(evsel->core.fd); cpu++) { + for (thread = 0; thread < xyarray__max_y(evsel->core.fd); thread++) { int fd = FD(evsel, cpu, thread); diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 1f9f66fe43f4..6056ce64bfdf 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -104,7 +104,6 @@ struct evsel { struct perf_evsel core; struct evlist *evlist; char *filter; - struct xyarray *fd; struct xyarray *sample_id; u64 *id; struct perf_counts *counts; -- 2.21.0