linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* OProfile issues
@ 2007-06-12 15:02 Stephane Eranian
  2007-06-12 18:37 ` Chris Wright
                   ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: Stephane Eranian @ 2007-06-12 15:02 UTC (permalink / raw)
  To: oprofile-list; +Cc: wcohen, ak, perfmon, linux-kernel, levon

Hello,

I am working on perfmon2 to allow Oprofile and perfmon2 to co-exist
as suggested by Andi Kleen. I looked at the Oprofile init/shutdown
code and I am puzzled by several things which you might be able to
explain for me. I am looking at 2.6.22-rc3.

Here are the issues:

 * model->fill_in_addresses is called once for all CPUs
   on X86, it does more than just filling in the addresses,
   it also coordinates with the NMI watchdog by reserving
   registers via the reserve_*nmi() interface.

   The problem is that the release of the registers is done
   in model->shutdown() which happens to be executed on every
   CPU. So you end up releasing the registers too many times.
   This is *not* harmless once you start sharing the PMU with
   other subsystems given the way the allocator is designed.

 * allocate_msrs() allocates two tables per CPU. One for the
   counters, the other for the eventsel registers. But then
   nmi_setup() copies the cpu_msrs[0] into cpu_msrs[] of all
   other cpus. This operation overrides the cpu_msrs[].counters
   and cpu_msrs[].controls pointers for all CPUs but CPU0.
   But free_msrs() will free the same tables multiple times. This
   causes a kernel dump when you enable certain kernel debugging
   features. The fix is to copy the content of the counters and
   controls array, not the pointers.

 * the fill_in_addresses() callback for X86 invokes the NMI watchdog
   reserve_*_nmi() register allocation routines. This is done regardless
   of whether the NMI watchdog is active. When the NMI watchdog is not
   active, the allocator will satisfy the allocation for the first MSR
   of each type (counter or control), but then it will reject any
   request for the others. You end up working with a single
   counter/control register.

Are those known bugs?

-- 
-Stephane

^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [PATCH 1/2] Always probe the NMI watchdog
@ 2007-06-26  8:04 Mikael Pettersson
  2007-06-26  9:57 ` Stephane Eranian
  0 siblings, 1 reply; 31+ messages in thread
From: Mikael Pettersson @ 2007-06-26  8:04 UTC (permalink / raw)
  To: B.Steinbrink, eranian
  Cc: ak, ingo, levon, linux-kernel, oprofile-list, perfmon, wcohen

On Mon, 25 Jun 2007 23:04:25 +0200, B.Steinbrink@gmx.de wrote:
> > I think the tricky part is that we do want to reserve perfctr1 even
> > though the NMI watchdog is not active. This comes from the fact that
> > the NMI watchdog knows about only one counter and if it can't get that
> > one, it probably fails.  By reserving it from the start, we ensure NMI
> > watchdog will work when eventually activated.
> 
> Can you enable it later on at all? It failed for me when I tried,
> because it didn't know which hardware to use. Had to pass the kernel
> parameter to make the proc files do anything. Seems like it has to be
> enable at boot to work at all.
> 
> And AFAICT we never unconditionally reserved a perfctr for the watchdog.

Yes you can dynamically enable/disable the NMI watchdog,
at least if you booted with it enabled.

> In 2.6.21 the nmi watchdog, if enabled, just reserved its perfctrs and
> everything else had to deal with it. Since the cleanup, the watchdog
> will release its perfctr when disabled, so another subsystem can grab
> it. But that also means that that other subsystem must release it again
> before you can reenable the watchdog.

Which is the obvious and correct way to handle a shared resource.

Keeping parts of the PMU HW permanently reserved whether or not
the watchdog is enabled would be a BUG.

/Mikael

^ permalink raw reply	[flat|nested] 31+ messages in thread
* Re: [PATCH 1/2] Always probe the NMI watchdog
@ 2007-06-26 10:35 Mikael Pettersson
  0 siblings, 0 replies; 31+ messages in thread
From: Mikael Pettersson @ 2007-06-26 10:35 UTC (permalink / raw)
  To: eranian, mikpe
  Cc: B.Steinbrink, ak, ingo, levon, linux-kernel, oprofile-list,
	perfmon, wcohen

On Tue, 26 Jun 2007 02:57:55 -0700, Mikael Pettersson wrote:
> > Keeping parts of the PMU HW permanently reserved whether or not
> > the watchdog is enabled would be a BUG.
> > 
> True. But the upside is that you guarantee the activation of the NMI
> watchdog will always succeed which may be a valuable property given the
> goal of the NMI watchdog. Otherwise, if Oprofile or perfmon are active,
> the NMI will fail to grab a single counter.

That relates more to policy than mechanism. I for one don't
consider the watchdog "sacred".

I think it's entirely reasonable that if the watchdog is disabled
(echo 0 > /proc/sys/kernel/nmi_watchdog) in order to give the
_full_ PMU HW to something else, then that something else needs
to be disabled (or otherwise instructed to give up the HW) before
the watchdog can be reenabled. If you don't want to risk not
being able to restart the watchdog, don't disable it.

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2007-06-26 10:58 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-12 15:02 OProfile issues Stephane Eranian
2007-06-12 18:37 ` Chris Wright
2007-06-12 18:38 ` Chuck Ebbert
2007-06-12 19:07 ` Björn Steinbrink
2007-06-13  1:41   ` [PATCH] Separate performance counter reservation from nmi watchdog Björn Steinbrink
2007-06-13 16:46     ` Björn Steinbrink
2007-06-18  9:52       ` Stephane Eranian
2007-06-18 10:32         ` Björn Steinbrink
     [not found]           ` <11823357571842-git-send-email->
2007-06-20 10:35             ` [PATCH 1/2] Separate the performance counter allocation from the LAPIC NMI watchdog Björn Steinbrink
2007-06-20 10:35               ` [PATCH 2/2] Finish separation of the performance counter allocator from the " Björn Steinbrink
2007-06-20 12:31               ` [PATCH 1/2] Separate the performance counter allocation from the LAPIC " Andi Kleen
2007-06-20 12:49                 ` [perfmon] " Stephane Eranian
2007-06-20 13:01                   ` Andi Kleen
2007-06-20 18:33                     ` Björn Steinbrink
2007-06-20 18:34                       ` [PATCH 1/2] Always probe the " Björn Steinbrink
2007-06-25 19:09                         ` Andrew Morton
2007-06-25 19:36                           ` Andi Kleen
2007-06-25 20:01                             ` Stephane Eranian
2007-06-25 20:36                               ` Andi Kleen
2007-06-25 21:04                               ` Björn Steinbrink
2007-06-25 21:06                             ` Björn Steinbrink
2007-06-20 18:35                       ` [PATCH 2/2] Reserve the right performance counter for the Intel PerfMon " Björn Steinbrink
2007-06-20 21:59                       ` [perfmon] Re: [PATCH 1/2] Separate the performance counter allocation from the LAPIC " Stephane Eranian
2007-06-21  8:36                         ` Stephane Eranian
2007-06-22  7:13                           ` Björn Steinbrink
2007-06-22 10:02                             ` Stephane Eranian
2007-06-20 13:18                 ` Björn Steinbrink
2007-06-20 10:49           ` [PATCH 0/2] Performance counter allocator separation Björn Steinbrink
  -- strict thread matches above, loose matches on Subject: below --
2007-06-26  8:04 [PATCH 1/2] Always probe the NMI watchdog Mikael Pettersson
2007-06-26  9:57 ` Stephane Eranian
2007-06-26 10:35 Mikael Pettersson

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).