From: Jacob Shin <jacob.shin@amd.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
"H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>, <x86@kernel.org>,
Stephane Eranian <eranian@google.com>,
Jiri Olsa <jolsa@redhat.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V2 1/4] perf: Add hardware breakpoint address mask
Date: Tue, 23 Apr 2013 09:25:46 -0500 [thread overview]
Message-ID: <20130423142546.GA17021@jshin-Toonie> (raw)
In-Reply-To: <20130423131844.GA24467@redhat.com>
On Tue, Apr 23, 2013 at 03:18:44PM +0200, Oleg Nesterov wrote:
> On 04/23, Jacob Shin wrote:
> >
> > +__weak int arch_validate_hwbkpt_addr_mask(struct perf_event *bp)
> > +{
> > + return bp->attr.bp_addr_mask == 0;
> > +}
> > +
> > static int validate_hw_breakpoint(struct perf_event *bp)
> > {
> > int ret;
> > @@ -393,6 +398,10 @@ static int validate_hw_breakpoint(struct perf_event *bp)
> > if (ret)
> > return ret;
> >
> > + ret = arch_validate_hwbkpt_addr_mask(bp);
> > + if (ret)
> > + return ret;
>
> Well, this looks obviously wrong?
>
> arch_validate_hwbkpt_addr_mask() fails if bp_addr_mask == 0? and returns
> "1" as the error code.
>
> Either it should returns something like "bp_addr_mask ? -ENOTSUPP : 0"
> or the caller should do "if (!validate_hw_breakpoint()) return -ERR".
You are absolutely right. I have mixed up "does this arch support address
masks?" vs "is this a valid address mask?" So sorry about that.
Here is the corrected patch:
>From f2054e8af979f024aa2da93f80646db18492479e Mon Sep 17 00:00:00 2001
From: Jacob Shin <jacob.shin@amd.com>
Date: Mon, 22 Apr 2013 17:02:37 -0500
Subject: [PATCH 1/4] perf: Add hardware breakpoint address mask
Some architectures (for us, AMD Family 16h) allow for "don't care" bit
mask to further qualify a hardware breakpoint address, in order to
trap on range of addresses. Update perf uapi to add bp_addr_mask field.
Signed-off-by: Jacob Shin <jacob.shin@amd.com>
---
include/uapi/linux/perf_event.h | 5 ++++-
kernel/events/hw_breakpoint.c | 9 +++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index fb104e5..e22e1d1 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -286,7 +286,10 @@ struct perf_event_attr {
__u64 config1; /* extension of config */
};
union {
- __u64 bp_len;
+ struct {
+ __u32 bp_len;
+ __u32 bp_addr_mask;
+ };
__u64 config2; /* extension of config1 */
};
__u64 branch_sample_type; /* enum perf_branch_sample_type */
diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
index a64f8ae..dde8273 100644
--- a/kernel/events/hw_breakpoint.c
+++ b/kernel/events/hw_breakpoint.c
@@ -385,6 +385,11 @@ int dbg_release_bp_slot(struct perf_event *bp)
return 0;
}
+__weak int arch_validate_hwbkpt_addr_mask(struct perf_event *bp)
+{
+ return bp->attr.bp_addr_mask ? -EOPNOTSUPP : 0;
+}
+
static int validate_hw_breakpoint(struct perf_event *bp)
{
int ret;
@@ -393,6 +398,10 @@ static int validate_hw_breakpoint(struct perf_event *bp)
if (ret)
return ret;
+ ret = arch_validate_hwbkpt_addr_mask(bp);
+ if (ret)
+ return ret;
+
if (arch_check_bp_in_kernelspace(bp)) {
if (bp->attr.exclude_kernel)
return -EINVAL;
--
1.7.9.5
next prev parent reply other threads:[~2013-04-23 14:25 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-23 7:57 [PATCH V2 0/4] perf: Add support for hardware breakpoint address masks Jacob Shin
2013-04-23 7:57 ` [PATCH V2 1/4] perf: Add hardware breakpoint address mask Jacob Shin
2013-04-23 9:54 ` Will Deacon
2013-04-23 14:34 ` Jacob Shin
2013-04-23 14:40 ` Jacob Shin
2013-04-23 15:02 ` Will Deacon
2013-04-23 15:18 ` Jacob Shin
2013-04-24 9:48 ` Will Deacon
2013-04-24 16:30 ` Jacob Shin
2013-04-25 17:06 ` Oleg Nesterov
2013-04-25 17:17 ` H. Peter Anvin
2013-04-25 23:19 ` Jacob Shin
2013-04-26 16:20 ` Will Deacon
2013-04-26 16:31 ` Jacob Shin
2013-04-26 16:47 ` Oleg Nesterov
2013-04-23 13:18 ` Oleg Nesterov
2013-04-23 14:25 ` Jacob Shin [this message]
2013-04-24 23:08 ` Frederic Weisbecker
2013-04-25 15:10 ` Oleg Nesterov
2013-04-25 15:57 ` Oleg Nesterov
2013-04-25 16:59 ` Jacob Shin
2013-04-25 17:33 ` Oleg Nesterov
2013-04-23 7:57 ` [PATCH V2 2/4] perf/x86/amd: AMD implementation for " Jacob Shin
2013-04-23 13:22 ` Oleg Nesterov
2013-04-23 7:57 ` [PATCH V2 3/4] perf tools: Add hardware breakpoint address mask event parser Jacob Shin
2013-04-23 7:57 ` [PATCH V2 4/4] perf tools: Add hardware breakpoint address mask test cases Jacob Shin
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=20130423142546.GA17021@jshin-Toonie \
--to=jacob.shin@amd.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=tglx@linutronix.de \
--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
all inboxes | Powered by JetHome®