From: Andi Kleen <ak@linux.intel.com>
To: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org,
Frederic Weisbecker <fweisbec@gmail.com>,
Mike Galbraith <efault@gmx.de>, Paul Mackerras <paulus@samba.org>,
Stephane Eranian <eranian@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Matt Fleming <matt.fleming@intel.com>
Subject: Re: [PATCH v1 07/11] x86: perf: intel_pt: Intel PT PMU driver
Date: Thu, 6 Feb 2014 12:29:59 -0800 [thread overview]
Message-ID: <20140206202959.GA12219@tassilo.jf.intel.com> (raw)
In-Reply-To: <1391683834-29868-8-git-send-email-alexander.shishkin@linux.intel.com>
> diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
> index 0fa4f24..28b5023 100644
> --- a/arch/x86/kernel/cpu/perf_event_intel.c
> +++ b/arch/x86/kernel/cpu/perf_event_intel.c
> @@ -1312,6 +1312,8 @@ int intel_pmu_save_and_restart(struct perf_event *event)
> return x86_perf_event_set_period(event);
> }
>
> +void intel_pt_interrupt(void);
Should be in $(pwd)/perf_event.h
> diff --git a/arch/x86/kernel/cpu/perf_event_intel_pt.c b/arch/x86/kernel/cpu/perf_event_intel_pt.c
> new file mode 100644
> index 0000000..b6b1a84
> --- /dev/null
> +++ b/arch/x86/kernel/cpu/perf_event_intel_pt.c
> @@ -0,0 +1,991 @@
> +/*
> + * Intel(R) Processor Trace PMU driver for perf
> + * Copyright (c) 2013-2014, Intel Corporation.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> + * more details.
> + *
> + * You should have received a copy of the GNU General Public License along with
> + * this program; if not, write to the Free Software Foundation, Inc.,
> + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
Remove the address, and add a pointer to the specification
Similar in the other files.
> +/*
> + * Capabilities of Intel PT hardware, such as number of address bits or
> + * supported output schemes, are cached and exported to userspace as "caps"
> + * attribute group of pt pmu device
> + * (/sys/bus/event_source/devices/intel_pt/caps/) so that userspace can store
> + * relevant bits together with intel_pt traces.
> + *
> + * Currently, for debugging purposes, these attributes are also writable; this
> + * should be removed in the final version.
Already remove that code?
> +{
> + u64 reg;
> +
> + reg = RTIT_CTL_TOPA | RTIT_CTL_BRANCH_EN;
> +
> + if (!event->attr.exclude_kernel)
> + reg |= RTIT_CTL_OS;
> + if (!event->attr.exclude_user)
> + reg |= RTIT_CTL_USR;
> +
> + reg |= (event->attr.itrace_config & PT_CONFIG_MASK);
> +
> + if (wrmsr_safe(MSR_IA32_RTIT_CTL, reg, 0) < 0) {
> + pr_warn("Failed to enable PT on cpu %d\n", event->cpu);
Should rate limit this warning
> + return -EINVAL;
> + }
> + return 0;
> +}
> +
> +static void pt_config_start(bool start)
> +{
> + u64 ctl;
> +
> + rdmsrl(MSR_IA32_RTIT_CTL, ctl);
Should bail out here if someone else already started (e.g. hardware debugger)
The read needs to be moved to before we overwrite other MSRs
> + if (start)
> + ctl |= RTIT_CTL_TRACEEN;
> + else
> + ctl &= ~RTIT_CTL_TRACEEN;
> + wrmsrl(MSR_IA32_RTIT_CTL, ctl);
> +
> +/**
> + * pt_handle_status - take care of possible status conditions
> + * @event: currently active PT event
> + */
> +static void pt_handle_status(struct perf_event *event)
> +{
> + struct pt_buffer *buf = itrace_priv(event);
> + int advance = 0;
> + u64 status;
> +
> + rdmsrl(MSR_IA32_RTIT_STATUS, status);
> +
> + if (status & RTIT_STATUS_ERROR) {
> + pr_err("ToPA ERROR encountered, trying to recover\n");
Add perf: prefix here (or better redefine pr_fmt at the beginning)
Should be rate limited
> +static struct pt_buffer *pt_buffer_alloc(int cpu, size_t size,
> + unsigned long watermark,
> + bool snapshot, gfp_t gfp,
> + void **pages)
> +{
> + struct pt_buffer *buf;
> + int node;
> + int ret;
> +
> + if (!size || watermark << PAGE_SHIFT > size)
> + return NULL;
> +
> + if (cpu == -1)
> + cpu = raw_smp_processor_id();
> + node = cpu_to_node(cpu);
> +
> + buf = kzalloc(sizeof(struct pt_buffer), gfp);
> + if (!buf)
> + return NULL;
Should be kzalloc_node()
-Andi
--
ak@linux.intel.com -- Speaking for myself only
next prev parent reply other threads:[~2014-02-06 20:30 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-06 10:50 [PATCH v1 00/11] perf: Add support for Intel Processor Trace Alexander Shishkin
2014-02-06 10:50 ` [PATCH v1 01/11] x86: Add Intel Processor Trace (INTEL_PT) cpu feature detection Alexander Shishkin
2014-02-06 10:50 ` [PATCH v1 02/11] perf: Abstract ring_buffer backing store operations Alexander Shishkin
2014-02-06 10:50 ` [PATCH v1 03/11] perf: Allow for multiple ring buffers per event Alexander Shishkin
2014-02-17 14:33 ` Peter Zijlstra
2014-02-18 2:36 ` Andi Kleen
2014-03-14 10:38 ` Peter Zijlstra
2014-03-14 14:10 ` Andi Kleen
2014-03-18 14:06 ` Alexander Shishkin
2014-02-19 22:02 ` Dave Hansen
2014-03-10 9:59 ` Alexander Shishkin
2014-03-10 17:24 ` Andi Kleen
2014-03-14 10:44 ` Peter Zijlstra
2014-03-14 14:13 ` Andi Kleen
2014-03-14 10:41 ` Peter Zijlstra
2014-05-07 15:26 ` Peter Zijlstra
2014-05-07 19:25 ` Ingo Molnar
2014-05-07 21:08 ` Andi Kleen
2014-05-07 21:22 ` Peter Zijlstra
2014-05-08 3:26 ` Alexander Shishkin
2014-05-08 4:05 ` Alexander Shishkin
2014-05-08 9:08 ` Alexander Shishkin
2014-05-08 12:34 ` Alexander Shishkin
2014-05-08 12:41 ` Peter Zijlstra
2014-05-08 12:46 ` Alexander Shishkin
2014-05-08 14:16 ` Peter Zijlstra
2014-02-06 10:50 ` [PATCH v1 04/11] itrace: Infrastructure for instruction flow tracing units Alexander Shishkin
2014-02-06 10:50 ` [PATCH v1 05/11] itrace: Add functionality to include traces in perf event samples Alexander Shishkin
2014-02-06 10:50 ` [PATCH v1 06/11] itrace: Add functionality to include traces in process core dumps Alexander Shishkin
2014-02-06 10:50 ` [PATCH v1 07/11] x86: perf: intel_pt: Intel PT PMU driver Alexander Shishkin
2014-02-06 20:29 ` Andi Kleen [this message]
2014-02-17 14:44 ` Peter Zijlstra
2014-02-17 16:07 ` Andi Kleen
2014-02-17 14:46 ` Peter Zijlstra
2014-02-18 12:42 ` Alexander Shishkin
2014-02-06 10:50 ` [PATCH v1 08/11] x86: perf: intel_pt: Add sampling functionality Alexander Shishkin
2014-02-06 10:50 ` [PATCH v1 09/11] x86: perf: intel_pt: Add core dump functionality Alexander Shishkin
2014-02-06 20:36 ` Andi Kleen
2014-02-07 9:03 ` Alexander Shishkin
2014-02-06 23:59 ` Andi Kleen
2014-02-07 9:09 ` Alexander Shishkin
2014-02-06 10:50 ` [PATCH v1 10/11] x86: perf: intel_bts: Add BTS PMU driver Alexander Shishkin
2014-02-06 10:50 ` [PATCH v1 11/11] x86: perf: intel_bts: Add core dump related functionality Alexander Shishkin
2014-02-06 23:57 ` Andi Kleen
2014-02-07 9:02 ` Alexander Shishkin
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=20140206202959.GA12219@tassilo.jf.intel.com \
--to=ak@linux.intel.com \
--cc=a.p.zijlstra@chello.nl \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=efault@gmx.de \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.fleming@intel.com \
--cc=mingo@redhat.com \
--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