From: Jiri Olsa <jolsa@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andi Kleen <ak@linux.intel.com>,
lkml <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
David Ahern <dsahern@gmail.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>
Subject: [PATCH 03/12] perf: Allocate context task_ctx_data for child event
Date: Sun, 7 Jan 2018 17:03:47 +0100 [thread overview]
Message-ID: <20180107160356.28203-4-jolsa@kernel.org> (raw)
In-Reply-To: <20180107160356.28203-1-jolsa@kernel.org>
Currently we use perf_event_context::task_ctx_data to save
and restore the LBR status when the task is scheduled out
and in.
We don't allocate it for child contexts, which results in
shorter task's LBR stack, because we don't save the history
from previous run and start over every time we schedule the
task in.
I made a test to generate samples with LBR call stack
and got higher numbers on bigger chain depths:
before: after:
LBR call chain: nr: 1 60561 498127
LBR call chain: nr: 2 0 0
LBR call chain: nr: 3 107030 2172
LBR call chain: nr: 4 466685 62758
LBR call chain: nr: 5 2307319 878046
LBR call chain: nr: 6 48713 495218
LBR call chain: nr: 7 1040 4551
LBR call chain: nr: 8 481 172
LBR call chain: nr: 9 878 120
LBR call chain: nr: 10 2377 6698
LBR call chain: nr: 11 28830 151487
LBR call chain: nr: 12 29347 339867
LBR call chain: nr: 13 4 22
LBR call chain: nr: 14 3 53
Cc: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
kernel/events/core.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 4df5b695bf0d..55fb648a32b0 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -10703,6 +10703,19 @@ inherit_event(struct perf_event *parent_event,
if (IS_ERR(child_event))
return child_event;
+
+ if ((child_event->attach_state & PERF_ATTACH_TASK_DATA) &&
+ !child_ctx->task_ctx_data) {
+ struct pmu *pmu = child_event->pmu;
+
+ child_ctx->task_ctx_data = kzalloc(pmu->task_ctx_size,
+ GFP_KERNEL);
+ if (!child_ctx->task_ctx_data) {
+ free_event(child_event);
+ return NULL;
+ }
+ }
+
/*
* is_orphaned_event() and list_add_tail(&parent_event->child_list)
* must be under the same lock in order to serialize against
@@ -10713,6 +10726,7 @@ inherit_event(struct perf_event *parent_event,
if (is_orphaned_event(parent_event) ||
!atomic_long_inc_not_zero(&parent_event->refcount)) {
mutex_unlock(&parent_event->child_mutex);
+ /* task_ctx_data is freed with child_ctx */
free_event(child_event);
return NULL;
}
--
2.13.6
next prev parent reply other threads:[~2018-01-07 16:04 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-07 16:03 [PATCH 00/12] perf: Assorted fixes Jiri Olsa
2018-01-07 16:03 ` [PATCH 01/12] perf tools: Enable LIBBABELTRACE by default Jiri Olsa
2018-01-08 15:17 ` Arnaldo Carvalho de Melo
2018-01-08 15:20 ` Arnaldo Carvalho de Melo
2018-01-08 15:24 ` Arnaldo Carvalho de Melo
2018-01-08 17:11 ` Jiri Olsa
2018-01-08 17:16 ` Jiri Olsa
2018-01-09 9:26 ` [PATCH] perf build: Display EXTRA features for VF=1 build Jiri Olsa
2018-01-19 10:15 ` Jiri Olsa
2018-01-19 12:43 ` Arnaldo Carvalho de Melo
2018-01-24 11:23 ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-01-11 6:24 ` [tip:perf/core] perf tools: Enable LIBBABELTRACE by default tip-bot for Jiri Olsa
2018-01-07 16:03 ` [PATCH 02/12] perf tools: Display perf_event_attr::namespaces debug info Jiri Olsa
2018-01-11 6:24 ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-01-07 16:03 ` Jiri Olsa [this message]
2018-01-08 12:14 ` [PATCH 03/12] perf: Allocate context task_ctx_data for child event Peter Zijlstra
2018-01-11 6:24 ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-01-07 16:03 ` [PATCH 04/12] perf: Add sample_id to PERF_RECORD_ITRACE_START event comment Jiri Olsa
2018-01-11 6:25 ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-01-07 16:03 ` [PATCH 05/12] perf: Make perf_callchain function static Jiri Olsa
2018-01-11 6:25 ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-01-07 16:03 ` [PATCH 06/12] perf: Return empty callchain instead of NULL Jiri Olsa
2018-01-08 12:15 ` Peter Zijlstra
2018-01-11 6:26 ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-01-07 16:03 ` [PATCH 07/12] perf: Update PERF_RECORD_MISC_* comment for perf_event_header::misc bit 13 Jiri Olsa
2018-01-11 6:26 ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-01-07 16:03 ` [PATCH 08/12] perf script: Add support to display sample misc field Jiri Olsa
2018-01-11 6:27 ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-01-07 16:03 ` [PATCH 09/12] perf script: Add support to display lost events Jiri Olsa
2018-01-10 15:40 ` Arnaldo Carvalho de Melo
2018-01-10 15:44 ` Jiri Olsa
2018-01-11 6:27 ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-01-07 16:03 ` [PATCH 10/12] perf tools: Make the tool's warning messages optional Jiri Olsa
2018-01-11 6:27 ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-01-07 16:03 ` [PATCH 11/12] perf report: Add --stat option to display quick data statistics Jiri Olsa
2018-01-11 6:28 ` [tip:perf/core] perf report: Add --stats " tip-bot for Jiri Olsa
2018-01-07 16:03 ` [PATCH 12/12] perf report: Add --task option to display monitored tasks Jiri Olsa
2018-01-08 15:55 ` Arnaldo Carvalho de Melo
2018-01-08 16:03 ` Arnaldo Carvalho de Melo
2018-01-09 1:56 ` Namhyung Kim
2018-01-09 9:15 ` Jiri Olsa
2018-01-09 13:05 ` Arnaldo Carvalho de Melo
2018-01-09 13:27 ` Jiri Olsa
2018-01-11 6:29 ` [tip:perf/core] perf report: Add --tasks " 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=20180107160356.28203-4-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dsahern@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.