Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1441216 > unrolled thread
| Started by | Wang Nan <wangnan0@huawei.com> |
|---|---|
| First post | 2016-07-12 12:10 +0200 |
| Last post | 2016-07-14 04:00 +0200 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH v15 00/12] perf tools: Support overwritable ring buffer Wang Nan <wangnan0@huawei.com> - 2016-07-12 12:10 +0200
[PATCH v15 01/12] perf tools: Drop redundant evsel->overwrite indicator Wang Nan <wangnan0@huawei.com> - 2016-07-12 12:10 +0200
[PATCH v15 03/12] perf tools: Update perf evlist mmap related APIs and helpers Wang Nan <wangnan0@huawei.com> - 2016-07-12 12:10 +0200
Re: [PATCH v15 03/12] perf tools: Update perf evlist mmap related APIs and helpers Jiri Olsa <jolsa@redhat.com> - 2016-07-13 16:10 +0200
Re: [PATCH v15 03/12] perf tools: Update perf evlist mmap related APIs and helpers "Wangnan (F)" <wangnan0@huawei.com> - 2016-07-14 04:00 +0200
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2016-07-12 12:10 +0200 |
| Subject | [PATCH v15 00/12] perf tools: Support overwritable ring buffer |
| Message-ID | <rU2NA-3tA-5@gated-at.bofh.it> |
This patch set enables daemonized perf recording by utilizing
overwritable backward ring buffer. With this feature one can
put perf background, and dump ring buffer records by a SIGUSR2
when he/she find something unusual. For example, following
command record system calls, schedule events and samples on cpu cycles
continously:
# perf record -g -e cycles -e raw_syscalls:*/call-graph=no/ \
-e sched:sched_switch/call-graph=no/ \
--switch-output --overwrite -a
Then by sending SIGUSR2 to perf when lagging is happen, we get multiple
perf.data output, each of them correspond a abnormal event, and the data
size is reasonable:
# ls -l ./perf.data*
-rw------- 1 root root 5122165 May 13 23:51 ./perf.data.2016051323511683
-rw------- 1 root root 5135093 May 13 23:51 ./perf.data.2016051323512107
-rw------- 1 root root 5135213 May 13 23:51 ./perf.data.2016051323512215
-rw------- 1 root root 5135157 May 13 23:51 ./perf.data.2016051323512387
v1 -> v2: Totally redesign: drop the principle of 'channal', use
auxiliary evlist instead. Fix missing documentation.
v2 -> v3: Rename perf_evlist__toggle_paused() to perf_evlist__pause/resume.
v3 -> v4: Update commit message to describe auxiliary evlist more clearly.
v4 -> v5: Reorder commits, ensure '--overwrite' works right after perf
support the option.
Add test cases for auxiliary evlist.
Avoid bug if main evlist is empty.
v5 -> v6: Improve filter pollfd related code.
v6 -> v7: Rebase to newest perf/core.
v7 -> v8: Unmap mmaps from parent and children in
perf_evlist__munmap_filtered(), hide more detail of aux evlist.
Add --tail-synthesize, do synthesize at the end of perf.data.
v8 -> v9: Beautify code of test case, make patch set more granular,
improve documentation.
v9 -> v10: Make patch set more granular: extract preparation code to
patch 1-3.
v10 -> v11: Rebase to newest perf/core: solve conflicts caused by commit
e5cadb93d08 ("perf evlist: Rename for_each() macros to
for_each_entry()").
v11 -> v12: Improve 'perf test backward': skip this test on old kernel,
resolve conflicts.
v12 -> v13: Drop evsel->overwrite, use evsel->attr.write_backward instead.
v13 -> v14: Follow Jiri Olsa's suggestion: Improve commit message,
add OVERWRITE_EVT_NOTREADY state, stop the state machine if
overwrite_evlist is not generated.
v15 -> v16: Totally redesign: drop auxiliary evlist, use one evlist to
contain normal and backward ring buffers (add evlist->backward_mmap).
Build new API and helpers for it.
Arnaldo Carvalho de Melo (1):
perf tools: Drop redundant evsel->overwrite indicator
Wang Nan (11):
tools lib fd array: Allow associating a pointer cookie with each entry
perf tools: Update perf evlist mmap related APIs and helpers
perf tools: Record mmap cookie into fdarray private field
perf tools: Extract common code in mmap failure processing
perf tools: Alloc backward_mmap array for evlist
perf tools: Map backward events to backward_mmap
perf tools: Drop evlist->backward
perf record: Read from overwritable ring buffer
perf tools: Enable overwrite settings
perf tools: Don't warn about out of order event if write_backward is
used
perf tools: Add --tail-synthesize option
tools/lib/api/fd/array.h | 1 +
tools/perf/Documentation/perf-record.txt | 22 ++++
tools/perf/builtin-record.c | 198 +++++++++++++++++++++++++++----
tools/perf/perf.h | 2 +
tools/perf/tests/backward-ring-buffer.c | 14 +--
tools/perf/util/evlist.c | 186 +++++++++++++++++------------
tools/perf/util/evlist.h | 13 +-
tools/perf/util/evsel.c | 16 +--
tools/perf/util/evsel.h | 3 +-
tools/perf/util/parse-events.c | 20 +++-
tools/perf/util/parse-events.h | 2 +
tools/perf/util/parse-events.l | 2 +
tools/perf/util/session.c | 22 +++-
13 files changed, 383 insertions(+), 118 deletions(-)
--
1.8.3.4
[toc] | [next] | [standalone]
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2016-07-12 12:10 +0200 |
| Subject | [PATCH v15 01/12] perf tools: Drop redundant evsel->overwrite indicator |
| Message-ID | <rU2NC-3tA-71@gated-at.bofh.it> |
| In reply to | #1441216 |
From: Arnaldo Carvalho de Melo <acme@redhat.com>
evsel->overwrite indicator means an event should be put into
overwritable ring buffer. In current implementation, it equals to
evsel->attr.write_backward. To reduce compliexity, remove
evsel->overwrite, use evsel->attr.write_backward instead.
In addition, in __perf_evsel__open(), if kernel doesn't support
write_backward and user explicitly set it in evsel, don't fallback
like other missing feature, since it is meaningless to fall back to
a forward ring buffer in this case: we are unable to stably read
from an forward overwritable ring buffer.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: pi3orama@163.com
---
tools/perf/tests/backward-ring-buffer.c | 1 +
tools/perf/util/evlist.c | 4 ++--
tools/perf/util/evsel.c | 12 +++++-------
tools/perf/util/evsel.h | 1 -
4 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c
index e70313f..1750ef2 100644
--- a/tools/perf/tests/backward-ring-buffer.c
+++ b/tools/perf/tests/backward-ring-buffer.c
@@ -101,6 +101,7 @@ int test__backward_ring_buffer(int subtest __maybe_unused)
return TEST_FAIL;
}
+ evlist->backward = true;
err = perf_evlist__create_maps(evlist, &opts.target);
if (err < 0) {
pr_debug("Not enough memory to create thread/cpu maps\n");
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 1135077..7228596 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1003,7 +1003,7 @@ static bool
perf_evlist__should_poll(struct perf_evlist *evlist __maybe_unused,
struct perf_evsel *evsel)
{
- if (evsel->overwrite)
+ if (evsel->attr.write_backward)
return false;
return true;
}
@@ -1018,7 +1018,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
evlist__for_each_entry(evlist, evsel) {
int fd;
- if (evsel->overwrite != (evlist->overwrite && evlist->backward))
+ if (!!evsel->attr.write_backward != (evlist->overwrite && evlist->backward))
continue;
if (evsel->system_wide && thread)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 0fea724..3abe519 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1359,6 +1359,9 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
int pid = -1, err;
enum { NO_CHANGE, SET_TO_MAX, INCREASED_MAX } set_rlimit = NO_CHANGE;
+ if (perf_missing_features.write_backward && evsel->attr.write_backward)
+ return -EINVAL;
+
if (evsel->system_wide)
nthreads = 1;
else
@@ -1389,11 +1392,6 @@ fallback_missing_features:
if (perf_missing_features.lbr_flags)
evsel->attr.branch_sample_type &= ~(PERF_SAMPLE_BRANCH_NO_FLAGS |
PERF_SAMPLE_BRANCH_NO_CYCLES);
- if (perf_missing_features.write_backward) {
- if (evsel->overwrite)
- return -EINVAL;
- evsel->attr.write_backward = false;
- }
retry_sample_id:
if (perf_missing_features.sample_id_all)
evsel->attr.sample_id_all = 0;
@@ -1495,7 +1493,7 @@ try_fallback:
*/
if (!perf_missing_features.write_backward && evsel->attr.write_backward) {
perf_missing_features.write_backward = true;
- goto fallback_missing_features;
+ goto out_close;
} else if (!perf_missing_features.clockid_wrong && evsel->attr.use_clockid) {
perf_missing_features.clockid_wrong = true;
goto fallback_missing_features;
@@ -2404,7 +2402,7 @@ int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
"We found oprofile daemon running, please stop it and try again.");
break;
case EINVAL:
- if (evsel->overwrite && perf_missing_features.write_backward)
+ if (evsel->attr.write_backward && perf_missing_features.write_backward)
return scnprintf(msg, size, "Reading from overwrite event is not supported by this kernel.");
if (perf_missing_features.clockid)
return scnprintf(msg, size, "clockid feature not supported.");
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 86fed7a..a31ee2d 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -114,7 +114,6 @@ struct perf_evsel {
bool tracking;
bool per_pkg;
bool precise_max;
- bool overwrite;
/* parse modifier helper */
int exclude_GH;
int nr_members;
--
1.8.3.4
[toc] | [prev] | [next] | [standalone]
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2016-07-12 12:10 +0200 |
| Subject | [PATCH v15 03/12] perf tools: Update perf evlist mmap related APIs and helpers |
| Message-ID | <rU2NC-3tA-69@gated-at.bofh.it> |
| In reply to | #1441216 |
Currently, evlist mmap related helpers and APIs accept evlist and idx,
and dereference 'struct perf_mmap' by evlist->mmap[idx]. This is
unnecessary, and force a evlist contain only one mmap array.
Following commits are going to introduce multiple mmap array to evlist.
This patch refators those APIs and helpers, extracts functions accept
perf_mmap pointer directly. New helpers and APIs are decoupled with
perf_evlist, and become perf_mmap functions.
Old functions are reimplemented with new functions. Some of them will be
removed in following commits.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: pi3orama@163.com
---
tools/perf/util/evlist.c | 128 +++++++++++++++++++++++++++++++----------------
tools/perf/util/evlist.h | 11 ++++
2 files changed, 96 insertions(+), 43 deletions(-)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 7228596..49f1d7c 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -29,6 +29,7 @@
static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx);
static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx);
+static void perf_mmap__munmap(struct perf_mmap *map);
#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
#define SID(e, x, y) xyarray__entry(e->sample_id, x, y)
@@ -781,9 +782,8 @@ broken_event:
return event;
}
-union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, int idx)
+union perf_event *perf_mmap__read_forward(struct perf_mmap *md, bool overwrite)
{
- struct perf_mmap *md = &evlist->mmap[idx];
u64 head;
u64 old = md->prev;
@@ -795,13 +795,12 @@ union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, int
head = perf_mmap__read_head(md);
- return perf_mmap__read(md, evlist->overwrite, old, head, &md->prev);
+ return perf_mmap__read(md, overwrite, old, head, &md->prev);
}
union perf_event *
-perf_evlist__mmap_read_backward(struct perf_evlist *evlist, int idx)
+perf_mmap__read_backward(struct perf_mmap *md, bool overwrite __maybe_unused)
{
- struct perf_mmap *md = &evlist->mmap[idx];
u64 head, end;
u64 start = md->prev;
@@ -836,6 +835,20 @@ perf_evlist__mmap_read_backward(struct perf_evlist *evlist, int idx)
return perf_mmap__read(md, false, start, end, &md->prev);
}
+union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, int idx)
+{
+ struct perf_mmap *md = &evlist->mmap[idx];
+
+ return perf_mmap__read_forward(md, evlist->overwrite);
+}
+
+union perf_event *perf_evlist__mmap_read_backward(struct perf_evlist *evlist, int idx)
+{
+ struct perf_mmap *md = &evlist->mmap[idx];
+
+ return perf_mmap__read_backward(md, evlist->overwrite);
+}
+
union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
{
if (!evlist->backward)
@@ -843,9 +856,8 @@ union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
return perf_evlist__mmap_read_backward(evlist, idx);
}
-void perf_evlist__mmap_read_catchup(struct perf_evlist *evlist, int idx)
+void perf_mmap__read_catchup(struct perf_mmap *md)
{
- struct perf_mmap *md = &evlist->mmap[idx];
u64 head;
if (!atomic_read(&md->refcnt))
@@ -855,38 +867,54 @@ void perf_evlist__mmap_read_catchup(struct perf_evlist *evlist, int idx)
md->prev = head;
}
+void perf_evlist__mmap_read_catchup(struct perf_evlist *evlist, int idx)
+{
+ perf_mmap__read_catchup(&evlist->mmap[idx]);
+}
+
static bool perf_mmap__empty(struct perf_mmap *md)
{
return perf_mmap__read_head(md) == md->prev && !md->auxtrace_mmap.base;
}
-static void perf_evlist__mmap_get(struct perf_evlist *evlist, int idx)
+static void perf_mmap__get(struct perf_mmap *map)
{
- atomic_inc(&evlist->mmap[idx].refcnt);
+ atomic_inc(&map->refcnt);
}
-static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx)
+static void perf_mmap__put(struct perf_mmap *md)
{
- struct perf_mmap *md = &evlist->mmap[idx];
-
BUG_ON(md->base && atomic_read(&md->refcnt) == 0);
if (atomic_dec_and_test(&md->refcnt))
- __perf_evlist__munmap(evlist, idx);
+ perf_mmap__munmap(md);
}
-void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx)
+static void perf_evlist__mmap_get(struct perf_evlist *evlist, int idx)
{
- struct perf_mmap *md = &evlist->mmap[idx];
+ perf_mmap__get(&evlist->mmap[idx]);
+}
- if (!evlist->overwrite) {
+static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx)
+{
+ perf_mmap__put(&evlist->mmap[idx]);
+}
+
+void perf_mmap__consume(struct perf_mmap *md, bool overwrite)
+{
+ if (!overwrite) {
u64 old = md->prev;
perf_mmap__write_tail(md, old);
}
if (atomic_read(&md->refcnt) == 1 && perf_mmap__empty(md))
- perf_evlist__mmap_put(evlist, idx);
+ perf_mmap__put(md);
+}
+
+void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx)
+{
+ perf_mmap__consume(&evlist->mmap[idx], evlist->overwrite);
}
int __weak auxtrace_mmap__mmap(struct auxtrace_mmap *mm __maybe_unused,
@@ -917,15 +945,20 @@ void __weak auxtrace_mmap_params__set_idx(
{
}
-static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx)
+static void perf_mmap__munmap(struct perf_mmap *map)
{
- if (evlist->mmap[idx].base != NULL) {
- munmap(evlist->mmap[idx].base, evlist->mmap_len);
- evlist->mmap[idx].base = NULL;
- evlist->mmap[idx].fd = -1;
- atomic_set(&evlist->mmap[idx].refcnt, 0);
+ if (map->base != NULL) {
+ munmap(map->base, perf_mmap__mmap_len(map));
+ map->base = NULL;
+ map->fd = -1;
+ atomic_set(&map->refcnt, 0);
}
- auxtrace_mmap__munmap(&evlist->mmap[idx].auxtrace_mmap);
+ auxtrace_mmap__munmap(&map->auxtrace_mmap);
+}
+
+static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx)
+{
+ perf_mmap__munmap(&evlist->mmap[idx]);
}
void perf_evlist__munmap(struct perf_evlist *evlist)
@@ -941,20 +974,21 @@ void perf_evlist__munmap(struct perf_evlist *evlist)
zfree(&evlist->mmap);
}
-static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
+static struct perf_mmap *perf_evlist__alloc_mmap(struct perf_evlist *evlist)
{
int i;
+ struct perf_mmap *map;
evlist->nr_mmaps = cpu_map__nr(evlist->cpus);
if (cpu_map__empty(evlist->cpus))
evlist->nr_mmaps = thread_map__nr(evlist->threads);
- evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
- if (!evlist->mmap)
- return -ENOMEM;
+ map = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
+ if (!map)
+ return NULL;
for (i = 0; i < evlist->nr_mmaps; i++)
- evlist->mmap[i].fd = -1;
- return 0;
+ map[i].fd = -1;
+ return map;
}
struct mmap_params {
@@ -963,8 +997,8 @@ struct mmap_params {
struct auxtrace_mmap_params auxtrace_mp;
};
-static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
- struct mmap_params *mp, int fd)
+static int perf_mmap__mmap(struct perf_mmap *map,
+ struct mmap_params *mp, int fd)
{
/*
* The last one will be done at perf_evlist__mmap_consume(), so that we
@@ -979,26 +1013,32 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
* evlist layer can't just drop it when filtering events in
* perf_evlist__filter_pollfd().
*/
- atomic_set(&evlist->mmap[idx].refcnt, 2);
- evlist->mmap[idx].prev = 0;
- evlist->mmap[idx].mask = mp->mask;
- evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, mp->prot,
- MAP_SHARED, fd, 0);
- if (evlist->mmap[idx].base == MAP_FAILED) {
+ atomic_set(&map->refcnt, 2);
+ map->prev = 0;
+ map->mask = mp->mask;
+ map->base = mmap(NULL, perf_mmap__mmap_len(map), mp->prot,
+ MAP_SHARED, fd, 0);
+ if (map->base == MAP_FAILED) {
pr_debug2("failed to mmap perf event ring buffer, error %d\n",
errno);
- evlist->mmap[idx].base = NULL;
+ map->base = NULL;
return -1;
}
- evlist->mmap[idx].fd = fd;
+ map->fd = fd;
- if (auxtrace_mmap__mmap(&evlist->mmap[idx].auxtrace_mmap,
- &mp->auxtrace_mp, evlist->mmap[idx].base, fd))
+ if (auxtrace_mmap__mmap(&map->auxtrace_mmap,
+ &mp->auxtrace_mp, map->base, fd))
return -1;
return 0;
}
+static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
+ struct mmap_params *mp, int fd)
+{
+ return perf_mmap__mmap(&evlist->mmap[idx], mp, fd);
+}
+
static bool
perf_evlist__should_poll(struct perf_evlist *evlist __maybe_unused,
struct perf_evsel *evsel)
@@ -1248,7 +1288,9 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,
.prot = PROT_READ | (overwrite ? 0 : PROT_WRITE),
};
- if (evlist->mmap == NULL && perf_evlist__alloc_mmap(evlist) < 0)
+ if (!evlist->mmap)
+ evlist->mmap = perf_evlist__alloc_mmap(evlist);
+ if (!evlist->mmap)
return -ENOMEM;
if (evlist->pollfd.entries == NULL && perf_evlist__alloc_pollfd(evlist) < 0)
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 872912b..2fc5c16 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -35,6 +35,12 @@ struct perf_mmap {
char event_copy[PERF_SAMPLE_MAX_SIZE] __attribute__((aligned(8)));
};
+static inline size_t
+perf_mmap__mmap_len(struct perf_mmap *map)
+{
+ return map->mask + 1 + page_size;
+}
+
struct perf_evlist {
struct list_head entries;
struct hlist_head heads[PERF_EVLIST__HLIST_SIZE];
@@ -129,6 +135,11 @@ struct perf_evsel *perf_evlist__id2evsel_strict(struct perf_evlist *evlist,
struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id);
+union perf_event *perf_mmap__read_forward(struct perf_mmap *map, bool overwrite);
+union perf_event *perf_mmap__read_backward(struct perf_mmap *map, bool overwrite);
+void perf_mmap__read_catchup(struct perf_mmap *md);
+void perf_mmap__consume(struct perf_mmap *md, bool overwrite);
+
union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx);
union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist,
--
1.8.3.4
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2016-07-13 16:10 +0200 |
| Subject | Re: [PATCH v15 03/12] perf tools: Update perf evlist mmap related APIs and helpers |
| Message-ID | <rUt1o-47M-21@gated-at.bofh.it> |
| In reply to | #1441218 |
On Tue, Jul 12, 2016 at 10:00:03AM +0000, Wang Nan wrote:
SNIP
> -union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, int idx)
> +union perf_event *perf_mmap__read_forward(struct perf_mmap *md, bool overwrite)
> {
> - struct perf_mmap *md = &evlist->mmap[idx];
> u64 head;
> u64 old = md->prev;
>
> @@ -795,13 +795,12 @@ union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, int
>
> head = perf_mmap__read_head(md);
>
> - return perf_mmap__read(md, evlist->overwrite, old, head, &md->prev);
> + return perf_mmap__read(md, overwrite, old, head, &md->prev);
> }
>
> union perf_event *
> -perf_evlist__mmap_read_backward(struct perf_evlist *evlist, int idx)
> +perf_mmap__read_backward(struct perf_mmap *md, bool overwrite __maybe_unused)
> {
> - struct perf_mmap *md = &evlist->mmap[idx];
> u64 head, end;
> u64 start = md->prev;
>
> @@ -836,6 +835,20 @@ perf_evlist__mmap_read_backward(struct perf_evlist *evlist, int idx)
> return perf_mmap__read(md, false, start, end, &md->prev);
should you pas evlist->overwrite in here?
thanks,
jirka
[toc] | [prev] | [next] | [standalone]
| From | "Wangnan (F)" <wangnan0@huawei.com> |
|---|---|
| Date | 2016-07-14 04:00 +0200 |
| Subject | Re: [PATCH v15 03/12] perf tools: Update perf evlist mmap related APIs and helpers |
| Message-ID | <rUE6t-2Rt-7@gated-at.bofh.it> |
| In reply to | #1442494 |
On 2016/7/13 22:06, Jiri Olsa wrote:
> On Tue, Jul 12, 2016 at 10:00:03AM +0000, Wang Nan wrote:
>
> SNIP
>
>> -union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, int idx)
>> +union perf_event *perf_mmap__read_forward(struct perf_mmap *md, bool overwrite)
>> {
>> - struct perf_mmap *md = &evlist->mmap[idx];
>> u64 head;
>> u64 old = md->prev;
>>
>> @@ -795,13 +795,12 @@ union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, int
>>
>> head = perf_mmap__read_head(md);
>>
>> - return perf_mmap__read(md, evlist->overwrite, old, head, &md->prev);
>> + return perf_mmap__read(md, overwrite, old, head, &md->prev);
>> }
>>
>> union perf_event *
>> -perf_evlist__mmap_read_backward(struct perf_evlist *evlist, int idx)
>> +perf_mmap__read_backward(struct perf_mmap *md, bool overwrite __maybe_unused)
>> {
>> - struct perf_mmap *md = &evlist->mmap[idx];
>> u64 head, end;
>> u64 start = md->prev;
>>
>> @@ -836,6 +835,20 @@ perf_evlist__mmap_read_backward(struct perf_evlist *evlist, int idx)
>> return perf_mmap__read(md, false, start, end, &md->prev);
> should you pas evlist->overwrite in here?
No need. The second arg of perf_mmap__read() is not 'overwrite', but
'check_messup'.
When set to 'true', stop reading if caller require a buffer larger than
half of the
size of the ring buffer and report a warning. Only forward, read-only
ring buffer
requires this check. We can always read the whole backward ring buffer
because we
pause it before reading.
I'll add more comments here.
Thank you.
> thanks,
> jirka
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web