PERFORCE change 100088 for review
John Baldwin
jhb at freebsd.org
Mon Jun 26 22:29:55 UTC 2006
On Monday 26 June 2006 16:51, Kip Macy wrote:
> http://perforce.freebsd.org/chv.cgi?CH=100088
>
> Change 100088 by kmacy at kmacy_storage:sun4v_work_sleepq on 2006/06/26
20:50:54
>
> allow turnstiles to handle sleeping for us
I thought this wasn't safe as some places wanted to sleep while holding the
filedesc lock. Maybe in select?
> Affected files ...
>
> .. //depot/projects/kmacy_sun4v/src/sys/sys/filedesc.h#5 edit
>
> Differences ...
>
> ==== //depot/projects/kmacy_sun4v/src/sys/sys/filedesc.h#5 (text+ko) ====
>
> @@ -96,60 +96,11 @@
> #ifdef _KERNEL
>
> /* Lock a file descriptor table. */
> -#define FILEDESC_LOCK(fd) \
> - do { \
> - mtx_lock(&(fd)->fd_mtx); \
> - (fd)->fd_wanted++; \
> - while ((fd)->fd_locked) \
> - msleep(&(fd)->fd_locked, &(fd)->fd_mtx, PLOCK, "fdesc", 0); \
> - (fd)->fd_locked = 2; \
> - (fd)->fd_wanted--; \
> - mtx_unlock(&(fd)->fd_mtx); \
> - } while (0)
> -
> -#define FILEDESC_UNLOCK(fd) \
> - do { \
> - mtx_lock(&(fd)->fd_mtx); \
> - KASSERT((fd)->fd_locked == 2, \
> - ("fdesc locking mistake %d should be %d", (fd)->fd_locked, 2)); \
> - (fd)->fd_locked = 0; \
> - if ((fd)->fd_wanted) \
> - wakeup_one(&(fd)->fd_locked); \
> - mtx_unlock(&(fd)->fd_mtx); \
> - } while (0)
> -
> -#define FILEDESC_LOCK_FAST(fd) \
> - do { \
> - mtx_lock(&(fd)->fd_mtx); \
> - (fd)->fd_wanted++; \
> - while ((fd)->fd_locked) \
> - msleep(&(fd)->fd_locked, &(fd)->fd_mtx, PLOCK, "fdesc", 0); \
> - (fd)->fd_locked = 1; \
> - (fd)->fd_wanted--; \
> - } while (0)
> -
> -#define FILEDESC_UNLOCK_FAST(fd) \
> - do { \
> - KASSERT((fd)->fd_locked == 1, \
> - ("fdesc locking mistake %d should be %d", (fd)->fd_locked, 1)); \
> - (fd)->fd_locked = 0; \
> - if ((fd)->fd_wanted) \
> - wakeup_one(&(fd)->fd_locked); \
> - mtx_unlock(&(fd)->fd_mtx); \
> - } while (0)
> -
> -#ifdef INVARIANT_SUPPORT
> -#define FILEDESC_LOCK_ASSERT(fd, arg) \
> - do { \
> - if ((arg) == MA_OWNED) \
> - KASSERT((fd)->fd_locked != 0, ("fdesc locking mistake")); \
> - else \
> - KASSERT((fd)->fd_locked == 0, ("fdesc locking mistake")); \
> - } while (0)
> -#else
> -#define FILEDESC_LOCK_ASSERT(fd, arg)
> -#endif
> -
> +#define FILEDESC_LOCK(fd) mtx_lock(&(fd)->fd_mtx);
> +#define FILEDESC_LOCK_FAST(fd) mtx_lock(&(fd)->fd_mtx);
> +#define FILEDESC_UNLOCK(fd) mtx_unlock(&(fd)->fd_mtx);
> +#define FILEDESC_UNLOCK_FAST(fd) mtx_unlock(&(fd)->fd_mtx);
> +#define FILEDESC_LOCK_ASSERT(fd, arg) mtx_assert(&(fd)->fd_mtx, arg)
> #define FILEDESC_LOCK_DESC "filedesc structure"
>
> struct thread;
>
--
John Baldwin
More information about the p4-projects
mailing list