From: tip-bot for Jiri Olsa <tipbot@zytor.com> To: linux-tip-commits@vger.kernel.org Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, jolsa@kernel.org, namhyung@kernel.org, alexander.shishkin@linux.intel.com, hpa@zytor.com, davem@davemloft.net, peterz@infradead.org, mingo@kernel.org Subject: [tip:perf/core] perf top: Drop samples which are behind the refresh rate Date: Fri, 14 Dec 2018 12:49:31 -0800 [thread overview] Message-ID: <tip-x533ra5c1pgofvbtsizzuydd@git.kernel.org> (raw) Commit-ID: bdbc7bcf0f9ac6196b23244b10632c30efb8653a Gitweb: https://git.kernel.org/tip/bdbc7bcf0f9ac6196b23244b10632c30efb8653a Author: Jiri Olsa <jolsa@kernel.org> AuthorDate: Sun, 11 Nov 2018 19:52:06 +0100 Committer: Arnaldo Carvalho de Melo <acme@redhat.com> CommitDate: Thu, 6 Dec 2018 14:12:34 -0300 perf top: Drop samples which are behind the refresh rate Drop samples from processing thread if they get behind the latest event read from the kernel maps. If it gets behind more than the refresh rate (-d option), drop the sample. Acked-by: David S. Miller <davem@davemloft.net> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://lkml.kernel.org/n/tip-x533ra5c1pgofvbtsizzuydd@git.kernel.org Signed-off-by: Jiri Olsa <jolsa@kernel.org> --- tools/perf/builtin-top.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 50ec01eb7f57..234232d538c2 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -833,6 +833,8 @@ perf_top__process_lost_samples(struct perf_top *top, hists->stats.total_lost_samples += event->lost_samples.lost; } +static u64 last_timestamp; + static void perf_top__mmap_read_idx(struct perf_top *top, int idx) { struct record_opts *opts = &top->record_opts; @@ -845,14 +847,13 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) return; while ((event = perf_mmap__read_event(md)) != NULL) { - u64 timestamp = -1ULL; int ret; - ret = perf_evlist__parse_sample_timestamp(evlist, event, ×tamp); + ret = perf_evlist__parse_sample_timestamp(evlist, event, &last_timestamp); if (ret && ret != -1) break; - ret = ordered_events__queue(top->qe.in, event, timestamp, 0); + ret = ordered_events__queue(top->qe.in, event, last_timestamp, 0); if (ret) break; @@ -1084,6 +1085,21 @@ static void *process_thread(void *arg) return NULL; } +/* + * Allow only 'top->delay_secs' seconds behind samples. + */ +static int should_drop(struct ordered_event *qevent, struct perf_top *top) +{ + union perf_event *event = qevent->event; + u64 delay_timestamp; + + if (event->header.type != PERF_RECORD_SAMPLE) + return false; + + delay_timestamp = qevent->timestamp + top->delay_secs * NSEC_PER_SEC; + return delay_timestamp < last_timestamp; +} + static int deliver_event(struct ordered_events *qe, struct ordered_event *qevent) { @@ -1096,6 +1112,9 @@ static int deliver_event(struct ordered_events *qe, struct machine *machine; int ret = -1; + if (should_drop(qevent, top)) + return 0; + ret = perf_evlist__parse_sample(evlist, event, &sample); if (ret) { pr_err("Can't parse sample, err = %d\n", ret);
WARNING: multiple messages have this Message-ID (diff)
From: tip-bot for Jiri Olsa <tipbot@zytor.com> To: linux-tip-commits@vger.kernel.org Cc: alexander.shishkin@linux.intel.com, jolsa@kernel.org, peterz@infradead.org, mingo@kernel.org, hpa@zytor.com, acme@redhat.com, davem@davemloft.net, namhyung@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org Subject: [tip:perf/core] perf top: Drop samples which are behind the refresh rate Date: Tue, 18 Dec 2018 06:16:28 -0800 [thread overview] Message-ID: <tip-x533ra5c1pgofvbtsizzuydd@git.kernel.org> (raw) Message-ID: <20181218141628.tyltgGuYiSvNkT5UrR28IfAuNLHmfDHQ6882ecLM6p0@z> (raw) Commit-ID: d63b9f6fea7613e2fdc8a5ef7e17ecc9cf24bf9d Gitweb: https://git.kernel.org/tip/d63b9f6fea7613e2fdc8a5ef7e17ecc9cf24bf9d Author: Jiri Olsa <jolsa@kernel.org> AuthorDate: Sun, 11 Nov 2018 19:52:06 +0100 Committer: Arnaldo Carvalho de Melo <acme@redhat.com> CommitDate: Mon, 17 Dec 2018 14:58:26 -0300 perf top: Drop samples which are behind the refresh rate Drop samples from processing thread if they get behind the latest event read from the kernel maps. If it gets behind more than the refresh rate (-d option), drop the sample. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Acked-by: David S. Miller <davem@davemloft.net> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://lkml.kernel.org/n/tip-x533ra5c1pgofvbtsizzuydd@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> --- tools/perf/builtin-top.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 50ec01eb7f57..234232d538c2 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -833,6 +833,8 @@ perf_top__process_lost_samples(struct perf_top *top, hists->stats.total_lost_samples += event->lost_samples.lost; } +static u64 last_timestamp; + static void perf_top__mmap_read_idx(struct perf_top *top, int idx) { struct record_opts *opts = &top->record_opts; @@ -845,14 +847,13 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) return; while ((event = perf_mmap__read_event(md)) != NULL) { - u64 timestamp = -1ULL; int ret; - ret = perf_evlist__parse_sample_timestamp(evlist, event, ×tamp); + ret = perf_evlist__parse_sample_timestamp(evlist, event, &last_timestamp); if (ret && ret != -1) break; - ret = ordered_events__queue(top->qe.in, event, timestamp, 0); + ret = ordered_events__queue(top->qe.in, event, last_timestamp, 0); if (ret) break; @@ -1084,6 +1085,21 @@ static void *process_thread(void *arg) return NULL; } +/* + * Allow only 'top->delay_secs' seconds behind samples. + */ +static int should_drop(struct ordered_event *qevent, struct perf_top *top) +{ + union perf_event *event = qevent->event; + u64 delay_timestamp; + + if (event->header.type != PERF_RECORD_SAMPLE) + return false; + + delay_timestamp = qevent->timestamp + top->delay_secs * NSEC_PER_SEC; + return delay_timestamp < last_timestamp; +} + static int deliver_event(struct ordered_events *qe, struct ordered_event *qevent) { @@ -1096,6 +1112,9 @@ static int deliver_event(struct ordered_events *qe, struct machine *machine; int ret = -1; + if (should_drop(qevent, top)) + return 0; + ret = perf_evlist__parse_sample(evlist, event, &sample); if (ret) { pr_err("Can't parse sample, err = %d\n", ret);
next reply other threads:[~2018-12-14 20:49 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-12-14 20:49 tip-bot for Jiri Olsa [this message] 2018-12-18 14:16 ` [tip:perf/core] perf top: Drop samples which are behind the refresh rate tip-bot for Jiri Olsa
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=tip-x533ra5c1pgofvbtsizzuydd@git.kernel.org \ --to=tipbot@zytor.com \ --cc=alexander.shishkin@linux.intel.com \ --cc=davem@davemloft.net \ --cc=hpa@zytor.com \ --cc=jolsa@kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-tip-commits@vger.kernel.org \ --cc=mingo@kernel.org \ --cc=namhyung@kernel.org \ --cc=peterz@infradead.org \ --cc=tglx@linutronix.de \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).