Re: [PATCH 21/52] perf session: Add ability to skip 4GiB or more

Arnaldo Carvalho de Melo
2014-07-23T14:45:30Z

Em Tue, Jul 22, 2014 at 04:17:30PM +0300, Adrian Hunter escreveu:
> A session can be made to skip portions of the input
> file. Do not limit that size to 32-bits.

Aren't there two changes here? One that is described in the changelog,
another that makes the value returned by perf_session__process_event to
be properly used if > 0?

Can you please split and provide relevant changeset comments?

- Arnaldo

> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> tools/perf/util/session.c | 20 +++++++++++++-------
> 1 file changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index 8aa1be1..708e1c1 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -1026,8 +1026,10 @@ static int perf_session_deliver_event(struct perf_session *session,
> }
> }
>
> -static int perf_session__process_user_event(struct perf_session *session, union perf_event *event,
> - struct perf_tool *tool, u64 file_offset)
> +static s64 perf_session__process_user_event(struct perf_session *session,
> + union perf_event *event,
> + struct perf_tool *tool,
> + u64 file_offset)
> {
> int fd = perf_data_file__fd(session->file);
> int err;
> @@ -1073,7 +1075,7 @@ static void event_swap(union perf_event *event, bool sample_id_all)
> swap(event, sample_id_all);
> }
>
> -static int perf_session__process_event(struct perf_session *session,
> +static s64 perf_session__process_event(struct perf_session *session,
> union perf_event *event,
> struct perf_tool *tool,
> u64 file_offset)
> @@ -1184,7 +1186,7 @@ static int __perf_session__process_pipe_events(struct perf_session *session,
> union perf_event *event;
> uint32_t size, cur_size = 0;
> void *buf = NULL;
> - int skip = 0;
> + s64 skip = 0;
> u64 head;
> ssize_t err;
> void *p;
> @@ -1313,13 +1315,13 @@ int __perf_session__process_events(struct perf_session *session,
> u64 file_size, struct perf_tool *tool)
> {
> int fd = perf_data_file__fd(session->file);
> - u64 head, page_offset, file_offset, file_pos;
> + u64 head, page_offset, file_offset, file_pos, size;
> int err, mmap_prot, mmap_flags, map_idx = 0;
> size_t mmap_size;
> char *buf, *mmaps[NUM_MMAPS];
> union perf_event *event;
> - uint32_t size;
> struct ui_progress prog;
> + s64 skip;
>
> perf_tool__fill_defaults(tool);
>
> @@ -1380,7 +1382,8 @@ more:
> size = event->header.size;
>
> if (size < sizeof(struct perf_event_header) ||
> - perf_session__process_event(session, event, tool, file_pos) < 0) {
> + (skip = perf_session__process_event(session, event, tool, file_pos))
> + < 0) {
> pr_err("%#" PRIx64 " [%#x]: failed to process type: %d\n",
> file_offset + head, event->header.size,
> event->header.type);
> @@ -1388,6 +1391,9 @@ more:
> goto out_err;
> }
>
> + if (skip)
> + size += skip;
> +

I.e. the above

> head += size;
> file_pos += size;
>
> --
> 1.8.3.2