From owner-freebsd-current@FreeBSD.ORG Wed Jun 12 18:59:58 2013 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9E95D129 for ; Wed, 12 Jun 2013 18:59:58 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id 0CEC51B4A for ; Wed, 12 Jun 2013 18:59:57 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.7/8.14.7) with ESMTP id r5CIxrQh052090; Wed, 12 Jun 2013 21:59:53 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.3 kib.kiev.ua r5CIxrQh052090 Received: (from kostik@localhost) by tom.home (8.14.7/8.14.7/Submit) id r5CIxrcC052089; Wed, 12 Jun 2013 21:59:53 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 12 Jun 2013 21:59:53 +0300 From: Konstantin Belousov To: Luigi Rizzo Subject: Re: copyin()/copyout() constraints ? Message-ID: <20130612185953.GK3146@kib.kiev.ua> References: <20130612180115.GA27892@onelab2.iet.unipi.it> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="3D7yMlnunRPwJqC7" Content-Disposition: inline In-Reply-To: <20130612180115.GA27892@onelab2.iet.unipi.it> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on tom.home Cc: current@freebsd.org 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: Wed, 12 Jun 2013 18:59:58 -0000 --3D7yMlnunRPwJqC7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 12, 2013 at 08:01:15PM +0200, 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) >=20 > I suspect #1 is forbidden, but am a bit unclear for the > other cases. The rules for copyin/copyout/uiomove come from the fact that usermode access might require VM handling the page fault, which might further require VM access to the VFS/filesystem and device. If the filesystem is NFS, then there is a network access down the stack. As result, you cannot hold any lock which may be recursed, or any non-sleepable lock. In other word, answer to all your four questions is no, since kernel cannot sleep while owning spinlock, mutex, rmlock or rwlock. In practical terms, you could only own some private sleepable lock which is before any other kernel lock. --3D7yMlnunRPwJqC7 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (FreeBSD) iQIcBAEBAgAGBQJRuMUoAAoJEJDCuSvBvK1BwL8QAIDftQ6aDRdMIUkcD8Wvp4yD +3eKFX0HgNmGjdO9PMn4iHUp11gQ6dYwX+4hAP2jUY8e+bwBPFpsyfiwSv1UeO+e vUIJVUfwlyeP5XKo/RLXdfkzDN516qBhoyg/gyKzoLRlOrQ3CDTPKpiM/GilCjYS Bckx5ksPlgNzsMHJch3eqBPccS5hey6xS0EsdWKbYI78gAg03Mhg/wux9Qq0xZvL +2F18HpOFzPCdlc2PjjF5ZOv/3kSv7pyjK/TzrXkhTs4kQAWIL+lu9DF5lq/5yME cpKd20rUsWkPsLQ37GnuLWl4L3idR6pP7C4/A5iQcXHIbVpfwpZiCXVAIQt2XEow xTgShw1AUYU7QRTu6U12xuv6harsCPddKjsCl3jjLo6CLeRA0l6QKNWlDmi+ozFs +6U/IJQtfNaS0XKTryuysWUIpfJ4Bhrs0Dwqb6Djewhe7vVshf7J5ZKosgb0oiLB Dva/Ppwdqqit7QM4FbLxdzcMcDONUiYVez8SmBnBmpUL4teyr7Qcb7gx6ZWQ0EZ6 QY8rkqcBnCV2wrNeUjeNbO7snXqhQv0D2wy9B1DSSehMMjP3rtTboUgl2TaLyock IVGERI7rSOsdmo2BHOgtXQLPM9ZWJCaJSG1ftQO5N4FsDvyiPn5ECyKaqipNEat+ cXIp9m+wHdHYsuppZEgN =lTiP -----END PGP SIGNATURE----- --3D7yMlnunRPwJqC7--