Re: [PATCH net-next-2.6] fasync: RCU locking

From: Eric Dumazet
Date: Wed Apr 14 2010 - 11:34:35 EST


Le mercredi 14 avril 2010 Ã 16:57 +0200, Eric Dumazet a Ãcrit :
> Le mercredi 14 avril 2010 Ã 16:36 +0800, Lai Jiangshan a Ãcrit :
>
> > Since rcu_read_lock() protects fasync_struct *fa for us, we can access
> > to @fa safely even fasync_remove_entry() is just called.
> >
> > But this patch does not ensure 'fa->fa_file is not freed' nor
> > 'fa->fa_fd is not released', so kill_fasync_rcu() may do wrong thing
> > if there is no other code ensure it.
>
> You are 100% right, I forgot my old attempt to RCUified struct files
> failed...
>
> Maybe its time to finally move f_owner out of struct file, and use RCU
> to free it.
>
> In the mean time, adding a lock in fasync_struct is more than enough.
>
> Thanks !
>
> [PATCH net-next-2.6 v2] fasync: fine grained locking
>
> kill_fasync() uses a central rwlock, candidate for RCU conversion, to
> avoid cache line ping pongs on SMP.
>
> fasync_remove_entry() and fasync_add_entry() can disable IRQS on a short
> section instead during whole list scan.
>
> Use a spinlock per fasync_struct to synchronize fasync_{remove|
> add}_entry() and kill_fasync_rcu()
>
> We can remove __kill_fasync() direct use in net, and rename it to
> kill_fasync_rcu().
>
> Signed-off-by: Eric Dumazet <eric.dumazet@xxxxxxxxx>
> Cc: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>

Please wait for a v3 version, as net/socket.c sock_fasync() should be
updated too...



--
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/