Date: Mon, 26 Jun 2006 17:59:22 -0400 From: John Baldwin <jhb@freebsd.org> To: Kip Macy <kmacy@freebsd.org> Cc: Perforce Change Reviews <perforce@freebsd.org> Subject: Re: PERFORCE change 100088 for review Message-ID: <200606261759.23136.jhb@freebsd.org> In-Reply-To: <200606262051.k5QKp8b3022216@repoman.freebsd.org> References: <200606262051.k5QKp8b3022216@repoman.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 26 June 2006 16:51, Kip Macy wrote: > http://perforce.freebsd.org/chv.cgi?CH=100088 > > Change 100088 by kmacy@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606261759.23136.jhb>