From: "tip-bot for markus.t.metzger@intel.com" <markus.t.metzger@intel.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
a.p.zijlstra@chello.nl, markus.t.metzger@intel.com,
tglx@linutronix.de, mingo@elte.hu
Subject: [tip:perfcounters/core] x86, perf_counter, bts: Fail if BTS is not available
Date: Fri, 4 Sep 2009 07:58:18 GMT [thread overview]
Message-ID: <tip-747b50aaf728987732e6ff3ba10aba4acc4e0277@git.kernel.org> (raw)
In-Reply-To: <20090902140612.943801000@intel.com>
Commit-ID: 747b50aaf728987732e6ff3ba10aba4acc4e0277
Gitweb: http://git.kernel.org/tip/747b50aaf728987732e6ff3ba10aba4acc4e0277
Author: markus.t.metzger@intel.com <markus.t.metzger@intel.com>
AuthorDate: Wed, 2 Sep 2009 16:04:46 +0200
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 4 Sep 2009 09:26:39 +0200
x86, perf_counter, bts: Fail if BTS is not available
Reserve PERF_COUNT_HW_BRANCH_INSTRUCTIONS with sample_period ==
1 for BTS tracing and fail, if BTS is not available.
Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20090902140612.943801000@intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86/kernel/cpu/perf_counter.c | 25 +++++++++++--------------
1 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/arch/x86/kernel/cpu/perf_counter.c b/arch/x86/kernel/cpu/perf_counter.c
index 396e35d..2f41874 100644
--- a/arch/x86/kernel/cpu/perf_counter.c
+++ b/arch/x86/kernel/cpu/perf_counter.c
@@ -769,7 +769,7 @@ static int reserve_bts_hardware(void)
int cpu, err = 0;
if (!bts_available())
- return -EOPNOTSUPP;
+ return 0;
get_online_cpus();
@@ -914,7 +914,7 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
if (!reserve_pmc_hardware())
err = -EBUSY;
else
- reserve_bts_hardware();
+ err = reserve_bts_hardware();
}
if (!err)
atomic_inc(&active_counters);
@@ -979,6 +979,13 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
if (config == -1LL)
return -EINVAL;
+ /*
+ * Branch tracing:
+ */
+ if ((attr->config == PERF_COUNT_HW_BRANCH_INSTRUCTIONS) &&
+ (hwc->sample_period == 1) && !bts_available())
+ return -EOPNOTSUPP;
+
hwc->config |= config;
return 0;
@@ -1355,19 +1362,9 @@ static int x86_pmu_enable(struct perf_counter *counter)
idx = fixed_mode_idx(counter, hwc);
if (idx == X86_PMC_IDX_FIXED_BTS) {
- /*
- * Try to use BTS for branch tracing. If that is not
- * available, try to get a generic counter.
- */
- if (unlikely(!cpuc->ds))
- goto try_generic;
-
- /*
- * Try to get the fixed counter, if that is already taken
- * then try to get a generic counter:
- */
+ /* BTS is already occupied. */
if (test_and_set_bit(idx, cpuc->used_mask))
- goto try_generic;
+ return -EAGAIN;
hwc->config_base = 0;
hwc->counter_base = 0;
next prev parent reply other threads:[~2009-09-04 7:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-02 14:04 [patch 0/3] x86, perf_counter, bts: incorporate review feedback and fix bugs markus.t.metzger
2009-09-02 14:04 ` [patch 1/3] x86, perf_counter, bts: fail if BTS is not available markus.t.metzger
2009-09-04 7:58 ` tip-bot for markus.t.metzger@intel.com [this message]
2009-09-02 14:04 ` [patch 2/3] x86, perf_counter, bts: correct pointer-to-u64 casts markus.t.metzger
2009-09-04 7:58 ` [tip:perfcounters/core] x86, perf_counter, bts: Correct " tip-bot for markus.t.metzger@intel.com
2009-09-02 14:04 ` [patch 3/3] x86, perf_counter, bts: do not allow kernel BTS tracing markus.t.metzger
2009-09-04 7:58 ` [tip:perfcounters/core] x86, perf_counter, bts: Do not allow kernel BTS tracing for now tip-bot for markus.t.metzger@intel.com
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-747b50aaf728987732e6ff3ba10aba4acc4e0277@git.kernel.org \
--to=markus.t.metzger@intel.com \
--cc=a.p.zijlstra@chello.nl \
--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=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
Powered by JetHome