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

next in thread | previous in thread | raw e-mail | index | archive | help
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.

If the memory is wired you can hold anything you want since it's basically a 
memcpy at that point.  Various sysctl handlers that need to hold locks while
writing things out use sysctl_wire_old_buffer() for exactly this reason.

-- 
John Baldwin



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