Re: [RFC,PATCH] use rcu for fasync_lock

From: OGAWA Hirofumi
Date: Thu Dec 25 2003 - 10:15:01 EST


Manfred Spraul <manfred@xxxxxxxxxxxxxxxx> writes:

> --- 2.6/fs/fcntl.c 2003-12-04 19:44:38.000000000 +0100
> +++ build-2.6/fs/fcntl.c 2003-12-24 00:15:16.000000000 +0100
> @@ -609,9 +609,15 @@
>
> void kill_fasync(struct fasync_struct **fp, int sig, int band)
> {
> - read_lock(&fasync_lock);
> - __kill_fasync(*fp, sig, band);
> - read_unlock(&fasync_lock);
> + /* First a quick test without locking: usually
> + * the list is empty.
> + */
> + if (*fp) {
> + read_lock(&fasync_lock);
> + /* reread *fp after obtaining the lock */
> + __kill_fasync(*fp, sig, band);
> + read_unlock(&fasync_lock);
> + }
> }

Looks good to me. This should be the enough effect for usual path.

Thanks.
--
OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>
-
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/