From owner-freebsd-current@FreeBSD.ORG Fri Jun 14 16:14:54 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0F3B24A1 for ; Fri, 14 Jun 2013 16:14:54 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) by mx1.freebsd.org (Postfix) with ESMTP id D1F621911 for ; Fri, 14 Jun 2013 16:14:53 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 291D2B915; Fri, 14 Jun 2013 12:14:53 -0400 (EDT) From: John Baldwin To: freebsd-current@freebsd.org Subject: Re: copyin()/copyout() constraints ? Date: Fri, 14 Jun 2013 12:07:29 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p25; KDE/4.5.5; amd64; ; ) References: <20130612180115.GA27892@onelab2.iet.unipi.it> <51B8BFC4.303@mu.org> In-Reply-To: <51B8BFC4.303@mu.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201306141207.29779.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 14 Jun 2013 12:14:53 -0400 (EDT) Cc: Alfred Perlstein , Luigi Rizzo X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jun 2013 16:14:54 -0000 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