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/cgroup: Grow per perf_cpu_context heap storage
Date: Fri, 06 Mar 2020 14:42:00 -0000 [thread overview]
Message-ID: <158350572076.28353.12179412076735895355.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20200214075133.181299-6-irogers@google.com>
The following commit has been merged into the perf/core branch of tip:
Commit-ID: c2283c9368d41063f2077cb58def02217360526d
Gitweb: https://git.kernel.org/tip/c2283c9368d41063f2077cb58def02217360526d
Author: Ian Rogers <irogers@google.com>
AuthorDate: Thu, 13 Feb 2020 23:51:32 -08:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Fri, 06 Mar 2020 11:57:00 +01:00
perf/cgroup: Grow per perf_cpu_context heap storage
Allow the per-CPU min heap storage to have sufficient space for per-cgroup
iterators.
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-6-irogers@google.com
---
kernel/events/core.c | 47 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 47 insertions(+)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 7529e76..8065949 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -892,6 +892,47 @@ static inline void perf_cgroup_sched_in(struct task_struct *prev,
rcu_read_unlock();
}
+static int perf_cgroup_ensure_storage(struct perf_event *event,
+ struct cgroup_subsys_state *css)
+{
+ struct perf_cpu_context *cpuctx;
+ struct perf_event **storage;
+ int cpu, heap_size, ret = 0;
+
+ /*
+ * Allow storage to have sufficent space for an iterator for each
+ * possibly nested cgroup plus an iterator for events with no cgroup.
+ */
+ for (heap_size = 1; css; css = css->parent)
+ heap_size++;
+
+ for_each_possible_cpu(cpu) {
+ cpuctx = per_cpu_ptr(event->pmu->pmu_cpu_context, cpu);
+ if (heap_size <= cpuctx->heap_size)
+ continue;
+
+ storage = kmalloc_node(heap_size * sizeof(struct perf_event *),
+ GFP_KERNEL, cpu_to_node(cpu));
+ if (!storage) {
+ ret = -ENOMEM;
+ break;
+ }
+
+ raw_spin_lock_irq(&cpuctx->ctx.lock);
+ if (cpuctx->heap_size < heap_size) {
+ swap(cpuctx->heap, storage);
+ if (storage == cpuctx->heap_default)
+ storage = NULL;
+ cpuctx->heap_size = heap_size;
+ }
+ raw_spin_unlock_irq(&cpuctx->ctx.lock);
+
+ kfree(storage);
+ }
+
+ return ret;
+}
+
static inline int perf_cgroup_connect(int fd, struct perf_event *event,
struct perf_event_attr *attr,
struct perf_event *group_leader)
@@ -911,6 +952,10 @@ static inline int perf_cgroup_connect(int fd, struct perf_event *event,
goto out;
}
+ ret = perf_cgroup_ensure_storage(event, css);
+ if (ret)
+ goto out;
+
cgrp = container_of(css, struct perf_cgroup, css);
event->cgrp = cgrp;
@@ -3440,6 +3485,8 @@ static noinline int visit_groups_merge(struct perf_cpu_context *cpuctx,
.nr = 0,
.size = cpuctx->heap_size,
};
+
+ lockdep_assert_held(&cpuctx->ctx.lock);
} else {
event_heap = (struct min_heap){
.data = itrs,
next prev parent reply other threads:[~2020-03-06 14:44 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: perf/core] perf/core: " tip-bot2 for Ian Rogers
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-bot2 for Ian Rogers [this message]
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=158350572076.28353.12179412076735895355.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).