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) > > 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.
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:38 UTC