From owner-svn-src-head@freebsd.org Thu Jul 6 15:03:55 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CD4DADAFF84; Thu, 6 Jul 2017 15:03:55 +0000 (UTC) (envelope-from gallatin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9C48473492; Thu, 6 Jul 2017 15:03:55 +0000 (UTC) (envelope-from gallatin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v66F3sCY055734; Thu, 6 Jul 2017 15:03:54 GMT (envelope-from gallatin@FreeBSD.org) Received: (from gallatin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v66F3s3p055733; Thu, 6 Jul 2017 15:03:54 GMT (envelope-from gallatin@FreeBSD.org) Message-Id: <201707061503.v66F3s3p055733@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gallatin set sender to gallatin@FreeBSD.org using -f From: Andrew Gallatin Date: Thu, 6 Jul 2017 15:03:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r320738 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: gallatin X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 320738 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jul 2017 15:03:55 -0000 Author: gallatin Date: Thu Jul 6 15:03:54 2017 New Revision: 320738 URL: https://svnweb.freebsd.org/changeset/base/320738 Log: Simplify UIO_SYSSPACE and UIO_NOCOPY paths in uiomove Uiomove can only block when the segflag is UIO_USERSPACE, otherwise we end up just doing a bcopy (or nothing) and moving cursors. So only emit witness warnings and set deadlock thread flags in the UIO_USERSPACE case. Reviewed by: kib Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D11489 Modified: head/sys/kern/subr_uio.c Modified: head/sys/kern/subr_uio.c ============================================================================== --- head/sys/kern/subr_uio.c Thu Jul 6 14:47:59 2017 (r320737) +++ head/sys/kern/subr_uio.c Thu Jul 6 15:03:54 2017 (r320738) @@ -206,31 +206,32 @@ uiomove_nofault(void *cp, int n, struct uio *uio) static int uiomove_faultflag(void *cp, int n, struct uio *uio, int nofault) { - struct thread *td; struct iovec *iov; size_t cnt; int error, newflags, save; - td = curthread; error = 0; KASSERT(uio->uio_rw == UIO_READ || uio->uio_rw == UIO_WRITE, ("uiomove: mode")); - KASSERT(uio->uio_segflg != UIO_USERSPACE || uio->uio_td == td, + KASSERT(uio->uio_segflg != UIO_USERSPACE || uio->uio_td == curthread, ("uiomove proc")); - if (!nofault) - WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, - "Calling uiomove()"); - /* XXX does it make a sense to set TDP_DEADLKTREAT for UIO_SYSSPACE ? */ - newflags = TDP_DEADLKTREAT; - if (uio->uio_segflg == UIO_USERSPACE && nofault) { - /* - * Fail if a non-spurious page fault occurs. - */ - newflags |= TDP_NOFAULTING | TDP_RESETSPUR; + if (uio->uio_segflg == UIO_USERSPACE) { + newflags = TDP_DEADLKTREAT; + if (nofault) { + /* + * Fail if a non-spurious page fault occurs. + */ + newflags |= TDP_NOFAULTING | TDP_RESETSPUR; + } else { + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, + "Calling uiomove()"); + } + save = curthread_pflags_set(newflags); + } else { + KASSERT(nofault == 0, ("uiomove: nofault")); } - save = curthread_pflags_set(newflags); while (n > 0 && uio->uio_resid) { iov = uio->uio_iov; @@ -272,7 +273,8 @@ uiomove_faultflag(void *cp, int n, struct uio *uio, in n -= cnt; } out: - curthread_pflags_restore(save); + if (uio->uio_segflg == UIO_USERSPACE) + curthread_pflags_restore(save); return (error); }