Re: [RFC,PATCH] use rcu for fasync_lock

From: Manfred Spraul
Date: Wed Dec 24 2003 - 20:24:45 EST




On Sun, 21 Dec 2003, Linus Torvalds wrote:

>
> > kill_fasync is far more common (every pipe_read and _write), I want to
> > remove the unconditional read_lock(&global_lock).
>
> Note that my personal preference would be to kill off "kill_fasync()"
> entirely.
>
We've discussed that earlier in the thread, and came to the same
conclusion. Unfortunately it touches several drivers, and is not a simple
patch. Viro's summary of fasync in Documentation/filesystem/Locking is
"fasync is a mess" - converting kill_fasync to wake_up_band() is 2.7
stuff.

What about this minimal approach:

<<<<
--- 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);
+ }
}

EXPORT_SYMBOL(kill_fasync);
<<<<


--
Manfred

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