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: Thu, 9 Nov 2017 08:52:41 +0100 [thread overview]
Message-ID: <20171109074658.GC14419@krava> (raw)
In-Reply-To: <CAMmz+Y=eq=S+gZaRefVUrfB7LDRVfD5UdpkfQXS0zvnHdNt0XA@mail.gmail.com>
On Wed, Nov 08, 2017 at 08:59:22AM -0800, Milind Chabbi wrote:
> On Wed, Nov 8, 2017 at 7:57 AM, Jiri Olsa <jolsa@redhat.com> wrote:
> > On Wed, Nov 08, 2017 at 07:51:10AM -0800, Milind Chabbi wrote:
> >> On Wed, Nov 8, 2017 at 7:12 AM, Jiri Olsa <jolsa@redhat.com> wrote:
> >>
> >> > > I am not able to fully understand your concern.
> >> > > Can you point to a code file and line related to your observation?
> >> > > The patch is modeled after the existing modify_user_hw_breakpoint() function
> >> > > present in events/hw_breakpoint.c; don't you see this problem in that code?
> >> >
> >> > the reserve_bp_slot/release_bp_slot functions manage
> >> > counts for current breakpoints based on its type
> >> >
> >> > those counts are cumulated in here:
> >> > static DEFINE_PER_CPU(struct bp_cpuinfo, bp_cpuinfo[TYPE_MAX]);
> >> >
> >> > you allow to change the breakpoint type, so I'd expect
> >> > to see some code that release slot count for old type
> >> > and take new one (if it's available)
> >> >
> >> > jirka
> >>
> >>
> >> Why is this not a concern for modify_user_hw_breakpoint() function?
> >
> > I don't know ;-)
> >
> > jirka
>
>
> Jirka,
>
> I carefully looked at bp_cpuinfo[] and nr_slots[] data structures.
> nr_slots[] is an array of length two (one slot of TYPE_INST and
> another for TYPE_DATA).
> The accounting "thinks" that there is one limit on the number of
> instruction breakpoints and another limit on the number of data
> breakpoints.
> The assumption is clearly broken; for example, on x86 there exists a
> limit on the *total* number of all breakpoints disregarding their kind
> and the code has failed to capture this aspect.
there's the CONFIG_HAVE_MIXED_BREAKPOINTS_REGS that puts DATA and INST
under one count on x86.. but that seems to be the enabled only for:
arch/sh/Kconfig: select HAVE_MIXED_BREAKPOINTS_REGS
arch/x86/Kconfig: select HAVE_MIXED_BREAKPOINTS_REGS
>
> As such, modify_user_hw_breakpoint() makes no attempt to keep the
> counts correct. Instead, it simply tries to change and install a new
> breakpoint and fails if the hardware disallows.
> This can lead to a situation where, say on x86, someone creates 4
> TYPE_DATA breakpoints, then changes one of them to TYPE_INS via
> modify_user_hw_breakpoint() and then releases the TYPE_INS breakpoint.
> Since the accounting still thinks that there are four TYPE_DATA
> breakpoints, it will disallow creating a new TYPE_DATA breakpoint,
> although there is place for one TYPE_DATA breakpoint.
>
> This convinces me that the problem and the solution are outside of
> this current patch.
> Do you agree?
I'll leave this decision to maintainer ;-) but seems better to fix
the interface before we add any new dependent function calls
jirka
next prev parent reply other threads:[~2017-11-09 7:52 UTC|newest]
Thread overview: 30+ 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
2017-11-08 15:12 ` Jiri Olsa
2017-11-08 15:51 ` Milind Chabbi
2017-11-08 15:57 ` Jiri Olsa
2017-11-08 16:59 ` Milind Chabbi
2017-11-09 7:52 ` Jiri Olsa [this message]
2017-11-09 13:12 ` Jiri Olsa
2017-11-09 18:59 ` Milind Chabbi
2017-11-12 19:09 ` Milind Chabbi
2017-11-13 7:46 ` Jiri Olsa
2017-11-13 8:02 ` Milind Chabbi
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=20171109074658.GC14419@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=chabbi.milind@gmail.com \
--cc=hbathini@linux.vnet.ibm.com \
--cc=kan.liang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-man@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=mtk.manpages@gmail.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=sukadev@linux.vnet.ibm.com \
--cc=yao.jin@linux.intel.com \
/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