From: "tip-bot2 for Ian Rogers" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Ian Rogers <irogers@google.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>, x86 <x86@kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [tip: perf/core] perf/core: Add per perf_cpu_context min_heap storage
Date: Fri, 06 Mar 2020 14:42:01 -0000 [thread overview]
Message-ID: <158350572112.28353.5843586926290087112.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20200214075133.181299-5-irogers@google.com>
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 836196beb377e59e54ec9e04f7402076ef7a8bd8
Gitweb: https://git.kernel.org/tip/836196beb377e59e54ec9e04f7402076ef7a8bd8
Author: Ian Rogers <irogers@google.com>
AuthorDate: Thu, 13 Feb 2020 23:51:31 -08:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Fri, 06 Mar 2020 11:57:00 +01:00
perf/core: Add per perf_cpu_context min_heap storage
The storage required for visit_groups_merge's min heap needs to vary in
order to support more iterators, such as when multiple nested cgroups'
events are being visited. This change allows for 2 iterators and doesn't
support growth.
Based-on-work-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lkml.kernel.org/r/20200214075133.181299-5-irogers@google.com
---
include/linux/perf_event.h | 7 ++++++-
kernel/events/core.c | 43 +++++++++++++++++++++++++++----------
2 files changed, 39 insertions(+), 11 deletions(-)
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 68e21e8..8768a39 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -862,6 +862,13 @@ struct perf_cpu_context {
int sched_cb_usage;
int online;
+ /*
+ * Per-CPU storage for iterators used in visit_groups_merge. The default
+ * storage is of size 2 to hold the CPU and any CPU event iterators.
+ */
+ int heap_size;
+ struct perf_event **heap;
+ struct perf_event *heap_default[2];
};
struct perf_output_handle {
diff --git a/kernel/events/core.c b/kernel/events/core.c
index ddfb06c..7529e76 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3423,22 +3423,34 @@ static void __heap_add(struct min_heap *heap, struct perf_event *event)
}
}
-static noinline int visit_groups_merge(struct perf_event_groups *groups,
- int cpu,
+static noinline int visit_groups_merge(struct perf_cpu_context *cpuctx,
+ struct perf_event_groups *groups, int cpu,
int (*func)(struct perf_event *, void *),
void *data)
{
/* Space for per CPU and/or any CPU event iterators. */
struct perf_event *itrs[2];
- struct min_heap event_heap = {
- .data = itrs,
- .nr = 0,
- .size = ARRAY_SIZE(itrs),
- };
- struct perf_event **evt = event_heap.data;
+ struct min_heap event_heap;
+ struct perf_event **evt;
int ret;
- __heap_add(&event_heap, perf_event_groups_first(groups, -1));
+ if (cpuctx) {
+ event_heap = (struct min_heap){
+ .data = cpuctx->heap,
+ .nr = 0,
+ .size = cpuctx->heap_size,
+ };
+ } else {
+ event_heap = (struct min_heap){
+ .data = itrs,
+ .nr = 0,
+ .size = ARRAY_SIZE(itrs),
+ };
+ /* Events not within a CPU context may be on any CPU. */
+ __heap_add(&event_heap, perf_event_groups_first(groups, -1));
+ }
+ evt = event_heap.data;
+
__heap_add(&event_heap, perf_event_groups_first(groups, cpu));
min_heapify_all(&event_heap, &perf_min_heap);
@@ -3492,7 +3504,10 @@ ctx_pinned_sched_in(struct perf_event_context *ctx,
{
int can_add_hw = 1;
- visit_groups_merge(&ctx->pinned_groups,
+ if (ctx != &cpuctx->ctx)
+ cpuctx = NULL;
+
+ visit_groups_merge(cpuctx, &ctx->pinned_groups,
smp_processor_id(),
merge_sched_in, &can_add_hw);
}
@@ -3503,7 +3518,10 @@ ctx_flexible_sched_in(struct perf_event_context *ctx,
{
int can_add_hw = 1;
- visit_groups_merge(&ctx->flexible_groups,
+ if (ctx != &cpuctx->ctx)
+ cpuctx = NULL;
+
+ visit_groups_merge(cpuctx, &ctx->flexible_groups,
smp_processor_id(),
merge_sched_in, &can_add_hw);
}
@@ -10364,6 +10382,9 @@ skip_type:
cpuctx->online = cpumask_test_cpu(cpu, perf_online_mask);
__perf_mux_hrtimer_init(cpuctx, cpu);
+
+ cpuctx->heap_size = ARRAY_SIZE(cpuctx->heap_default);
+ cpuctx->heap = cpuctx->heap_default;
}
got_cpu_context:
next prev parent reply other threads:[~2020-03-06 14:42 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-14 0:30 [PATCH v3 00/10] Optimize cgroup context switch Ian Rogers
2019-11-14 0:30 ` [PATCH v3 01/10] perf/cgroup: Reorder perf_cgroup_connect() Ian Rogers
2019-11-14 8:50 ` Peter Zijlstra
2019-11-14 0:30 ` [PATCH v3 02/10] lib: introduce generic min max heap Ian Rogers
2019-11-14 9:32 ` Peter Zijlstra
2019-11-14 9:35 ` Peter Zijlstra
2019-11-17 18:28 ` Joe Perches
2019-11-18 8:40 ` Peter Zijlstra
2019-11-18 11:50 ` Joe Perches
2019-11-18 12:21 ` Peter Zijlstra
2019-11-14 0:30 ` [PATCH v3 03/10] perf: Use min_max_heap in visit_groups_merge Ian Rogers
2019-11-14 9:39 ` Peter Zijlstra
2019-11-14 0:30 ` [PATCH v3 04/10] perf: Add per perf_cpu_context min_heap storage Ian Rogers
2019-11-14 9:51 ` Peter Zijlstra
2019-11-16 1:19 ` Ian Rogers
2019-11-14 0:30 ` [PATCH v3 05/10] perf/cgroup: Grow per perf_cpu_context heap storage Ian Rogers
2019-11-14 9:54 ` Peter Zijlstra
2019-11-14 0:30 ` [PATCH v3 06/10] perf/cgroup: Order events in RB tree by cgroup id Ian Rogers
2019-11-14 0:30 ` [PATCH v3 07/10] perf: simplify and rename visit_groups_merge Ian Rogers
2019-11-14 10:03 ` Peter Zijlstra
2019-11-16 1:20 ` Ian Rogers
2019-11-14 0:30 ` [PATCH v3 08/10] perf: cache perf_event_groups_first for cgroups Ian Rogers
2019-11-14 10:25 ` Peter Zijlstra
2019-11-16 1:20 ` Ian Rogers
2019-11-18 8:37 ` Peter Zijlstra
2019-11-14 0:30 ` [PATCH v3 09/10] perf: optimize event_filter_match during sched_in Ian Rogers
2019-11-14 0:30 ` [PATCH v3 10/10] perf/cgroup: Do not switch system-wide events in cgroup switch Ian Rogers
2019-11-14 10:43 ` Peter Zijlstra
2019-11-14 13:46 ` Liang, Kan
2019-11-14 13:57 ` Peter Zijlstra
2019-11-14 15:16 ` Liang, Kan
2019-11-14 15:24 ` Liang, Kan
2019-11-14 20:49 ` Liang, Kan
2019-11-14 0:42 ` [PATCH v3 00/10] Optimize cgroup context switch Ian Rogers
2019-11-14 10:45 ` Peter Zijlstra
2019-11-14 18:17 ` Ian Rogers
2019-12-06 23:16 ` Ian Rogers
2019-11-16 1:18 ` [PATCH v4 " Ian Rogers
2019-11-16 1:18 ` [PATCH v4 01/10] perf/cgroup: Reorder perf_cgroup_connect() Ian Rogers
2019-11-16 1:18 ` [PATCH v4 02/10] lib: introduce generic min max heap Ian Rogers
2019-11-21 11:11 ` Joe Perches
2019-11-16 1:18 ` [PATCH v4 03/10] perf: Use min_max_heap in visit_groups_merge Ian Rogers
2019-11-16 1:18 ` [PATCH v4 04/10] perf: Add per perf_cpu_context min_heap storage Ian Rogers
2019-11-16 1:18 ` [PATCH v4 05/10] perf/cgroup: Grow per perf_cpu_context heap storage Ian Rogers
2019-11-16 1:18 ` [PATCH v4 06/10] perf/cgroup: Order events in RB tree by cgroup id Ian Rogers
2019-11-16 1:18 ` [PATCH v4 07/10] perf: simplify and rename visit_groups_merge Ian Rogers
2019-11-16 1:18 ` [PATCH v4 08/10] perf: cache perf_event_groups_first for cgroups Ian Rogers
2019-11-16 1:18 ` [PATCH v4 09/10] perf: optimize event_filter_match during sched_in Ian Rogers
2019-11-16 1:18 ` [PATCH v4 10/10] perf/cgroup: Do not switch system-wide events in cgroup switch Ian Rogers
2019-12-06 23:15 ` [PATCH v5 00/10] Optimize cgroup context switch Ian Rogers
2019-12-06 23:15 ` [PATCH v5 01/10] perf/cgroup: Reorder perf_cgroup_connect() Ian Rogers
2019-12-06 23:15 ` [PATCH v5 02/10] lib: introduce generic min-heap Ian Rogers
2019-12-06 23:15 ` [PATCH v5 03/10] perf: Use min_max_heap in visit_groups_merge Ian Rogers
2019-12-08 7:10 ` kbuild test robot
2019-12-06 23:15 ` [PATCH v5 04/10] perf: Add per perf_cpu_context min_heap storage Ian Rogers
2019-12-06 23:15 ` [PATCH v5 05/10] perf/cgroup: Grow per perf_cpu_context heap storage Ian Rogers
2019-12-06 23:15 ` [PATCH v5 06/10] perf/cgroup: Order events in RB tree by cgroup id Ian Rogers
2019-12-06 23:15 ` [PATCH v5 07/10] perf: simplify and rename visit_groups_merge Ian Rogers
2019-12-06 23:15 ` [PATCH v5 08/10] perf: cache perf_event_groups_first for cgroups Ian Rogers
2019-12-06 23:15 ` [PATCH v5 09/10] perf: optimize event_filter_match during sched_in Ian Rogers
2019-12-06 23:15 ` [PATCH v5 10/10] perf/cgroup: Do not switch system-wide events in cgroup switch Ian Rogers
2020-02-14 7:51 ` [PATCH v6 0/6] Optimize cgroup context switch Ian Rogers
2020-02-14 7:51 ` [PATCH v6 1/6] perf/cgroup: Reorder perf_cgroup_connect() Ian Rogers
2020-02-14 16:11 ` Shuah Khan
2020-02-14 17:37 ` Peter Zijlstra
2020-03-06 14:42 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2020-02-14 7:51 ` [PATCH v6 2/6] lib: introduce generic min-heap Ian Rogers
2020-02-14 22:06 ` Randy Dunlap
2020-02-17 16:29 ` Peter Zijlstra
2020-03-06 14:42 ` [tip: perf/core] lib: Introduce " tip-bot2 for Ian Rogers
2020-02-14 7:51 ` [PATCH v6 3/6] perf: Use min_heap in visit_groups_merge Ian Rogers
2020-02-17 17:23 ` Peter Zijlstra
2020-03-06 14:42 ` [tip: perf/core] perf/core: Use min_heap in visit_groups_merge() tip-bot2 for Ian Rogers
2020-02-14 7:51 ` [PATCH v6 4/6] perf: Add per perf_cpu_context min_heap storage Ian Rogers
2020-03-06 14:42 ` tip-bot2 for Ian Rogers [this message]
2020-02-14 7:51 ` [PATCH v6 5/6] perf/cgroup: Grow per perf_cpu_context heap storage Ian Rogers
2020-03-06 14:42 ` [tip: perf/core] " tip-bot2 for Ian Rogers
2020-02-14 7:51 ` [PATCH v6 6/6] perf/cgroup: Order events in RB tree by cgroup id Ian Rogers
2020-02-14 19:32 ` [PATCH v6 0/6] Optimize cgroup context switch Ian Rogers
2020-02-17 16:18 ` Peter Zijlstra
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=158350572112.28353.5843586926290087112.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=x86@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 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).