From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>,
Corey Ashford <cjashfor@linux.vnet.ibm.com>,
linux-kernel@vger.kernel.org,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 2/4] perf_counter: optimize mmap/comm tracking
Date: Thu, 09 Apr 2009 10:53:44 +0200 [thread overview]
Message-ID: <20090409085524.427173196@chello.nl> (raw)
In-Reply-To: 20090409085342.799915215@chello.nl
[-- Attachment #1: perf_counter-opt-tracing.patch --]
[-- Type: text/plain, Size: 2339 bytes --]
The mmap/comm tracking code does quite a lot of work before it discovers
there's no interest in it, avoid that by keeping a counter.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
kernel/perf_counter.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
Index: linux-2.6/kernel/perf_counter.c
===================================================================
--- linux-2.6.orig/kernel/perf_counter.c
+++ linux-2.6/kernel/perf_counter.c
@@ -38,6 +38,10 @@ int perf_max_counters __read_mostly = 1;
static int perf_reserved_percpu __read_mostly;
static int perf_overcommit __read_mostly = 1;
+static atomic_t nr_mmap_tracking __read_mostly;
+static atomic_t nr_munmap_tracking __read_mostly;
+static atomic_t nr_comm_tracking __read_mostly;
+
/*
* Mutex for (sysadmin-configurable) counter reservations:
*/
@@ -1186,6 +1190,13 @@ static void free_counter(struct perf_cou
{
perf_pending_sync(counter);
+ if (counter->hw_event.mmap)
+ atomic_dec(&nr_mmap_tracking);
+ if (counter->hw_event.munmap)
+ atomic_dec(&nr_munmap_tracking);
+ if (counter->hw_event.comm)
+ atomic_dec(&nr_comm_tracking);
+
if (counter->destroy)
counter->destroy(counter);
@@ -2128,7 +2139,12 @@ got_name:
void perf_counter_mmap(unsigned long addr, unsigned long len,
unsigned long pgoff, struct file *file)
{
- struct perf_mmap_event mmap_event = {
+ struct perf_mmap_event mmap_event;
+
+ if (!atomic_read(&nr_mmap_tracking))
+ return;
+
+ mmap_event = (struct perf_mmap_event){
.file = file,
.event = {
.header = { .type = PERF_EVENT_MMAP, },
@@ -2146,7 +2162,12 @@ void perf_counter_mmap(unsigned long add
void perf_counter_munmap(unsigned long addr, unsigned long len,
unsigned long pgoff, struct file *file)
{
- struct perf_mmap_event mmap_event = {
+ struct perf_mmap_event mmap_event;
+
+ if (!atomic_read(&nr_munmap_tracking))
+ return;
+
+ mmap_event = (struct perf_mmap_event){
.file = file,
.event = {
.header = { .type = PERF_EVENT_MUNMAP, },
@@ -2725,6 +2746,13 @@ done:
counter->hw_ops = hw_ops;
+ if (counter->hw_event.mmap)
+ atomic_inc(&nr_mmap_tracking);
+ if (counter->hw_event.munmap)
+ atomic_inc(&nr_munmap_tracking);
+ if (counter->hw_event.comm)
+ atomic_inc(&nr_comm_tracking);
+
return counter;
}
--
next prev parent reply other threads:[~2009-04-09 8:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-09 8:53 [PATCH 0/4] perf_counter: fixes and an optimization Peter Zijlstra
2009-04-09 8:53 ` [PATCH 1/4] perf_counter: fix off-by-one on the string lengths Peter Zijlstra
2009-04-09 8:53 ` Peter Zijlstra [this message]
2009-04-09 9:06 ` [tip:perfcounters/core] perf_counter: optimize mmap/comm tracking Peter Zijlstra
2009-04-09 9:16 ` [PATCH 2/4] " Ingo Molnar
2009-04-09 9:28 ` Peter Zijlstra
2009-04-09 9:54 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-09 8:53 ` [PATCH 3/4] perf_counter: sysctl for system wide perf counters Peter Zijlstra
2009-04-09 9:06 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-09 9:54 ` Peter Zijlstra
2009-04-09 8:53 ` [PATCH 4/4] perf_counter: log full path names Peter Zijlstra
2009-04-09 9:07 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-09 9:54 ` Peter Zijlstra
2009-04-09 9:03 ` [PATCH 0/4] perf_counter: fixes and an optimization Ingo Molnar
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=20090409085524.427173196@chello.nl \
--to=a.p.zijlstra@chello.nl \
--cc=cjashfor@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.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