From: Jiri Olsa <jolsa-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Milind Chabbi <chabbi.milind-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Peter Zijlstra <peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
Ingo Molnar <mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Arnaldo Carvalho de Melo
<acme-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Alexander Shishkin
<alexander.shishkin-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
Namhyung Kim <namhyung-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Michael Kerrisk-manpages
<mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>,
Andi Kleen <ak-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
Kan Liang <kan.liang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Hari Bathini
<hbathini-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>,
Sukadev Bhattiprolu
<sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>,
Jin Yao <yao.jin-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Subject: Re: [PATCH] perf/core: fast breakpoint modification via _IOC_MODIFY_BREAKPOINT
Date: Mon, 13 Nov 2017 08:46:44 +0100 [thread overview]
Message-ID: <20171113074644.GA18733@krava> (raw)
In-Reply-To: <CAMmz+YmhGXPQ_KydpPTLbPDQW-6G_wxrnAz2UYqSwqQJHBN_5Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Sun, Nov 12, 2017 at 11:09:23AM -0800, Milind Chabbi wrote:
> ,
>
> On Thu, Nov 9, 2017 at 10:59 AM, Milind Chabbi <chabbi.milind-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > SNIP
> >
> > On Thu, Nov 9, 2017 at 5:12 AM, Jiri Olsa <jolsa-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> >>
> >>
> >> how about something like below (untested)
> >>
> >> looks like there's no irq caller for modify_user_hw_breakpoint,
> >> so we should be fine with locking nr_bp_mutex
> >>
> >> jirka
> >>
> >>
> >> ---
> >> diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
> >> index 3f8cb1e14588..f062b68399ea 100644
> >> --- a/kernel/events/hw_breakpoint.c
> >> +++ b/kernel/events/hw_breakpoint.c
> >> @@ -448,6 +448,8 @@ int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *att
> >> else
> >> perf_event_disable(bp);
> >>
> >> + release_bp_slot(bp);
> >> +
> >> bp->attr.bp_addr = attr->bp_addr;
> >> bp->attr.bp_type = attr->bp_type;
> >> bp->attr.bp_len = attr->bp_len;
> >> @@ -455,9 +457,9 @@ int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *att
> >> if (attr->disabled)
> >> goto end;
> >>
> >> - err = validate_hw_breakpoint(bp);
> >> + err = reserve_bp_slot(bp);
> >> if (!err)
> >> - perf_event_enable(bp);
> >> + err = validate_hw_breakpoint(bp);
> >>
> >> if (err) {
> >> bp->attr.bp_addr = old_addr;
> >> @@ -469,6 +471,7 @@ int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *att
> >> return err;
> >> }
> >>
> >> + perf_event_enable(bp);
> >> end:
> >> bp->attr.disabled = attr->disabled;
> >>
> >
> > We can do this accounting only if bp->attr.bp_type != attr->bp_type.
> >
> > -Milind
>
>
> Jirka,
>
> Neither of us seems to fully understand the convoluted logic used in
> breakpoint counting.
yea, I was hoping some of the guys would take over ;-)
the problem I have with the patch above is that we could
fail to reserve the slot at the end, which is not what
the caller might expect
>
> I tested the following sequence on an x86 machine, which has four
> debug registers (without your suggested patch for counting
> correction).
>
> fd1 = perf_event_open(...); //BP_TYPE= HW_BREAKPOINT_RW @ ADDR1
> fd2 = perf_event_open(...); //BP_TYPE= HW_BREAKPOINT_RW @ ADDR2
> fd3 = perf_event_open(...); //BP_TYPE= HW_BREAKPOINT_RW @ ADDR3
> fd4 = perf_event_open(...); //BP_TYPE= HW_BREAKPOINT_RW @ ADDR4
> ioctl(fd4, MODIFY, ...); // change fd4 to BP_TYPE= HW_BREAKPOINT_X @ ADDR5
> close(fd4);
> fd5 = perf_event_open(); //BP_TYPE=RW @ ADDR6
>
> We expected fd5 to fail because four BP_TYPE=TYPE_DATA are in use as
> per the accounting, but in reality, fd5 was successfully opened.
but you closed fd4 before openning fd5..?
>
> Is the accounting accidentally working on x86?
> Is there another architecture where TYPE_DATA and TYPE_INS are counted
> differently?
[jolsa@krava linux-perf]$ grep -r HAVE_MIXED_BREAKPOINTS_REGS arch/*
arch/Kconfig:config HAVE_MIXED_BREAKPOINTS_REGS
arch/sh/Kconfig: select HAVE_MIXED_BREAKPOINTS_REGS
arch/x86/Kconfig: select HAVE_MIXED_BREAKPOINTS_REGS
I'll try to check on it this week
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Jiri Olsa <jolsa@redhat.com>
To: Milind Chabbi <chabbi.milind@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Namhyung Kim <namhyung@kernel.org>,
linux-kernel@vger.kernel.org,
Michael Kerrisk-manpages <mtk.manpages@gmail.com>,
linux-man@vger.kernel.org, Michael Ellerman <mpe@ellerman.id.au>,
Andi Kleen <ak@linux.intel.com>, Kan Liang <kan.liang@intel.com>,
Hari Bathini <hbathini@linux.vnet.ibm.com>,
Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>,
Jin Yao <yao.jin@linux.intel.com>
Subject: Re: [PATCH] perf/core: fast breakpoint modification via _IOC_MODIFY_BREAKPOINT
Date: Mon, 13 Nov 2017 08:46:44 +0100 [thread overview]
Message-ID: <20171113074644.GA18733@krava> (raw)
In-Reply-To: <CAMmz+YmhGXPQ_KydpPTLbPDQW-6G_wxrnAz2UYqSwqQJHBN_5Q@mail.gmail.com>
On Sun, Nov 12, 2017 at 11:09:23AM -0800, Milind Chabbi wrote:
> ,
>
> On Thu, Nov 9, 2017 at 10:59 AM, Milind Chabbi <chabbi.milind@gmail.com> wrote:
> > SNIP
> >
> > On Thu, Nov 9, 2017 at 5:12 AM, Jiri Olsa <jolsa@redhat.com> wrote:
> >>
> >>
> >> how about something like below (untested)
> >>
> >> looks like there's no irq caller for modify_user_hw_breakpoint,
> >> so we should be fine with locking nr_bp_mutex
> >>
> >> jirka
> >>
> >>
> >> ---
> >> diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
> >> index 3f8cb1e14588..f062b68399ea 100644
> >> --- a/kernel/events/hw_breakpoint.c
> >> +++ b/kernel/events/hw_breakpoint.c
> >> @@ -448,6 +448,8 @@ int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *att
> >> else
> >> perf_event_disable(bp);
> >>
> >> + release_bp_slot(bp);
> >> +
> >> bp->attr.bp_addr = attr->bp_addr;
> >> bp->attr.bp_type = attr->bp_type;
> >> bp->attr.bp_len = attr->bp_len;
> >> @@ -455,9 +457,9 @@ int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *att
> >> if (attr->disabled)
> >> goto end;
> >>
> >> - err = validate_hw_breakpoint(bp);
> >> + err = reserve_bp_slot(bp);
> >> if (!err)
> >> - perf_event_enable(bp);
> >> + err = validate_hw_breakpoint(bp);
> >>
> >> if (err) {
> >> bp->attr.bp_addr = old_addr;
> >> @@ -469,6 +471,7 @@ int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *att
> >> return err;
> >> }
> >>
> >> + perf_event_enable(bp);
> >> end:
> >> bp->attr.disabled = attr->disabled;
> >>
> >
> > We can do this accounting only if bp->attr.bp_type != attr->bp_type.
> >
> > -Milind
>
>
> Jirka,
>
> Neither of us seems to fully understand the convoluted logic used in
> breakpoint counting.
yea, I was hoping some of the guys would take over ;-)
the problem I have with the patch above is that we could
fail to reserve the slot at the end, which is not what
the caller might expect
>
> I tested the following sequence on an x86 machine, which has four
> debug registers (without your suggested patch for counting
> correction).
>
> fd1 = perf_event_open(...); //BP_TYPE= HW_BREAKPOINT_RW @ ADDR1
> fd2 = perf_event_open(...); //BP_TYPE= HW_BREAKPOINT_RW @ ADDR2
> fd3 = perf_event_open(...); //BP_TYPE= HW_BREAKPOINT_RW @ ADDR3
> fd4 = perf_event_open(...); //BP_TYPE= HW_BREAKPOINT_RW @ ADDR4
> ioctl(fd4, MODIFY, ...); // change fd4 to BP_TYPE= HW_BREAKPOINT_X @ ADDR5
> close(fd4);
> fd5 = perf_event_open(); //BP_TYPE=RW @ ADDR6
>
> We expected fd5 to fail because four BP_TYPE=TYPE_DATA are in use as
> per the accounting, but in reality, fd5 was successfully opened.
but you closed fd4 before openning fd5..?
>
> Is the accounting accidentally working on x86?
> Is there another architecture where TYPE_DATA and TYPE_INS are counted
> differently?
[jolsa@krava linux-perf]$ grep -r HAVE_MIXED_BREAKPOINTS_REGS arch/*
arch/Kconfig:config HAVE_MIXED_BREAKPOINTS_REGS
arch/sh/Kconfig: select HAVE_MIXED_BREAKPOINTS_REGS
arch/x86/Kconfig: select HAVE_MIXED_BREAKPOINTS_REGS
I'll try to check on it this week
jirka
next prev parent reply other threads:[~2017-11-13 7:46 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAMmz+Y=Py0dw63tuww+Oa4rWi_Hghhs3DHmNX=Tf1Yt_JH4O+Q@mail.gmail.com>
2017-11-06 9:23 ` [PATCH] perf/core: fast breakpoint modification via _IOC_MODIFY_BREAKPOINT Jiri Olsa
[not found] ` <CAMmz+YkB955Na6wOMmgqZX_TxqsBh86FiLi8EXmOrg1vwm-fGA@mail.gmail.com>
2017-11-08 14:15 ` Jiri Olsa
2017-11-08 15:02 ` Milind Chabbi
[not found] ` <CAMmz+Ym4yyAAYw02EtxSG7Duv_Pkg3Z+cYrgmW5Esm8Mgdx4-w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-08 15:12 ` Jiri Olsa
2017-11-08 15:12 ` Jiri Olsa
2017-11-08 15:51 ` Milind Chabbi
[not found] ` <CAMmz+Y=PJ2kFf9mqoQDJY32VjpCQBCCuWOiHNXR3mSEzotSS_w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-08 15:57 ` Jiri Olsa
2017-11-08 15:57 ` Jiri Olsa
2017-11-08 16:59 ` Milind Chabbi
2017-11-08 16:59 ` Milind Chabbi
[not found] ` <CAMmz+Y=eq=S+gZaRefVUrfB7LDRVfD5UdpkfQXS0zvnHdNt0XA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-09 7:52 ` Jiri Olsa
2017-11-09 7:52 ` Jiri Olsa
2017-11-09 13:12 ` Jiri Olsa
2017-11-09 13:12 ` Jiri Olsa
2017-11-09 18:59 ` Milind Chabbi
2017-11-09 18:59 ` Milind Chabbi
[not found] ` <CAMmz+Ykdf+bpA=ARSAYd3xp7U+BDWVmf1iW3SKW=ZVDBSmUSEg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-12 19:09 ` Milind Chabbi
2017-11-12 19:09 ` Milind Chabbi
[not found] ` <CAMmz+YmhGXPQ_KydpPTLbPDQW-6G_wxrnAz2UYqSwqQJHBN_5Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-13 7:46 ` Jiri Olsa [this message]
2017-11-13 7:46 ` Jiri Olsa
2017-11-13 8:02 ` Milind Chabbi
[not found] ` <CAMmz+Y=95ffwgSbLSXoAPOrdQXVQftZNJFjoH=kjpGkZ2u2LYw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-26 19:31 ` Jiri Olsa
2017-11-26 19:31 ` Jiri Olsa
2017-11-27 6:43 ` [PATCH] perf/core: Enable the bp only if the .disable field is 0 Milind Chabbi
2017-11-27 6:50 ` Milind Chabbi
2017-11-27 9:25 ` Jiri Olsa
[not found] <CAMmz+YnaoN3-7DN5WysQvhWNyGhM7_WDz5AQAnvP6FO_GMnMgw@mail.gmail.com>
2017-11-06 15:03 ` [PATCH] perf/core: fast breakpoint modification via _IOC_MODIFY_BREAKPOINT Arnaldo Carvalho de Melo
2017-11-06 22:09 Milind Chabbi
2017-11-06 23:16 ` Andi Kleen
2017-11-07 8:15 ` Peter Zijlstra
2017-11-07 17:09 ` Andi Kleen
2017-11-07 8:14 ` Peter Zijlstra
2017-11-07 15:43 ` Milind Chabbi
2017-11-07 17:24 ` Andi Kleen
2017-11-07 17:42 ` Milind Chabbi
2017-11-07 19:01 ` Peter Zijlstra
2017-11-07 19:31 ` Milind Chabbi
2017-11-08 13:35 ` kbuild test robot
2017-11-08 13:51 ` kbuild test robot
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=20171113074644.GA18733@krava \
--to=jolsa-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=acme-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=ak-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=alexander.shishkin-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=chabbi.milind-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=hbathini-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
--cc=kan.liang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org \
--cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=namhyung-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
--cc=yao.jin-VuQAYsv1563Yd54FQh9/CA@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.