Re: __lock_task_sighand() and RCU

From: Oleg Nesterov
Date: Mon Mar 28 2011 - 10:45:08 EST


Hi Matt,

On 03/28, Matt Fleming wrote:
>
> I've been reading __lock_task_sighand() and I can't quite wrap my head
> around what the rcu_read_lock()/rcu_read_unlock() is protecting in
> there.

It protects ->sighand.

> Initially I assumed that it was protecting the 'tsk' argument,

No. the caller must have a reference.

> Then I wondered if it was protecting the sighand from being freed from
> under us while we're trying to lock it.

Yes,

> But sighands aren't freed via
> rcu,

it is ;)

> it's just a simple refcnt and kmem_cache_free()

Yes, but please note that sighand_cachep was created with
SLAB_DESTROY_BY_RCU.

Oleg.

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