diff options
author | rwatson <rwatson@FreeBSD.org> | 2007-04-04 09:11:34 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2007-04-04 09:11:34 +0000 |
commit | 765a83fd795f79d2911ebf3b158ddc368ea0a0f6 (patch) | |
tree | 8805b4674ed3429ddf05f19fd5eb0813fb7884aa /sys/netsmb | |
parent | 37016d3a5dbecc7b8ef5733b5f47471e3418f9ea (diff) | |
download | FreeBSD-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/netsmb')
-rw-r--r-- | sys/netsmb/smb_dev.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/netsmb/smb_dev.c b/sys/netsmb/smb_dev.c index d3ed95a..850f0ad 100644 --- a/sys/netsmb/smb_dev.c +++ b/sys/netsmb/smb_dev.c @@ -368,15 +368,15 @@ nsmb_getfp(struct filedesc* fdp, int fd, int flag) { struct file* fp; - FILEDESC_LOCK(fdp); + FILEDESC_SLOCK(fdp); if (((u_int)fd) >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL || (fp->f_flag & flag) == 0) { - FILEDESC_UNLOCK(fdp); + FILEDESC_SUNLOCK(fdp); return (NULL); } fhold(fp); - FILEDESC_UNLOCK(fdp); + FILEDESC_SUNLOCK(fdp); return (fp); } |