mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH -tip] x86,perf: P4 PMU -- protect sensible procedures from  preemption
Date: Thu, 6 May 2010 11:45:56 +0400	[thread overview]
Message-ID: <n2maa79d98a1005060045ke0f87f4aw8b86da0440a019b3@mail.gmail.com> (raw)
In-Reply-To: <20100506074231.GA8625@elte.hu>

On Thursday, May 6, 2010, Ingo Molnar <mingo@elte.hu> wrote:
>
> * Cyrill Gorcunov <gorcunov@gmail.com> wrote:
>
>> On Thursday, May 6, 2010, Ingo Molnar <mingo@elte.hu> wrote:
>> >
>> > * Cyrill Gorcunov <gorcunov@gmail.com> wrote:
>> >
>> >> On Wed, May 05, 2010 at 06:57:34PM +0200, Frederic Weisbecker wrote:
>> >> ...
>> >> > > @@ -741,7 +743,7 @@ static int p4_pmu_schedule_events(struct
>> >> > > ?{
>> >> > > ? unsigned long used_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)];
>> >> > > ? unsigned long escr_mask[BITS_TO_LONGS(ARCH_P4_TOTAL_ESCR)];
>> >> > > - int cpu = raw_smp_processor_id();
>> >> > > + int cpu = get_cpu();
>> >> > > ? struct hw_perf_event *hwc;
>> >> > > ? struct p4_event_bind *bind;
>> >> > > ? unsigned int i, thread, num;
>> >> > > @@ -777,6 +779,7 @@ reserve:
>> >> > > ? }
>> >> > >
>> >> > > ?done:
>> >> > > + put_cpu();
>> >> > > ? return num ? -ENOSPC : 0;
>> >> > > ?}
>> >> >
>> >> > That's no big deal. But I think the schedule_events() is called on
>> >> > pmu::enable() time, when preemption is already disabled.
>> >> >
>> >>
>> >> We'll be on a safe side using get/put_cpu here (ie in case
>> >> if something get changed one day).
>> >
>> > hm, when 'something gets changed one day' we'll see a warning when using
>> > unsafe primitives.
>> >
>> > So if preemption is always off here we really should not add extra runtime
>> > overhead via get_cpu()/put_cpu().
>> >
>> > So wouldnt it be better (and faster) to disable preemption in
>> > hw_perf_event_init(), which seems to be the bit missing?
>> >
>> >  ? ? ? ?Ingo
>> >
>>
>> the thing are that p4 is only snippet here which is sensible to preemtion,
>> and hw_perf_event_init is executing with preemtion off (but i could miss the
>> details here, dont have code under my hands at moment, so PeterZ help is
>> needed ;) but more important reason why i've saved get/put here is that
>> otherwise i would not have rights to put tested-by tag, since it would not
>> be the patch Steven has tested. We could make a patch on top of this one, or
>> we could drop this one, make new with explicit preemt off in caller and use
>> smp_processor_id in p4 schedule routine. What is preferred?
>
> We want the one with the least runtime overhead. These are instrumentation
> routines, so we want to optimize them as much as possible.
>
> Thanks,
>
>         Ingo
>

ok, Ingo, dont apply this patch then for a while.

  reply	other threads:[~2010-05-06  7:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-05 15:07 Cyrill Gorcunov
2010-05-05 16:57 ` Frederic Weisbecker
2010-05-05 17:42   ` Cyrill Gorcunov
2010-05-05 17:58     ` Frederic Weisbecker
2010-05-06  6:44     ` Ingo Molnar
2010-05-06  7:39       ` Cyrill Gorcunov
2010-05-06  7:42         ` Ingo Molnar
2010-05-06  7:45           ` Cyrill Gorcunov [this message]
2010-05-06 13:45             ` Steven Rostedt
2010-05-06 14:48               ` Cyrill Gorcunov
2010-05-06 15:26                 ` Cyrill Gorcunov
2010-05-06 18:32                   ` Steven Rostedt
2010-05-06 18:36                     ` Cyrill Gorcunov
2010-05-07 15:05 Cyrill Gorcunov
2010-05-08  8:06 ` Ingo Molnar
2010-05-08  8:09   ` Cyrill Gorcunov

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=n2maa79d98a1005060045ke0f87f4aw8b86da0440a019b3@mail.gmail.com \
    --to=gorcunov@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®