summaryrefslogtreecommitdiffstats
path: root/sys/opencrypto/cryptodev.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2007-04-04 09:11:34 +0000
committerrwatson <rwatson@FreeBSD.org>2007-04-04 09:11:34 +0000
commit765a83fd795f79d2911ebf3b158ddc368ea0a0f6 (patch)
tree8805b4674ed3429ddf05f19fd5eb0813fb7884aa /sys/opencrypto/cryptodev.c
parent37016d3a5dbecc7b8ef5733b5f47471e3418f9ea (diff)
downloadFreeBSD-src-765a83fd795f79d2911ebf3b158ddc368ea0a0f6.zip
FreeBSD-src-765a83fd795f79d2911ebf3b158ddc368ea0a0f6.tar.gz
Replace custom file descriptor array sleep lock constructed using a mutex
and flags with an sxlock. This leads to a significant and measurable performance improvement as a result of access to shared locking for frequent lookup operations, reduced general overhead, and reduced overhead in the event of contention. All of these are imported for threaded applications where simultaneous access to a shared file descriptor array occurs frequently. Kris has reported 2x-4x transaction rate improvements on 8-core MySQL benchmarks; smaller improvements can be expected for many workloads as a result of reduced overhead. - Generally eliminate the distinction between "fast" and regular acquisisition of the filedesc lock; the plan is that they will now all be fast. Change all locking instances to either shared or exclusive locks. - Correct a bug (pointed out by kib) in fdfree() where previously msleep() was called without the mutex held; sx_sleep() is now always called with the sxlock held exclusively. - Universally hold the struct file lock over changes to struct file, rather than the filedesc lock or no lock. Always update the f_ops field last. A further memory barrier is required here in the future (discussed with jhb). - Improve locking and reference management in linux_at(), which fails to properly acquire vnode references before using vnode pointers. Annotate improper use of vn_fullpath(), which will be replaced at a future date. In fcntl(), we conservatively acquire an exclusive lock, even though in some cases a shared lock may be sufficient, which should be revisited. The dropping of the filedesc lock in fdgrowtable() is no longer required as the sxlock can be held over the sleep operation; we should consider removing that (pointed out by attilio). Tested by: kris Discussed with: jhb, kris, attilio, jeff
Diffstat (limited to 'sys/opencrypto/cryptodev.c')
-rw-r--r--sys/opencrypto/cryptodev.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c
index 7de290c..15a207b 100644
--- a/sys/opencrypto/cryptodev.c
+++ b/sys/opencrypto/cryptodev.c
@@ -834,10 +834,12 @@ cryptoioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread
return (error);
}
/* falloc automatically provides an extra reference to 'f'. */
+ FILE_LOCK(f);
f->f_flag = FREAD | FWRITE;
f->f_type = DTYPE_CRYPTO;
- f->f_ops = &cryptofops;
f->f_data = fcr;
+ f->f_ops = &cryptofops;
+ FILE_UNLOCK(f);
*(u_int32_t *)data = fd;
fdrop(f, td);
break;
OpenPOWER on IntegriCloud