All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: "K.Prasad" <prasad@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Jan Kiszka <jan.kiszka@web.de>, Jiri Slaby <jirislaby@gmail.com>,
	Li Zefan <lizf@cn.fujitsu.com>, Avi Kivity <avi@redhat.com>,
	Paul Mackerras <paulus@samba.org>, Mike Galbraith <efault@gmx.de>,
	Masami Hiramatsu <mhiramat@redhat.com>,
	Paul Mundt <lethal@linux-sh.org>
Subject: Re: [PATCH 4/6] hw-breakpoints: Rewrite the hw-breakpoints layer on top of perf events
Date: Thu, 12 Nov 2009 16:42:22 +0100	[thread overview]
Message-ID: <20091112154221.GD5237@nowhere> (raw)
In-Reply-To: <20091108173205.GC4465@in.ibm.com>

On Sun, Nov 08, 2009 at 11:02:05PM +0530, K.Prasad wrote:
> On Thu, Nov 05, 2009 at 10:06:55PM +0100, Frederic Weisbecker wrote:
> > > Can't it be cpumask_t instead of int cpu? Given that per-cpu breakpoints
> > > will be implemented, it should be very different to implement them for a
> > > subset of cpus too.
> > 
> > I can't figure out any usecase where we want to only bind to,
> > say, cpu 1 and 3 or any kind of such strange combination.
> > 
> > Either we want a wide breakpoint, or we want to profile
> > a single cpu, but I don't imagine we need a middle case.
>  
> When we originally had this discussion on LKML, one of the use-cases
> cited was http://lkml.org/lkml/2009/7/29/243. I can't see why such
> need should be restricted to a given CPU only, rather than a subset of
> CPUs (say 'x' is a variable normally read/written-to in the interrupt
> path, and if the said interrupt is has a cpu affinity to a subset of
> cpus only).
>
> Although in the normal case, this feature could be implemented later, in
> case of breakpoints we accept that as input from the user (and hence
> part of the well-defined interface), so it is better to design it for
> a subset of CPUs from start. The logic isn't very different and given that
> there are plenty of helper routines in cpumask.h the implementation is easy too.


Well, if one day someone wants to profile a subset of cpus and then need
this feature, I'll implement it. But I don't think we should anticipate
every possible corner usecases for now.

It's not possible to request that from any user interface anyway
(either ptrace, perf or ftrace). And if it becomes needed for in-kernel
use, then it's trivial to change.

 
> > If we want to lock such path, we probably more likely want a mutex.
> > Registering a breakpoint is not a fastpath and also perf does
> > some sleepable things while creating a counter.
> > 
> > The check to register constraints, which is part of this path,
> > is itself a mutex.
> > 
> > But we'll probably need something NMI safe in the future so
> > that it can be used without any problem by kgdb.
> > 
> 
> I suspect that it will be required for cpu-hotplug handler, where
> previously load_debug_registers() was called from a softirq context.


Nop. There is no register/unregister on cpu hotplug time.
Perf will just reschedule the events on that cpu (through
pmu::enable/disable calls).


 
> > > I'm assuming that there'd be an implementation for system-wide
> > > perf-events (and hence breakpoints) in the forthcoming version(s) of
> > > this patchset.
> > 
> > 
> > If that becomes a necessary feature, then yeah.
> > 
> > 
> 
> Apart from the several benefits of having system-wide perf-events,
> implementing them in the first iteration itself will
> help us fully realise the cost of perf-events + hw-breakpoint
> integration! When implemented, perf-events will also be ready to
> accomodate future users (apart from bp and perf-top) having a
> need for system-wide counter.


For now this is meant to be costly (wrt cross cpu contention)
as I explained you before.

But if the ftrace ring buffer becomes integrated by perf (which
seem to be in the plans), then yeah this may become a very useful
feature because we could use a single counter for wide profiling
without the cost of the cpu contention (ftrace ring buffer is
per cpu and fully lockless).

Thanks.


  reply	other threads:[~2009-11-12 15:42 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-03 19:11 [GIT PULL v4] hw-breakpoints: Rewrite on top of perf events v4 Frederic Weisbecker
2009-11-03 19:11 ` [PATCH 1/6] perf/core: Provide a kernel-internal interface to get to performance counters Frederic Weisbecker
2009-11-03 19:11 ` [PATCH 2/6] x86/hw-breakpoints: Actually flush thread breakpoints in flush_thread() Frederic Weisbecker
2009-11-03 19:11 ` [PATCH 3/6] perf/core: Add a callback to perf events Frederic Weisbecker
2009-11-03 19:11 ` [PATCH 4/6] hw-breakpoints: Rewrite the hw-breakpoints layer on top of " Frederic Weisbecker
2009-11-03 19:58   ` Jan Kiszka
2009-11-03 20:15     ` Frederic Weisbecker
2009-11-03 20:22       ` Jan Kiszka
2009-11-03 20:29         ` Frederic Weisbecker
2009-11-03 20:39           ` Jan Kiszka
2009-11-03 20:45             ` Frederic Weisbecker
2009-11-04 23:59   ` Paul Mackerras
2009-11-05  6:00     ` K.Prasad
2009-11-05 11:00       ` Paul Mackerras
2009-11-05 11:09     ` Frederic Weisbecker
2009-11-07 10:03       ` Paul Mackerras
2009-11-07 19:52         ` Frederic Weisbecker
2009-11-05 11:03   ` Paul Mackerras
2009-11-05 11:11     ` Frederic Weisbecker
2009-11-05 15:34   ` K.Prasad
2009-11-05 21:06     ` Frederic Weisbecker
2009-11-08 17:32       ` K.Prasad
2009-11-12 15:42         ` Frederic Weisbecker [this message]
2009-11-03 19:11 ` [PATCH 5/6] hw-breakpoints: Arbitrate access to pmu following registers constraints Frederic Weisbecker
2009-11-05 10:58   ` Paul Mackerras
2009-11-05 11:24     ` Frederic Weisbecker
2009-11-08 20:56     ` Benjamin Herrenschmidt
2009-11-12 15:54       ` Frederic Weisbecker
2009-11-12 20:00         ` Benjamin Herrenschmidt
2009-11-14 13:34           ` Frederic Weisbecker
2009-11-03 19:11 ` [PATCH 6/6] ksym_tracer: Remove KSYM_SELFTEST_ENTRY Frederic Weisbecker
2009-11-05 14:13 ` [GIT PULL v4] hw-breakpoints: Rewrite on top of perf events v4 K.Prasad
2009-11-05 20:30   ` Frederic Weisbecker
  -- strict thread matches above, loose matches on Subject: below --
2009-10-24 14:16 [GIT PULL v2] hw-breakpoints: Rewrite on top of perf events Frederic Weisbecker
2009-10-24 14:16 ` [PATCH 4/6] hw-breakpoints: Rewrite the hw-breakpoints layer " Frederic Weisbecker
2009-10-24 16:19   ` Jan Kiszka
2009-10-25 23:31     ` Frederic Weisbecker
2009-10-26  8:17       ` Jan Kiszka
2009-11-01 21:09         ` Frederic Weisbecker
2009-11-01 22:09           ` Jan Kiszka
2009-11-01 22:49             ` Frederic Weisbecker
2009-11-01 23:37             ` Frederic Weisbecker
2009-11-02  7:45               ` Jan Kiszka
2009-11-02 13:04                 ` Frederic Weisbecker

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=20091112154221.GD5237@nowhere \
    --to=fweisbec@gmail.com \
    --cc=acme@redhat.com \
    --cc=avi@redhat.com \
    --cc=efault@gmx.de \
    --cc=jan.kiszka@web.de \
    --cc=jirislaby@gmail.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mhiramat@redhat.com \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=prasad@linux.vnet.ibm.com \
    --cc=rostedt@goodmis.org \
    --cc=stern@rowland.harvard.edu \
    /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.