Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/yamt-uio_vmspace]: src/sys/kern - check the kcopy case in copy{in, out}_v...



details:   https://anonhg.NetBSD.org/src/rev/9b485c8d733e
branches:  yamt-uio_vmspace
changeset: 586697:9b485c8d733e
user:      yamt <yamt%NetBSD.org@localhost>
date:      Sat Dec 31 16:08:22 2005 +0000

description:
- check the kcopy case in copy{in,out}_vmspace.
- simplify uiomove instead.

diffstat:

 sys/kern/kern_subr.c |  41 ++++++++++++++++++++++-------------------
 1 files changed, 22 insertions(+), 19 deletions(-)

diffs (86 lines):

diff -r 0b08ff186d1e -r 9b485c8d733e sys/kern/kern_subr.c
--- a/sys/kern/kern_subr.c      Sat Dec 31 12:37:20 2005 +0000
+++ b/sys/kern/kern_subr.c      Sat Dec 31 16:08:22 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_subr.c,v 1.123.2.3 2005/12/31 11:34:25 yamt Exp $ */
+/*     $NetBSD: kern_subr.c,v 1.123.2.4 2005/12/31 16:08:22 yamt Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
@@ -86,7 +86,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.123.2.3 2005/12/31 11:34:25 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.123.2.4 2005/12/31 16:08:22 yamt Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -167,21 +167,17 @@
                        if (curcpu()->ci_schedstate.spc_flags &
                            SPCF_SHOULDYIELD)
                                preempt(1);
-                       if (uio->uio_rw == UIO_READ)
-                               error = copyout_vmspace(vm, cp, iov->iov_base,
-                                   cnt);
-                       else
-                               error = copyin_vmspace(vm, iov->iov_base, cp,
-                                   cnt);
-                       if (error)
-                               goto out;
+               }
+
+               if (uio->uio_rw == UIO_READ) {
+                       error = copyout_vmspace(vm, cp, iov->iov_base,
+                           cnt);
                } else {
-                       if (uio->uio_rw == UIO_READ)
-                               error = kcopy(cp, iov->iov_base, cnt);
-                       else
-                               error = kcopy(iov->iov_base, cp, cnt);
-                       if (error)
-                               goto out;
+                       error = copyin_vmspace(vm, iov->iov_base, cp,
+                           cnt);
+               }
+               if (error) {
+                       break;
                }
                iov->iov_base = (caddr_t)iov->iov_base + cnt;
                iov->iov_len -= cnt;
@@ -191,7 +187,6 @@
                KDASSERT(cnt <= n);
                n -= cnt;
        }
-out:
        KERNEL_LOCK_ACQUIRE_COUNT(hold_count);
        return (error);
 }
@@ -258,8 +253,12 @@
        if (len == 0)
                return (0);
 
-       if (__predict_true(vm == curproc->p_vmspace))
+       if (VMSPACE_IS_KERNEL(vm)) {
+               return kcopy(uaddr, kaddr, len);
+       }
+       if (__predict_true(vm == curproc->p_vmspace)) {
                return copyin(uaddr, kaddr, len);
+       }
 
        iov.iov_base = kaddr;
        iov.iov_len = len;
@@ -287,8 +286,12 @@
        if (len == 0)
                return (0);
 
-       if (__predict_true(vm == curproc->p_vmspace))
+       if (VMSPACE_IS_KERNEL(vm)) {
+               return kcopy(kaddr, uaddr, len);
+       }
+       if (__predict_true(vm == curproc->p_vmspace)) {
                return copyout(kaddr, uaddr, len);
+       }
 
        iov.iov_base = __UNCONST(kaddr); /* XXXUNCONST cast away const */
        iov.iov_len = len;



Home | Main Index | Thread Index | Old Index