Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Jun 2013 16:56:57 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Luigi Rizzo <rizzo@iet.unipi.it>
Cc:        freebsd-current@freebsd.org, Alfred Perlstein <bright@mu.org>
Subject:   Re: copyin()/copyout() constraints ?
Message-ID:  <201306141656.57827.jhb@freebsd.org>
In-Reply-To: <20130614163812.GA50980@onelab2.iet.unipi.it>
References:  <20130612180115.GA27892@onelab2.iet.unipi.it> <201306141207.29779.jhb@freebsd.org> <20130614163812.GA50980@onelab2.iet.unipi.it>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday, June 14, 2013 12:38:12 pm Luigi Rizzo wrote:
> On Fri, Jun 14, 2013 at 12:07:29PM -0400, John Baldwin wrote:
> > On Wednesday, June 12, 2013 2:36:52 pm Alfred Perlstein wrote:
> > > On 6/12/13 11:01 AM, Luigi Rizzo wrote:
> > > > hi,
> > > > is it possible to run copyin() or copyout() in one of these cases:
> > > > 1. while holding a spinlock
> > > > 2. while holding a regular mutex/lock
> > > > 3. while holding a read lock (on an RWLOCK or RMLOCK)
> > > > 4. while holding a write lock (on an RWLOCK or RMLOCK)
> > > >
> > > > I suspect #1 is forbidden, but am a bit unclear for the
> > > > other cases.
> > > No on all of the above unless the memory is wired.
> 
> ok i suppose i'll move to an sx lock, which i have been told
> allows me to sleep ?
> 
> My use case is that while i run the copyin(), and possibly take a
> page fault, nobody destroys the destination buffer.  So i wanted
> to hold a read lock (sx_slock() ?) in the thread doing the copy
> (there may be several writers to different parts of the destination),
> and a write lock (sx_xlock() ?) for the other thread which may
> destroy the buffer.

Yep, that will work fine.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306141656.57827.jhb>