lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4E28478B.1070907@redhat.com>
Date:	Thu, 21 Jul 2011 18:36:43 +0300
From:	Avi Kivity <avi@...hat.com>
To:	Will Deacon <will.deacon@....com>
CC:	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Frederic Weisbecker <fweisbec@...il.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
	Ingo Molnar <mingo@...e.hu>,
	"acme@...stprotocols.net" <acme@...stprotocols.net>,
	Jason Wessel <jason.wessel@...driver.com>
Subject: Re: [PATCH 1/3] perf: add context field to perf_event

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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ