public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Will Deacon <will.deacon@arm.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	Ingo Molnar <mingo@elte.hu>,
	"acme@ghostprotocols.net" <acme@ghostprotocols.net>,
	Jason Wessel <jason.wessel@windriver.com>
Subject: Re: [PATCH 1/3] perf: add context field to perf_event
Date: Thu, 21 Jul 2011 18:36:43 +0300	[thread overview]
Message-ID: <4E28478B.1070907@redhat.com> (raw)
In-Reply-To: <20110721153238.GC8446@e102144-lin.cambridge.arm.com>

On 07/21/2011 06:32 PM, Will Deacon wrote:
> >
> >  Using TIF_bits sounds like a much better solution for this, wakeups are
> >  really rather expensive and its best to avoid extra if at all possible.
>
> The problem with using a TIF bit to tell a task that it needs to perform
> some preempt_notifier registrations is that you end up with something that
> looks a lot like preempt notifiers! You also don't escape the concurrent
> read/write to thelist of pending registrations.
>
> One thing I tried was simply using an RCU protected hlist for the preempt
> notifiers so that we don't have to worry about atomicity when reading the
> notifiers in finish_task_switch. It's a bit odd, since we know we only ever
> have a single reader, but I've included it below anyway.
>
> If anybody has any better ideas, I'm all ears.

> +void preempt_notifier_register_task(struct preempt_notifier *notifier,
> +				    struct task_struct *tsk)
> +{
> +	mutex_lock(&tsk->preempt_notifiers_mutex);
> +	hlist_add_head_rcu(&notifier->link,&tsk->preempt_notifiers);
> +	mutex_unlock(&tsk->preempt_notifiers_mutex);
> +}
> +EXPORT_SYMBOL_GPL(preempt_notifier_register_task);
> +
> +void preempt_notifier_unregister_task(struct preempt_notifier *notifier,
> +				      struct task_struct *tsk)
> +{
> +	mutex_lock(&tsk->preempt_notifiers_mutex);
> +	hlist_del_rcu(&notifier->link);
> +	mutex_unlock(&tsk->preempt_notifiers_mutex);
> +}
> +EXPORT_SYMBOL_GPL(preempt_notifier_unregister_task);
> +
>   /**
>    * preempt_notifier_register - tell me when current is being preempted&  rescheduled
>    * @notifier: notifier struct to register
>    */
>   void preempt_notifier_register(struct preempt_notifier *notifier)
>   {
> -	hlist_add_head(&notifier->link,&current->preempt_notifiers);
> +	preempt_notifier_register_task(notifier, current);
>   }
>   EXPORT_SYMBOL_GPL(preempt_notifier_register);

This is (and must be) called from a preempt disabled context, no mutexes 
around here.


-- 
error compiling committee.c: too many arguments to function


  reply	other threads:[~2011-07-21 15:37 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-29 15:42 [PATCH 0/3] Preparatory perf patches for KVM PMU support Avi Kivity
2011-06-29 15:42 ` [PATCH 1/3] perf: add context field to perf_event Avi Kivity
2011-06-29 16:08   ` Frederic Weisbecker
2011-06-29 16:25     ` Avi Kivity
2011-06-29 16:27     ` Will Deacon
2011-07-04 13:58       ` Frederic Weisbecker
2011-07-04 14:10         ` Avi Kivity
2011-07-04 14:36           ` Frederic Weisbecker
2011-07-11 21:07             ` Will Deacon
2011-07-12  7:20               ` Avi Kivity
2011-07-12  8:38                 ` Peter Zijlstra
2011-07-12  9:08                   ` Avi Kivity
2011-07-12  9:14                     ` Peter Zijlstra
2011-07-12  9:16                       ` Avi Kivity
2011-07-12  9:18                         ` Peter Zijlstra
2011-07-12  9:27                           ` Avi Kivity
2011-07-12  9:31                             ` Peter Zijlstra
2011-07-12  9:36                               ` Avi Kivity
2011-07-12  9:42                                 ` Will Deacon
2011-07-12  9:41                               ` Joerg Roedel
2011-07-12  9:44                                 ` Avi Kivity
2011-07-12  9:48                                   ` Joerg Roedel
2011-07-12  9:55                                     ` Avi Kivity
2011-07-12 10:03                                       ` Joerg Roedel
2011-07-12 10:07                                         ` Avi Kivity
2011-07-12 10:24                                           ` Joerg Roedel
2011-07-12 10:36                                             ` Avi Kivity
2011-07-21 15:32                               ` Will Deacon
2011-07-21 15:36                                 ` Avi Kivity [this message]
2011-07-21 15:46                                   ` Will Deacon
2011-07-21 15:59                                     ` Avi Kivity
2011-07-21 16:37                                       ` Will Deacon
2011-07-05 14:30         ` Will Deacon
2011-07-05 14:34           ` Frederic Weisbecker
2011-07-01 15:24   ` [tip:perf/core] perf: Add " tip-bot for Avi Kivity
2011-06-29 15:42 ` [PATCH 2/3] x86, perf: add constraints for architectural PMU v1 Avi Kivity
2011-07-01 15:24   ` [tip:perf/core] x86, perf: Add constraints for architectural PMU tip-bot for Avi Kivity
2011-06-29 15:42 ` [PATCH 3/3] perf: export perf_event_refresh() to modules Avi Kivity
2011-07-01 15:25   ` [tip:perf/core] " tip-bot for Avi Kivity

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=4E28478B.1070907@redhat.com \
    --to=avi@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=fweisbec@gmail.com \
    --cc=jason.wessel@windriver.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=will.deacon@arm.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