From: Oleg Nesterov <oleg@redhat.com>
To: Jacob Shin <jacob.shin@amd.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, Will Deacon <will.deacon@arm.com>
Subject: Re: [PATCH 1/3] perf/x86/amd: AMD support for bp_len > HW_BREAKPOINT_LEN_8
Date: Sat, 27 Apr 2013 18:10:28 +0200 [thread overview]
Message-ID: <20130427161028.GA27310@redhat.com> (raw)
In-Reply-To: <20130427154026.GA3529@jshin-Toonie>
On 04/27, Jacob Shin wrote:
>
> On Sat, Apr 27, 2013 at 05:05:10PM +0200, Oleg Nesterov wrote:
> > ...
> > > + if (info->mask)
> > > + set_dr_addr_mask(0, i);
> >
> > I agree we should clear addr_mask anyway.
> >
> > But I am just curious, what if we do not? I mean what will the hardware
> > do if this breakpoint was already disabled but the mask wasn't cleared?
>
> Oh, it is fine if we don't and we are not using breakpoints, however I
> was trying to account for per-thread events sharing the same DR
> register, in that case we don't want previous event's mask value still
> in the MSR.
Aha, so CPU "remembers" the non-cleared mask and this can affect the
next "enable". Thanks.
> > Suppose that the kernel was compiled without CONFIG_CPU_SUP_AMD.
> > Then perf_event_open(attr => { .bp_len == 16 }) will succeed, but
> > this breakpoint won't actually work as expected?
>
> Well, on non-AMD, even if we have CONFIG_CPU_SUP_AMD=y or not,
> cpu_has_bpext (x86 CPUID check) will fail.
>
> On AMD, if we don't have CONFIG_CPU_SUP_AMD=y then we can't even boot.
Heh, I didn't know ;)
OK, I think the patch is fine then.
Except... cough, the last nit, I promise ;)
Currently this doesn't matter, the only caller of modify_user_hw_breakpoint()
is ptrace, and it can't use bp_len != HW_BREAKPOINT_LEN_*.
But still, I think your patch needs a small fixlet,
- /* info->len == info->mask == 0 */
+ info->mask = 0;
Or we can do this later.
And while this is purely cosmetic (feel free to ignore), perhaps we
can join the bp_len checks and move cpu_has_bpext from _validate to
_build, this looks a little bit cleaner imho. IOW,
info->mask == 0;
switch (bp->attr.bp_len) {
default:
if (!is_power_of_2(bp->attr.bp_len))
return -EINVAL;
if (!cpu_has_bpext)
return -EOPNOTSUPP;
info->mask = bp->attr.bp_len - 1;
/* fallthrough */
case HW_BREAKPOINT_LEN_1:
info->len = X86_BREAKPOINT_LEN_1;
break;
case HW_BREAKPOINT_LEN_2:
info->len = X86_BREAKPOINT_LEN_2;
break;
case HW_BREAKPOINT_LEN_4:
info->len = X86_BREAKPOINT_LEN_4;
break;
#ifdef CONFIG_X86_64
case HW_BREAKPOINT_LEN_8:
info->len = X86_BREAKPOINT_LEN_8;
break;
#endif
}
Then arch_validate_hwbkpt_settings() only needs
case X86_BREAKPOINT_LEN_1:
align = 0;
+ if (info->mask)
+ align = mask;
change.
Oleg.
next prev parent reply other threads:[~2013-04-27 16:13 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-26 18:57 [PATCH 0/3] perf/x86/amd: AMD Family 16h Data Breakpoint Extensions Jacob Shin
2013-04-26 18:57 ` [PATCH 1/3] perf/x86/amd: AMD support for bp_len > HW_BREAKPOINT_LEN_8 Jacob Shin
2013-04-27 15:05 ` Oleg Nesterov
2013-04-27 15:14 ` Oleg Nesterov
2013-04-27 15:40 ` Jacob Shin
2013-04-27 16:10 ` Oleg Nesterov [this message]
2013-04-28 6:05 ` Jacob Shin
2013-04-26 18:57 ` [PATCH 2/3] perf tools: allow user to specify hardware breakpoint bp_len Jacob Shin
2013-04-27 16:58 ` Oleg Nesterov
2013-04-27 17:34 ` Oleg Nesterov
2013-04-28 5:44 ` Jacob Shin
2013-04-28 5:50 ` H. Peter Anvin
2013-04-28 16:12 ` Oleg Nesterov
2013-04-26 18:57 ` [PATCH 3/3] perf tools: add hardware breakpoint bp_len test cases Jacob Shin
-- strict thread matches above, loose matches on Subject: below --
2013-04-28 6:05 [PATCH V4 0/3] perf/x86/amd: AMD Family 16h Data Breakpoint Extensions Jacob Shin
2013-04-28 6:05 ` [PATCH 1/3] perf/x86/amd: AMD support for bp_len > HW_BREAKPOINT_LEN_8 Jacob Shin
2013-10-02 16:11 [PATCH V5 0/3] perf/x86/amd: AMD Family 16h Data Breakpoint Extensions suravee.suthikulpanit
2013-10-02 16:11 ` [PATCH 1/3] perf/x86/amd: AMD support for bp_len > HW_BREAKPOINT_LEN_8 suravee.suthikulpanit
2013-10-31 9:58 ` Frederic Weisbecker
2013-10-31 10:48 ` Borislav Petkov
2013-10-31 11:23 ` Frederic Weisbecker
2013-11-02 4:34 ` Borislav Petkov
2013-11-08 21:22 ` Suravee Suthikulpanit
2013-11-08 14:40 ` Borislav Petkov
2013-10-31 16:49 ` Oleg Nesterov
2013-11-08 19:41 ` Frederic Weisbecker
2013-11-09 15:11 ` Oleg Nesterov
2013-11-09 15:32 ` Frederic Weisbecker
2013-11-09 15:54 ` Oleg Nesterov
2013-11-11 15:44 ` Frederic Weisbecker
2013-11-11 17:51 ` Oleg Nesterov
2013-12-02 23:12 ` Frederic Weisbecker
2013-12-04 13:57 ` Oleg Nesterov
2013-12-10 14:43 ` Frederic Weisbecker
2013-12-10 14:52 ` Frederic Weisbecker
2013-12-10 15:23 ` Frederic Weisbecker
2013-12-10 16:19 ` Oleg Nesterov
2013-12-10 16:30 ` Frederic Weisbecker
2013-12-11 12:05 ` Suravee Suthikulanit
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=20130427161028.GA27310@redhat.com \
--to=oleg@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=jacob.shin@amd.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=will.deacon@arm.com \
--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;
as well as URLs for NNTP newsgroup(s).