[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20101109185748.GA12138@redhat.com>
Date: Tue, 9 Nov 2010 19:57:48 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Frederic Weisbecker <fweisbec@...il.com>,
Alan Stern <stern@...land.harvard.edu>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Ingo Molnar <mingo@...e.hu>, Paul Mackerras <paulus@...ba.org>,
Prasad <prasad@...ux.vnet.ibm.com>,
Roland McGrath <roland@...hat.com>,
linux-kernel@...r.kernel.org
Subject: Re: Q: perf_event && event->owner
On 11/09, Peter Zijlstra wrote:
>
> I think you're right, how about something like this?
I need to read it with a fresh head ;)
At first glance,
> @@ -2254,6 +2249,12 @@ static int perf_release(struct inode *in
>
> file->private_data = NULL;
>
> + if (event->owner) {
> + mutex_lock(&event->owner->perf_event_mutex);
> + list_del_init(&event->owner_entry);
> + mutex_unlock(&event->owner->perf_event_mutex);
> + }
Agreed, it is better to do this in perf_release().
But, this can use the already freed task_struct, event->owner.
Either sys_perf_open() should do get_task_struct() like we currently
do, or perf_event_exit_task() should clear event->owner and then
perf_release() should do something like
rcu_read_lock();
owner = event->owner;
if (owner)
get_task_struct(owner);
rcu_read_unlock();
if (owner) {
mutex_lock(&event->owner->perf_event_mutex);
list_del_init(&event->owner_entry);
mutex_unlock(&event->owner->perf_event_mutex);
put_task_struct(owner);
}
Probably this can be simplified...
Oleg.
--
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