All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Metzger <markus.t.metzger@googlemail.com>
To: eranian@gmail.com
Cc: "Metzger, Markus T" <markus.t.metzger@intel.com>,
	Markus Metzger <markus.t.metzger@googlemail.com>,
	Ingo Molnar <mingo@elte.hu>, Andi Kleen <andi@firstfloor.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: debugctl msr
Date: Wed, 19 Nov 2008 19:27:25 +0100	[thread overview]
Message-ID: <1227119245.6025.12.camel@raistlin> (raw)
In-Reply-To: <7c86c4470811190913u743706abgafff3b0f0e3559ec@mail.gmail.com>

On Wed, 2008-11-19 at 18:13 +0100, stephane eranian wrote:

> Speaking of locking, I also ran into another issue with ds_lock.
> Perfmon sessions each have a spinlock for access serialization, but to
> prevent from PMU and timers interrupts, interrupts are masked. Thus,
> when perfmon
> calls ds.c, interrupts are masked. That means that we lock/unlock ds_lock
> with interrupts disabled. The lock checker triggered when I ran a simple perfmon
> session and warned of possible lock inversion. Suppose you are coming from the
> ptrace code into ds. You grab ds_lock, but the same process is also running
> a perfmon session with PEBS and a counter overflows, you get into
> the PMU interrupt handler which may call into ds.c and try to grab the ds_lock.
> For that reason, I think you should use a
> spin_lock_irqsave/spin_unlock_irqrestore
> pairs to protect your ds context.

OK. So far, there was no user that called ds_*() with interrupts
disabled.


> I found another issue with ds_release(). You need to skip freeing the
> buffer when it
> is NULL, i.e., was already allocated by caller of ds_request_pebs().

ds_release() is not robust with respect to double release, if that's
what you mean. Is that desirable?

For a single ds_release() call matching a corresponding successful
ds_request() call, the buffer is freed if and only if it had been
allocated by ds.c.

Kfree() itself handles NULL pointers and scripts/checkpatch.pl warns on
a check for NULL around a kfree() call.


> I have attached a diff for the ds.c interface. It disables
> ds_validate_access(), export
> the PEBS functions to modules, fixes ds_release().
> 


> As for handling the interrupt is ds.c, not clear how this could work
> with current perfmon.
> I don't know how this work on the BTS side. On the PMU side, that is not because
> I am using PEBS, that I don't also use other counters as well. Longer
> term, I think, there
> needs to be a lower-level PMU interrupt service where you would
> register a callback
> on PMU interrupts. It would be used by NMI watchdog, perfmon,
> Oprofile, ds.c. 

That's even preferable to having the interrupt code itself in ds.c

The point I was trying to make is that buffer overflows should not be
handled on higher levels (i.e. users of ds.c). That's why I am so
reluctant to expose the interrupt threshold in the ds.c interface.


regards,
markus.


  reply	other threads:[~2008-11-19 18:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <7c86c4470810300753v7d377092qbcd266178d8e7338@mail.gmail.com>
     [not found] ` <029E5BE7F699594398CA44E3DDF5544402AB2C50@swsmsx413.ger.corp.intel.com>
     [not found]   ` <7c86c4470811040822i6745bee6mbe451284d76549be@mail.gmail.com>
     [not found]     ` <7c86c4470811050505j678c6929if00cceda2af8cb17@mail.gmail.com>
     [not found]       ` <7c86c4470811050711w3753232fk1030fb00259a7b8@mail.gmail.com>
     [not found]         ` <029E5BE7F699594398CA44E3DDF5544402AB350E@swsmsx413.ger.corp.intel.com>
     [not found]           ` <7c86c4470811060249g62666885nbaa559c1777217a0@mail.gmail.com>
     [not found]             ` <1226236327.6104.4.camel@raistlin>
     [not found]               ` <7c86c4470811111411k754887a8ic9b63163928157a6@mail.gmail.com>
     [not found]                 ` <491A812D.9010208@gmail.com>
2008-11-12 10:10                   ` debugctl msr stephane eranian
2008-11-12 10:59                     ` Metzger, Markus T
2008-11-13 14:50                       ` stephane eranian
2008-11-14 14:41                         ` Metzger, Markus T
2008-11-14 21:10                           ` stephane eranian
2008-11-15 10:01                             ` Markus Metzger
2008-11-18 22:00                               ` stephane eranian
2008-11-19 12:14                                 ` Metzger, Markus T
2008-11-19 12:59                                   ` stephane eranian
2008-11-19 15:47                                     ` Metzger, Markus T
2008-11-19 17:13                                       ` stephane eranian
2008-11-19 18:27                                         ` Markus Metzger [this message]
2008-11-19 19:20                                           ` stephane eranian
2008-11-19 20:53                                             ` stephane eranian
2008-11-19 22:26                                             ` Markus Metzger
2008-11-20 21:19                                               ` stephane eranian
2008-11-21  8:22                                                 ` Metzger, Markus T
2008-11-21  8:47                                                   ` stephane eranian
2008-11-21  8:58                                                     ` Metzger, Markus T
2008-11-21 13:38                                                   ` stephane eranian
2008-11-21 15:27                                                     ` stephane eranian
2008-11-21 16:10                                                       ` Metzger, Markus T
2008-11-21 16:33                                                         ` stephane eranian
2008-11-21 22:47                                                           ` stephane eranian
2008-11-22  9:51                                                             ` Markus Metzger
2008-11-23 22:31                                                               ` stephane eranian

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=1227119245.6025.12.camel@raistlin \
    --to=markus.t.metzger@googlemail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=eranian@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markus.t.metzger@intel.com \
    --cc=mingo@elte.hu \
    /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.