From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, paulus@samba.org, hpa@zytor.com,
mingo@redhat.com, a.p.zijlstra@chello.nl, tglx@linutronix.de,
cjashfor@linux.vnet.ibm.com, mingo@elte.hu
Subject: [tip:perfcounters/core] perf_counter: minimize context time updates
Date: Tue, 7 Apr 2009 09:09:38 GMT [thread overview]
Message-ID: <tip-bce379bf358738ab8efc8cda2594a299ac685085@git.kernel.org> (raw)
In-Reply-To: <20090406094518.618876874@chello.nl>
Commit-ID: bce379bf358738ab8efc8cda2594a299ac685085
Gitweb: http://git.kernel.org/tip/bce379bf358738ab8efc8cda2594a299ac685085
Author: Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Mon, 6 Apr 2009 11:45:13 +0200
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Tue, 7 Apr 2009 10:49:01 +0200
perf_counter: minimize context time updates
Push the update_context_time() calls up the stack so that we get less
invokations and thereby a less noisy output:
before:
# ./perfstat -e 1:0 -e 1:1 -e 1:1 -e 1:1 -l ls > /dev/null
Performance counter stats for 'ls':
10.163691 cpu clock ticks (msecs) (scaled from 98.94%)
10.215360 task clock ticks (msecs) (scaled from 98.18%)
10.185549 task clock ticks (msecs) (scaled from 98.53%)
10.183581 task clock ticks (msecs) (scaled from 98.71%)
Wall-clock time elapsed: 11.912858 msecs
after:
# ./perfstat -e 1:0 -e 1:1 -e 1:1 -e 1:1 -l ls > /dev/null
Performance counter stats for 'ls':
9.316630 cpu clock ticks (msecs)
9.280789 task clock ticks (msecs)
9.280789 task clock ticks (msecs)
9.280789 task clock ticks (msecs)
Wall-clock time elapsed: 9.574872 msecs
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
LKML-Reference: <20090406094518.618876874@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/perf_counter.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index f4f7596..863703b 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -319,6 +319,8 @@ static void __perf_counter_disable(void *info)
spin_lock_irqsave(&ctx->lock, flags);
+ update_context_time(ctx);
+
/*
* If the counter is on, turn it off.
* If it is in error state, leave it in error state.
@@ -797,6 +799,8 @@ void perf_counter_task_sched_out(struct task_struct *task, int cpu)
if (likely(!cpuctx->task_ctx))
return;
+ update_context_time(ctx);
+
regs = task_pt_regs(task);
perf_swcounter_event(PERF_COUNT_CONTEXT_SWITCHES, 1, 1, regs);
__perf_counter_sched_out(ctx, cpuctx);
@@ -2336,7 +2340,6 @@ static void task_clock_perf_counter_update(struct perf_counter *counter)
u64 prev, now;
s64 delta;
- update_context_time(counter->ctx);
now = counter->ctx->time;
prev = atomic64_xchg(&counter->hw.prev_count, now);
@@ -2349,7 +2352,6 @@ static int task_clock_perf_counter_enable(struct perf_counter *counter)
struct hw_perf_counter *hwc = &counter->hw;
u64 now;
- update_context_time(counter->ctx);
now = counter->ctx->time;
atomic64_set(&hwc->prev_count, now);
@@ -2372,6 +2374,7 @@ static void task_clock_perf_counter_disable(struct perf_counter *counter)
static void task_clock_perf_counter_read(struct perf_counter *counter)
{
+ update_context_time(counter->ctx);
task_clock_perf_counter_update(counter);
}
next prev parent reply other threads:[~2009-04-07 9:13 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-06 9:44 [PATCH 00/15] various perf counter bits Peter Zijlstra
2009-04-06 9:44 ` [PATCH 01/15] perf_counter: update mmap() counter read, take 2 Peter Zijlstra
2009-04-07 9:06 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-06 9:45 ` [PATCH 02/15] perf_counter: add more context information Peter Zijlstra
2009-04-07 9:07 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-06 9:45 ` [PATCH 03/15] perf_counter: SIGIO support Peter Zijlstra
2009-04-07 9:07 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-06 9:45 ` [PATCH 04/15] perf_counter: generalize pending infrastructure Peter Zijlstra
2009-04-07 9:07 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-06 9:45 ` [PATCH 05/15] perf_counter: x86: self-IPI for pending work Peter Zijlstra
2009-04-07 9:07 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-06 9:45 ` [PATCH 06/15] perf_counter: theres more to overflow than writing events Peter Zijlstra
2009-04-07 9:07 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-06 9:45 ` [PATCH 07/15] perf_counter: fix the mlock accounting Peter Zijlstra
2009-04-07 9:08 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-06 9:45 ` [PATCH 08/15] perf_counter: PERF_RECORD_TIME Peter Zijlstra
2009-04-07 9:08 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-06 9:45 ` [PATCH 09/15] perf_counter: counter overflow limit Peter Zijlstra
2009-04-07 9:08 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-06 9:45 ` [PATCH 10/15] perf_counter: comment the perf_event_type stuff Peter Zijlstra
2009-04-07 9:08 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-06 9:45 ` [PATCH 11/15] perf_counter: change event defenition Peter Zijlstra
2009-04-07 9:08 ` [tip:perfcounters/core] perf_counter: change event definition Peter Zijlstra
2009-04-06 9:45 ` [PATCH 12/15] perf_counter: rework context time Peter Zijlstra
2009-04-07 9:09 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-06 9:45 ` [PATCH 13/15] perf_counter: rework the task clock software counter Peter Zijlstra
2009-04-07 9:09 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-07 9:36 ` [tip:perfcounters/core] x86, perfcounters: add atomic64_xchg() Ingo Molnar
2009-04-07 11:19 ` Paul Mackerras
2009-04-07 13:28 ` Ingo Molnar
2009-04-07 10:06 ` Ingo Molnar
2009-04-06 9:45 ` [PATCH 14/15] perf_counter: remove rq->lock usage Peter Zijlstra
2009-04-07 9:09 ` [tip:perfcounters/core] " Peter Zijlstra
2009-04-06 9:45 ` [PATCH 15/15] perf_counter: minimize context time updates Peter Zijlstra
2009-04-07 9:09 ` Peter Zijlstra [this message]
2009-04-07 9:21 ` [PATCH 00/15] various perf counter bits Ingo Molnar
2009-04-07 9:21 ` Ingo Molnar
2009-04-07 9:33 ` Ingo Molnar
2009-04-07 9:23 ` 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=tip-bce379bf358738ab8efc8cda2594a299ac685085@git.kernel.org \
--to=a.p.zijlstra@chello.nl \
--cc=cjashfor@linux.vnet.ibm.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=paulus@samba.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: 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