Commit f6ef9d5b authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] kill_fasync speedup

From: Manfred Spraul <manfred@colorfullife.com>

fasync_helper and kill_fasync are helpers for managing F_SETFL fcntl 
calls that change FASYNC and sending the necessary signals. The locking 
uses one global rwlock that's acquired for read in all kill_fasync
calls, and that causes cache line trashing. This is not necessary: if
the fasync list is empty, then there is no need to acquire the rwlock.
Tests with reaim on a 4-way pIII on STP showed an 80% reduction of the
time within kill_fasync.
parent 96c4bc2e
...@@ -609,9 +609,15 @@ EXPORT_SYMBOL(__kill_fasync); ...@@ -609,9 +609,15 @@ EXPORT_SYMBOL(__kill_fasync);
void kill_fasync(struct fasync_struct **fp, int sig, int band) void kill_fasync(struct fasync_struct **fp, int sig, int band)
{ {
read_lock(&fasync_lock); /* First a quick test without locking: usually
__kill_fasync(*fp, sig, band); * the list is empty.
read_unlock(&fasync_lock); */
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); EXPORT_SYMBOL(kill_fasync);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment