Messages in this thread | | | From | David Howells <> | Subject | Re: [PATCH] cred - synchronize rcu before releasing cred | Date | Fri, 18 Jun 2010 00:50:40 +0100 |
| |
Jiri Olsa <jolsa@redhat.com> wrote:
> maybe I have better solution... > > I think there's no need to get the cred refference as long as > the 'cred' handling stays inside the rcu_read_lock block.
I think this is right. There should be no need for a synchronize_rcu() call to be added in commit_creds() with this as commit_creds() calls put_cred() which will defer the destruction until the RCU grace period is up anyway.
Whilst I'd prefer to call get_cred() in task_state(), as you point out (and I hadn't considered), this may see an cred struct that has been detached from its pointer on another CPU and had its usage count reduced to 0.
In such a case, we can't simply increment the count and then decrement it again later as it's already on the RCU destruction queue and can't necessarily be removed so that it can be added back in.
What could be done, though I'm not sure it's worth it, is to use atomic_inc_not_zero() and loop around if the cred struct has gone out of service when we try and access it and reread the pointer.
The advantage of this would be that we could manage to hold the RCU read lock for as little time as possible.
Acked-by: David Howells <dhowells@redhat.com>
| |