Source-Changes-HG archive

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

[src/trunk]: src/sys ktrace ioctl data buffers



details:   https://anonhg.NetBSD.org/src/rev/1e47679d1f45
branches:  trunk
changeset: 547075:1e47679d1f45
user:      dsl <dsl%NetBSD.org@localhost>
date:      Mon May 12 15:17:36 2003 +0000

description:
ktrace ioctl data buffers
Optimise structure layout for 'struct selinfo' to avoid padding on 64bit
systems.  Use an entire variable for the 'collision' flag for efficiency.

diffstat:

 sys/kern/sys_generic.c |  38 +++++++++++++++++++++++++++-----------
 sys/sys/select.h       |   7 +++----
 2 files changed, 30 insertions(+), 15 deletions(-)

diffs (117 lines):

diff -r bb5126f54db3 -r 1e47679d1f45 sys/kern/sys_generic.c
--- a/sys/kern/sys_generic.c    Mon May 12 15:15:11 2003 +0000
+++ b/sys/kern/sys_generic.c    Mon May 12 15:17:36 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_generic.c,v 1.72 2003/03/26 17:50:16 jdolecek Exp $        */
+/*     $NetBSD: sys_generic.c,v 1.73 2003/05/12 15:17:37 dsl Exp $     */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_generic.c,v 1.72 2003/03/26 17:50:16 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_generic.c,v 1.73 2003/05/12 15:17:37 dsl Exp $");
 
 #include "opt_ktrace.h"
 
@@ -575,6 +575,15 @@
                                        free(memp, M_IOCTLOPS);
                                goto out;
                        }
+#ifdef KTRACE
+                       if (KTRPOINT(p, KTR_GENIO)) {
+                               struct iovec iov;
+                               iov.iov_base = SCARG(uap, data);
+                               iov.iov_len = size;
+                               ktrgenio(p, SCARG(uap, fd), UIO_READ, &iov,
+                                       size, 0);
+                       }
+#endif
                } else
                        *(caddr_t *)data = SCARG(uap, data);
        } else if ((com&IOC_OUT) && size)
@@ -642,8 +651,18 @@
                 * Copy any data to user, size was
                 * already set and checked above.
                 */
-               if (error == 0 && (com&IOC_OUT) && size)
+               if (error == 0 && (com&IOC_OUT) && size) {
                        error = copyout(data, SCARG(uap, data), size);
+#ifdef KTRACE
+                       if (KTRPOINT(p, KTR_GENIO)) {
+                               struct iovec iov;
+                               iov.iov_base = SCARG(uap, data);
+                               iov.iov_len = size;
+                               ktrgenio(p, SCARG(uap, fd), UIO_WRITE, &iov,
+                                       size, error);
+                       }
+#endif
+               }
                break;
        }
        if (memp)
@@ -956,23 +975,20 @@
        struct lwp      *l;
        struct proc     *p;
        pid_t           mypid;
-       int             collision;
 
        mypid = selector->p_pid;
        if (sip->sel_pid == mypid)
                return;
-       collision = 0;
        if (sip->sel_pid && (p = pfind(sip->sel_pid))) {
                LIST_FOREACH(l, &p->p_lwps, l_sibling) {
                        if (l->l_wchan == (caddr_t)&selwait) {
-                               collision = 1;
-                               sip->sel_flags |= SI_COLL;
+                               sip->sel_collision = 1;
+                               return;
                        }
                }
        }
 
-       if (collision == 0)
-               sip->sel_pid = mypid;
+       sip->sel_pid = mypid;
 }
 
 /*
@@ -988,10 +1004,10 @@
 
        if (sip->sel_pid == 0)
                return;
-       if (sip->sel_flags & SI_COLL) {
+       if (sip->sel_collision) {
                sip->sel_pid = 0;
                nselcoll++;
-               sip->sel_flags &= ~SI_COLL;
+               sip->sel_collision = 0;
                wakeup((caddr_t)&selwait);
                return;
        }
diff -r bb5126f54db3 -r 1e47679d1f45 sys/sys/select.h
--- a/sys/sys/select.h  Mon May 12 15:15:11 2003 +0000
+++ b/sys/sys/select.h  Mon May 12 15:17:36 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: select.h,v 1.14 2002/11/26 19:08:06 christos Exp $     */
+/*     $NetBSD: select.h,v 1.15 2003/05/12 15:17:36 dsl Exp $  */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -46,11 +46,10 @@
  * notified when I/O becomes possible.
  */
 struct selinfo {
+       struct klist    sel_klist;      /* knotes attached to this selinfo */
        pid_t           sel_pid;        /* process to be notified */
-       struct klist    sel_klist;      /* knotes attached to this selinfo */
-       short           sel_flags;      /* see below */
+       uint8_t         sel_collision;  /* non-zero if a collision occurred */
 };
-#define        SI_COLL         0x0001          /* collision occurred */
 
 #ifdef _KERNEL
 struct proc;



Home | Main Index | Thread Index | Old Index