<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/">
  <channel rdf:about="http://blog.gmane.org/gmane.os.netbsd.devel.kernel">
    <title>gmane.os.netbsd.devel.kernel</title>
    <link>http://blog.gmane.org/gmane.os.netbsd.devel.kernel</link>
    <description/>
    <syn:updatePeriod>hourly</syn:updatePeriod>
    <syn:updateFrequency>1</syn:updateFrequency>
    <syn:updateBase>1901-01-01T00:00+00:00</syn:updateBase>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42133"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42127"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42122"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42111"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42109"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42101"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42096"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42082"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42065"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42063"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42055"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42051"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42044"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42035"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42023"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42005"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42002"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/41996"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/41992"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/41982"/>
      </rdf:Seq>
    </items>
    <image rdf:resource="http://gmane.org/img/gmane-25t.png"/>
    <textinput rdf:resource=""/>
  </channel>
  <image rdf:about="http://gmane.org/img/gmane-25t.png">
    <title>Gmane</title>
    <url>http://gmane.org/img/gmane-25t.png</url>
    <link>http://gmane.org</link>
  </image>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42133">
    <title>raw/block device disc troughput</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42133</link>
    <description>&lt;pre&gt;It seems that I have to update my understanding of raw and block devices
for discs.

Using a (non-recent) 6.0_BETA INSTALL kernel and an ST9146853SS 15k SAS disc
behind an LSI SAS 1068E (i.e. mpt(4)), I did a
dd if=/dev/zero od=/dev/[r]sd0b bs=nn, count=xxx.
For the raw device, the troughput dramatically increased with the block size:
Block size16k64k256k1M
Troughput (MByte/s)41549112
For the block device, throughput was around 81MByte/s independent of block size.

This surprised me in two ways:
1. I would have expected the raw device to outperform the block devices
   with not too small block sizes.
2. I would have expected inceasing the block size above MAXPHYS not
   improving the performance.

So obviously, my understanding is wrong.


I then build a RAID 1 with SectorsPerSU=128 (e.g. a 64k stripe size) on two
of these discs, and, after the parity initialisation was complete, wrote
to [r]raid0b.
On the raw device, throghput ranged from 4MByte/s to 97MByte/s depending on bs.
On the block device, it was always 3MByte/s. Furthermore, dd's WCHAN was
"vnode" for the whole run. Why is that so and why is throughput so low?

&lt;/pre&gt;</description>
    <dc:creator>Edgar Fuß</dc:creator>
    <dc:date>2012-05-24T16:26:45</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42127">
    <title>lwp resource limit</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42127</link>
    <description>&lt;pre&gt;Hello,

This is a new resource limit to prevent users from exhausting kernel
resources that lwps use.

- The limit is per uid
- The default is 1024 per user unless the architecture overrides it
- The kernel is never prohibited from creating threads
- Exceeding the thread limit does not prevent process creation, but
  it will prevent processes from creating additional threads. So the
  effective thread limit is nlwp + nproc
- The name NTHR was chosen to follow prior art
- There could be atomicity issues for setuid and lwp exits
- This diff also adds a sysctl kern.uidinfo.* to show the user the uid
  limits

comments?

christos
Index: kern/init_main.c
===================================================================
RCS file: /cvsroot/src/sys/kern/init_main.c,v
retrieving revision 1.442
diff -u -p -u -r1.442 init_main.c
--- kern/init_main.c19 Feb 2012 21:06:47 -00001.442
+++ kern/init_main.c23 May 2012 23:19:31 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -256,6 +256,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; intcold = 1;/* still working on star
 struct timespec boottime;        /* time at system startup - will only follow settime deltas */
 
 intstart_init_exec;/* semaphore for start_init() */
+intmaxlwp;
 
 cprng_strong_t*kern_cprng;
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -291,6 +292,12 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; main(void)
 #endif
 l-&amp;gt;l_pflag |= LP_RUNNING;
 
+#ifdef __HAVE_CPU_MAXLWP
+maxlwp = cpu_maxlwp();
+#else
+maxlwp = 1024;
+#endif
+
 /*
  * Attempt to find console and initialize
  * in case of early panic or other messages.
Index: kern/init_sysctl.c
===================================================================
RCS file: /cvsroot/src/sys/kern/init_sysctl.c,v
retrieving revision 1.189
diff -u -p -u -r1.189 init_sysctl.c
--- kern/init_sysctl.c7 Apr 2012 05:38:49 -00001.189
+++ kern/init_sysctl.c23 May 2012 23:19:31 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -147,6 +147,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int sysctl_kern_trigger_panic(SYS
 static int sysctl_kern_maxvnodes(SYSCTLFN_PROTO);
 static int sysctl_kern_rtc_offset(SYSCTLFN_PROTO);
 static int sysctl_kern_maxproc(SYSCTLFN_PROTO);
+static int sysctl_kern_maxlwp(SYSCTLFN_PROTO);
 static int sysctl_kern_hostid(SYSCTLFN_PROTO);
 static int sysctl_setlen(SYSCTLFN_PROTO);
 static int sysctl_kern_clockrate(SYSCTLFN_PROTO);
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -234,6 +235,12 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; SYSCTL_SETUP(sysctl_kern_setup, "sysctl 
        CTL_KERN, KERN_MAXPROC, CTL_EOL);
 sysctl_createv(clog, 0, NULL, NULL,
        CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+       CTLTYPE_INT, "maxlwp",
+       SYSCTL_DESCR("Maximum number of simultaneous threads"),
+       sysctl_kern_maxlwp, 0, NULL, 0,
+       CTL_KERN, KERN_MAXLWP, CTL_EOL);
+sysctl_createv(clog, 0, NULL, NULL,
+       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
        CTLTYPE_INT, "maxfiles",
        SYSCTL_DESCR("Maximum number of open files"),
        NULL, 0, &amp;amp;maxfiles, 0,
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1050,6 +1057,33 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; sysctl_kern_maxproc(SYSCTLFN_ARGS)
 }
 
 /*
+ * sysctl helper routine for kern.maxlwp. Ensures that the new
+ * values are not too low or too high.
+ */
+static int
+sysctl_kern_maxlwp(SYSCTLFN_ARGS)
+{
+int error, nmaxlwp;
+struct sysctlnode node;
+
+nmaxlwp = maxlwp;
+node = *rnode;
+node.sysctl_data = &amp;amp;nmaxlwp;
+error = sysctl_lookup(SYSCTLFN_CALL(&amp;amp;node));
+if (error || newp == NULL)
+return error;
+
+if (nmaxlwp &amp;lt; 0 || nmaxlwp &amp;gt;= 65536)
+return EINVAL;
+#ifdef __HAVE_CPU_MAXLWP
+if (nmaxlwp &amp;gt; cpu_maxlwp())
+return EINVAL;
+#endif
+maxlwp = nmaxlwp;
+
+return 0;
+}
+/*
  * sysctl helper function for kern.hostid. The hostid is a long, but
  * we export it as an int, so we need to give it a little help.
  */
Index: kern/kern_exec.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_exec.c,v
retrieving revision 1.352
diff -u -p -u -r1.352 kern_exec.c
--- kern/kern_exec.c2 May 2012 23:33:11 -00001.352
+++ kern/kern_exec.c23 May 2012 23:19:32 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -2295,7 +2295,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; do_posix_spawn(struct lwp *l1, pid_t *pi
 
 /* create LWP */
 lwp_create(l1, p2, uaddr, 0, NULL, 0, spawn_return, spawn_data,
-    &amp;amp;l2, l1-&amp;gt;l_class);
+    &amp;amp;l2, l1-&amp;gt;l_class, 0);
 l2-&amp;gt;l_ctxlink = NULL;/* reset ucontext link */
 
 /*
Index: kern/kern_fork.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_fork.c,v
retrieving revision 1.189
diff -u -p -u -r1.189 kern_fork.c
--- kern/kern_fork.c13 Mar 2012 18:40:52 -00001.189
+++ kern/kern_fork.c23 May 2012 23:19:32 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -426,7 +426,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; fork1(struct lwp *l1, int flags, int exi
  */
 lwp_create(l1, p2, uaddr, (flags &amp;amp; FORK_PPWAIT) ? LWP_VFORK : 0,
     stack, stacksize, (func != NULL) ? func : child_return, arg, &amp;amp;l2,
-    l1-&amp;gt;l_class);
+    l1-&amp;gt;l_class, 0);
 
 /*
  * Inherit l_private from the parent.
Index: kern/kern_kthread.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_kthread.c,v
retrieving revision 1.38
diff -u -p -u -r1.38 kern_kthread.c
--- kern/kern_kthread.c1 Nov 2011 15:39:37 -00001.38
+++ kern/kern_kthread.c23 May 2012 23:19:32 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -81,7 +81,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; kthread_create(pri_t pri, int flag, stru
 }
 
 error = lwp_create(&amp;amp;lwp0, &amp;amp;proc0, uaddr, LWP_DETACHED, NULL,
-    0, func, arg, &amp;amp;l, lc);
+    0, func, arg, &amp;amp;l, lc, 0);
 if (error) {
 uvm_uarea_system_free(uaddr);
 return error;
Index: kern/kern_lwp.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_lwp.c,v
retrieving revision 1.168
diff -u -p -u -r1.168 kern_lwp.c
--- kern/kern_lwp.c13 Apr 2012 15:32:43 -00001.168
+++ kern/kern_lwp.c23 May 2012 23:19:32 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -239,6 +239,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; __KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v
 #include &amp;lt;sys/dtrace_bsd.h&amp;gt;
 #include &amp;lt;sys/sdt.h&amp;gt;
 #include &amp;lt;sys/xcall.h&amp;gt;
+#include &amp;lt;sys/uidinfo.h&amp;gt;
 
 #include &amp;lt;uvm/uvm_extern.h&amp;gt;
 #include &amp;lt;uvm/uvm_object.h&amp;gt;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -668,15 +669,32 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; lwp_wait1(struct lwp *l, lwpid_t lid, lw
 int
 lwp_create(lwp_t *l1, proc_t *p2, vaddr_t uaddr, int flags,
    void *stack, size_t stacksize, void (*func)(void *), void *arg,
-   lwp_t **rnewlwpp, int sclass)
+   lwp_t **rnewlwpp, int sclass, int enforce)
 {
 struct lwp *l2, *isfree;
 turnstile_t *ts;
 lwpid_t lid;
+uid_t uid;
+int count;
 
 KASSERT(l1 == curlwp || l1-&amp;gt;l_proc == &amp;amp;proc0);
 
 /*
+ * Enforce limits.
+ */
+uid = kauth_cred_getuid(l1-&amp;gt;l_cred);
+count = chglwpcnt(uid, 1);
+if (enforce &amp;amp;&amp;amp;
+    __predict_false(count &amp;gt; p2-&amp;gt;p_rlimit[RLIMIT_NTHR].rlim_cur)) {
+if (kauth_authorize_process(l1-&amp;gt;l_cred, KAUTH_PROCESS_RLIMIT,
+    p2, KAUTH_ARG(KAUTH_REQ_PROCESS_RLIMIT_BYPASS),
+    &amp;amp;p2-&amp;gt;p_rlimit[RLIMIT_NTHR], KAUTH_ARG(RLIMIT_NTHR)) != 0) {
+(void)chglwpcnt(uid, -1);
+return EAGAIN;
+}
+}
+
+/*
  * First off, reap any detached LWP waiting to be collected.
  * We can re-use its LWP structure and turnstile.
  */
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -898,6 +916,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; lwp_exit(struct lwp *l)
 
 SDT_PROBE(proc,,,lwp_exit, l, 0,0,0,0);
 
+chglwpcnt(kauth_cred_getuid(l-&amp;gt;l_cred), -1);
 /*
  * Verify that we hold no locks other than the kernel lock.
  */
Index: kern/kern_proc.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_proc.c,v
retrieving revision 1.183
diff -u -p -u -r1.183 kern_proc.c
--- kern/kern_proc.c13 Apr 2012 15:32:15 -00001.183
+++ kern/kern_proc.c23 May 2012 23:19:33 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -460,6 +460,9 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; proc0_init(void)
 rlim[RLIMIT_MEMLOCK].rlim_max = lim;
 rlim[RLIMIT_MEMLOCK].rlim_cur = lim / 3;
 
+rlim[RLIMIT_NTHR].rlim_max = maxlwp;
+rlim[RLIMIT_NTHR].rlim_cur = maxlwp &amp;lt; maxuprc ? maxlwp : maxuprc;
+
 /* Note that default core name has zero length. */
 limit0.pl_corename = defcorename;
 limit0.pl_cnlen = 0;
Index: kern/kern_prot.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_prot.c,v
retrieving revision 1.114
diff -u -p -u -r1.114 kern_prot.c
--- kern/kern_prot.c19 Mar 2012 06:04:19 -00001.114
+++ kern/kern_prot.c23 May 2012 23:19:33 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -346,6 +346,11 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; do_setresuid(struct lwp *l, uid_t r, uid
 /* Update count of processes for this user */
 (void)chgproccnt(kauth_cred_getuid(ncred), -1);
 (void)chgproccnt(r, 1);
+
+int nlwps = p-&amp;gt;p_nlwps;
+(void)chglwpcnt(kauth_cred_getuid(ncred), -nlwps);
+(void)chglwpcnt(r, nlwps);
+
 kauth_cred_setuid(ncred, r);
 }
 if (sv != -1)
Index: kern/kern_resource.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_resource.c,v
retrieving revision 1.168
diff -u -p -u -r1.168 kern_resource.c
--- kern/kern_resource.c2 Dec 2011 12:33:12 -00001.168
+++ kern/kern_resource.c23 May 2012 23:19:33 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -439,6 +439,13 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; dosetrlimit(struct lwp *l, struct proc *
 if (limp-&amp;gt;rlim_max &amp;gt; maxproc)
 limp-&amp;gt;rlim_max = maxproc;
 break;
+
+case RLIMIT_NTHR:
+if (limp-&amp;gt;rlim_cur &amp;gt; maxlwp)
+limp-&amp;gt;rlim_cur = maxlwp;
+if (limp-&amp;gt;rlim_max &amp;gt; maxlwp)
+limp-&amp;gt;rlim_max = maxlwp;
+break;
 }
 
 mutex_enter(&amp;amp;p-&amp;gt;p_limit-&amp;gt;pl_lock);
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1082,6 +1089,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; sysctl_proc_setup(void)
 create_proc_plimit("descriptors",PROC_PID_LIMIT_NOFILE);
 create_proc_plimit("sbsize",PROC_PID_LIMIT_SBSIZE);
 create_proc_plimit("vmemoryuse",PROC_PID_LIMIT_AS);
+create_proc_plimit("maxlwp",PROC_PID_LIMIT_NTHR);
 
 #undef create_proc_plimit
 
Index: kern/kern_synch.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_synch.c,v
retrieving revision 1.301
diff -u -p -u -r1.301 kern_synch.c
--- kern/kern_synch.c21 Apr 2012 22:38:25 -00001.301
+++ kern/kern_synch.c23 May 2012 23:19:34 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -96,6 +96,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; __KERNEL_RCSID(0, "$NetBSD: kern_synch.c
 #include &amp;lt;sys/lwpctl.h&amp;gt;
 #include &amp;lt;sys/atomic.h&amp;gt;
 #include &amp;lt;sys/simplelock.h&amp;gt;
+#include &amp;lt;sys/uidinfo.h&amp;gt;
+#include &amp;lt;sys/kauth.h&amp;gt;
 #include &amp;lt;sys/syslog.h&amp;gt;
 
 #include &amp;lt;uvm/uvm_extern.h&amp;gt;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -805,6 +807,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; lwp_exit_switchaway(lwp_t *l)
 LOCKDEBUG_BARRIER(NULL, 0);
 
 kstack_check_magic(l);
+chglwpcnt(kauth_cred_geteuid(l-&amp;gt;l_cred), -1);
 
 /* Count time spent in current system call */
 SYSCALL_TIME_SLEEP(l);
Index: kern/kern_uidinfo.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_uidinfo.c,v
retrieving revision 1.5
diff -u -p -u -r1.5 kern_uidinfo.c
--- kern/kern_uidinfo.c22 Mar 2009 00:49:13 -00001.5
+++ kern/kern_uidinfo.c23 May 2012 23:19:34 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -43,6 +43,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; __KERNEL_RCSID(0, "$NetBSD: kern_uidinfo
 #include &amp;lt;sys/proc.h&amp;gt;
 #include &amp;lt;sys/atomic.h&amp;gt;
 #include &amp;lt;sys/uidinfo.h&amp;gt;
+#include &amp;lt;sys/sysctl.h&amp;gt;
+#include &amp;lt;sys/kauth.h&amp;gt;
 #include &amp;lt;sys/cpu.h&amp;gt;
 
 static SLIST_HEAD(uihashhead, uidinfo) *uihashtbl;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -50,6 +52,79 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static u_long uihash;
 
 #defineUIHASH(uid)(&amp;amp;uihashtbl[(uid) &amp;amp; uihash])
 
+static int
+sysctl_kern_uidinfo_cnt(SYSCTLFN_ARGS)
+{  
+static const struct {
+const char *name;
+u_int value;
+} nv[] = {
+#define _MEM(n) { # n, offsetof(struct uidinfo, ui_ ## n) }
+_MEM(proccnt),
+_MEM(lwpcnt),
+_MEM(lockcnt),
+_MEM(sbsize),
+#undef _MEM
+};
+
+for (size_t i = 0; i &amp;lt; __arraycount(nv); i++)
+if (strcmp(nv[i].name, rnode-&amp;gt;sysctl_name) == 0) {
+uint64_t cnt;
+struct sysctlnode node = *rnode;
+struct uidinfo *uip;
+
+node.sysctl_data = &amp;amp;cnt;
+uip = uid_find(kauth_cred_geteuid(l-&amp;gt;l_cred));
+
+*(uint64_t *)node.sysctl_data = 
+    *(u_long *)((char *)uip + nv[i].value);
+
+return sysctl_lookup(SYSCTLFN_CALL(&amp;amp;node));
+}
+
+return EINVAL;
+}
+
+static void
+sysctl_kern_uidinfo_setup(void)
+{
+const struct sysctlnode *rnode, *cnode;
+struct sysctllog *kern_uidinfo_sysctllog;
+
+kern_uidinfo_sysctllog = NULL;
+sysctl_createv(&amp;amp;kern_uidinfo_sysctllog, 0, NULL, &amp;amp;rnode,
+       CTLFLAG_PERMANENT,
+       CTLTYPE_NODE, "uidinfo",
+       SYSCTL_DESCR("Resource usage per uid"),
+       NULL, 0, NULL, 0,
+       CTL_KERN, CTL_CREATE, CTL_EOL);
+
+sysctl_createv(&amp;amp;kern_uidinfo_sysctllog, 0, &amp;amp;rnode, &amp;amp;cnode,
+       CTLFLAG_PERMANENT,
+       CTLTYPE_QUAD, "proccnt",
+       SYSCTL_DESCR("Number of processes for the current user"),
+       sysctl_kern_uidinfo_cnt, 0, NULL, 0,
+       CTL_CREATE, CTL_EOL);
+sysctl_createv(&amp;amp;kern_uidinfo_sysctllog, 0, &amp;amp;rnode, &amp;amp;cnode,
+       CTLFLAG_PERMANENT,
+       CTLTYPE_QUAD, "lwpcnt",
+       SYSCTL_DESCR("Number of lwps for the current user"),
+       sysctl_kern_uidinfo_cnt, 0, NULL, 0,
+       CTL_CREATE, CTL_EOL);
+sysctl_createv(&amp;amp;kern_uidinfo_sysctllog, 0, &amp;amp;rnode, &amp;amp;cnode,
+       CTLFLAG_PERMANENT,
+       CTLTYPE_QUAD, "lockcnt",
+       SYSCTL_DESCR("Number of locks for the current user"),
+       sysctl_kern_uidinfo_cnt, 0, NULL, 0,
+       CTL_CREATE, CTL_EOL);
+sysctl_createv(&amp;amp;kern_uidinfo_sysctllog, 0, &amp;amp;rnode, &amp;amp;cnode,
+       CTLFLAG_PERMANENT,
+       CTLTYPE_QUAD, "sbsize",
+       SYSCTL_DESCR("Socket buffers used for the current user"),
+       sysctl_kern_uidinfo_cnt, 0, NULL, 0,
+       CTL_CREATE, CTL_EOL);
+}
+
 void
 uid_init(void)
 {
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -68,6 +143,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; uid_init(void)
  * sbreserve() expects it available from interrupt context.
  */
 (void)uid_find(0);
+sysctl_kern_uidinfo_setup();
 }
 
 struct uidinfo *
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -126,6 +202,22 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; chgproccnt(uid_t uid, int diff)
 return proccnt;
 }
 
+/*
+ * Change the count associated with number of lwps
+ * a given user is using.
+ */
+int
+chglwpcnt(uid_t uid, int diff)
+{
+struct uidinfo *uip;
+long lwpcnt;
+
+uip = uid_find(uid);
+lwpcnt = atomic_add_long_nv(&amp;amp;uip-&amp;gt;ui_lwpcnt, diff);
+KASSERT(lwpcnt &amp;gt;= 0);
+return lwpcnt;
+}
+
 int
 chgsbsize(struct uidinfo *uip, u_long *hiwat, u_long to, rlim_t xmax)
 {
Index: kern/sys_aio.c
===================================================================
RCS file: /cvsroot/src/sys/kern/sys_aio.c,v
retrieving revision 1.37
diff -u -p -u -r1.37 sys_aio.c
--- kern/sys_aio.c17 Feb 2011 19:02:50 -00001.37
+++ kern/sys_aio.c23 May 2012 23:19:34 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -211,7 +211,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; aio_procinit(struct proc *p)
 return EAGAIN;
 }
 error = lwp_create(curlwp, p, uaddr, 0, NULL, 0, aio_worker,
-    NULL, &amp;amp;l, curlwp-&amp;gt;l_class);
+    NULL, &amp;amp;l, curlwp-&amp;gt;l_class, 1);
 if (error != 0) {
 uvm_uarea_free(uaddr);
 aio_exit(p, aio);
Index: kern/sys_lwp.c
===================================================================
RCS file: /cvsroot/src/sys/kern/sys_lwp.c,v
retrieving revision 1.53
diff -u -p -u -r1.53 sys_lwp.c
--- kern/sys_lwp.c19 Feb 2012 21:06:56 -00001.53
+++ kern/sys_lwp.c23 May 2012 23:19:34 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -101,7 +101,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; sys__lwp_create(struct lwp *l, const str
 }
 
 error = lwp_create(l, p, uaddr, SCARG(uap, flags) &amp;amp; LWP_DETACHED,
-    NULL, 0, p-&amp;gt;p_emul-&amp;gt;e_startlwp, newuc, &amp;amp;l2, l-&amp;gt;l_class);
+    NULL, 0, p-&amp;gt;p_emul-&amp;gt;e_startlwp, newuc, &amp;amp;l2, l-&amp;gt;l_class, 1);
 if (__predict_false(error)) {
 uvm_uarea_free(uaddr);
 kmem_free(newuc, sizeof(ucontext_t));
Index: sys/lwp.h
===================================================================
RCS file: /cvsroot/src/sys/sys/lwp.h,v
retrieving revision 1.160
diff -u -p -u -r1.160 lwp.h
--- sys/lwp.h19 Feb 2012 21:06:58 -00001.160
+++ sys/lwp.h23 May 2012 23:19:35 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -210,6 +210,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; LIST_HEAD(lwplist, lwp);/* A list of L
 #ifdef _KERNEL
 extern struct lwplistalllwp;/* List of all LWPs. */
 extern lwp_tlwp0;/* LWP for proc0. */
+extern intmaxlwp;/* max number of lwps */
 #endif
 
 /* These flags are kept in l_flag. */
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -409,7 +410,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; lwp_eprio(lwp_t *l)
 }
 
 int lwp_create(lwp_t *, struct proc *, vaddr_t, int,
-    void *, size_t, void (*)(void *), void *, lwp_t **, int);
+    void *, size_t, void (*)(void *), void *, lwp_t **, int, int);
 
 /*
  * XXX _MODULE
Index: sys/resource.h
===================================================================
RCS file: /cvsroot/src/sys/sys/resource.h,v
retrieving revision 1.32
diff -u -p -u -r1.32 resource.h
--- sys/resource.h14 May 2011 17:57:05 -00001.32
+++ sys/resource.h23 May 2012 23:19:35 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -90,9 +90,10 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; structrusage {
 #defineRLIMIT_SBSIZE9/* maximum size of all socket buffers */
 #defineRLIMIT_AS10/* virtual process size (inclusive of mmap) */
 #defineRLIMIT_VMEMRLIMIT_AS/* common alias */
+#defineRLIMIT_NTHR11/* number of threads */
 
 #if defined(_NETBSD_SOURCE)
-#defineRLIM_NLIMITS11/* number of resource limits */
+#defineRLIM_NLIMITS12/* number of resource limits */
 #endif
 
 #defineRLIM_INFINITY(~((u_quad_t)1 &amp;lt;&amp;lt; 63))/* no limit */
Index: sys/sysctl.h
===================================================================
RCS file: /cvsroot/src/sys/sys/sysctl.h,v
retrieving revision 1.199
diff -u -p -u -r1.199 sysctl.h
--- sys/sysctl.h27 Jan 2012 19:48:41 -00001.199
+++ sys/sysctl.h23 May 2012 23:19:36 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -266,7 +266,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; struct ctlname {
 #defineKERN_SYSVIPC82/* node: SysV IPC parameters */
 #defineKERN_BOOTTIME83/* struct: time kernel was booted */
 #defineKERN_EVCNT84/* struct: evcnts */
-#defineKERN_MAXID85/* number of valid kern ids */
+#defineKERN_MAXLWP85/* int: maxlwp */
+#defineKERN_MAXID86/* number of valid kern ids */
 
 
 #defineCTL_KERN_NAMES { \
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -355,6 +356,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; struct ctlname {
 { "sysvipc", CTLTYPE_STRUCT }, \
 { "boottime", CTLTYPE_STRUCT }, \
 { "evcnt", CTLTYPE_STRUCT }, \
+{ "maxlwp", CTLTYPE_INT }, \
 }
 
 /*
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -975,6 +977,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; struct evcnt_sysctl {
 #definePROC_PID_LIMIT_NOFILE(RLIMIT_NOFILE+1)
 #definePROC_PID_LIMIT_SBSIZE(RLIMIT_SBSIZE+1)
 #definePROC_PID_LIMIT_AS(RLIMIT_AS+1)
+#definePROC_PID_LIMIT_NTHR(RLIMIT_NTHR+1)
 #definePROC_PID_LIMIT_MAXID (RLIM_NLIMITS+1)
 
 #definePROC_PID_LIMIT_NAMES { \
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -990,6 +993,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; struct evcnt_sysctl {
 { "descriptors", CTLTYPE_NODE }, \
 { "sbsize", CTLTYPE_NODE }, \
 { "vmemoryuse", CTLTYPE_NODE }, \
+{ "maxlwp", CTLTYPE_NODE }, \
 }
 /* for each type, either hard or soft value */
 #definePROC_PID_LIMIT_TYPE_SOFT1
Index: sys/uidinfo.h
===================================================================
RCS file: /cvsroot/src/sys/sys/uidinfo.h,v
retrieving revision 1.2
diff -u -p -u -r1.2 uidinfo.h
--- sys/uidinfo.h14 Oct 2008 09:16:32 -00001.2
+++ sys/uidinfo.h23 May 2012 23:19:36 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -43,11 +43,13 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; struct uidinfo {
 SLIST_ENTRY(uidinfo) ui_hash;
 uid_tui_uid;
 u_longui_proccnt;/* Number of processes */
+u_longui_lwpcnt;/* Number of lwps */
 u_longui_lockcnt;/* Number of locks */
 u_longui_sbsize;/* Socket buffer size */
 };
 
 intchgproccnt(uid_t, int);
+intchglwpcnt(uid_t, int);
 intchgsbsize(struct uidinfo *, u_long *, u_long, rlim_t);
 struct uidinfo *uid_find(uid_t);
 voiduid_init(void);

&lt;/pre&gt;</description>
    <dc:creator>Christos Zoulas</dc:creator>
    <dc:date>2012-05-23T23:37:19</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42122">
    <title>mlockall() and small memory systems</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42122</link>
    <description>&lt;pre&gt;In the regular sparc test runs on qemu the emulated sparc machine only
has 32MB of ram. In this setup the /usr/tests/lib/libc/sys/t_mincore test
"mincore_resid" fails. If we allow qemu ot provide more memory, the test
succeeds.

The part of the test that fails in "low" memory environments is:

An anonymous mmap of 128 pages size is created:

        addr = mmap(NULL, npgs * page, PROT_READ | PROT_WRITE,
            MAP_ANON | MAP_PRIVATE, -1, (off_t)0);

Nothing in this mapping is touched, so nothing gets paged in/modified.
Via mincore() the test now validates that 0 of the mapped pages are
resident. So far, this works.

Now a mlockall(MCL_CURRENT|MCL_FUTURE) call is done.

The test now expects all pages in the above mapping to be resident and
again checks via mincore().

This is the part where the test fails: some of the pages are not resident.

I do believe this is not a bug in the sparc pmap.

Am I wrong? Is this an MI bug? Or a bogus test?

Martin

&lt;/pre&gt;</description>
    <dc:creator>Martin Husemann</dc:creator>
    <dc:date>2012-05-23T16:15:32</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42111">
    <title>Breaking out of the emulation dir</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42111</link>
    <description>&lt;pre&gt;What's the suggested method for breaking out of the emulation directory?
I want &amp;lt;EMULDIR&amp;gt;/opt/tivoli/tsm/client/ba/bin/dsm.opt to be a symlink to
&amp;lt;no-emulation&amp;gt;/usr/pkg/etc/tsm/dsm.opt.
I can achieve this with a considerable amount of ../, but that amount depends
on the value of &amp;lt;EMULDIR&amp;gt;, more precisely, it's expanded value, which happens
to be /usr/pkg/emul/linux32 in the case in question.
I was thinking about a /emul/none -&amp;gt; / symlink.

I'm not sure how the behaviour of the emulation sort-of-chroot is defined
to be if it, for example, looks up /usr/local/foo/bar and e.g. a "real"
/usr/local (or /usr/local/foo) exists, but /usr/local/foo
(or /usr/local/foo/bar) doesn't.
Is this documented anywhere? Has it change since 4.0?

&lt;/pre&gt;</description>
    <dc:creator>Edgar Fuß</dc:creator>
    <dc:date>2012-05-21T13:44:51</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42109">
    <title>"bad tag" message</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42109</link>
    <description>&lt;pre&gt;What does this mean:

May 21 15:32:12 trave /netbsd: /emul/linux32/usr/bin/dsmc: bad tag 1: [5 4, 2 4, SuSE  PaX]

&lt;/pre&gt;</description>
    <dc:creator>Edgar Fuß</dc:creator>
    <dc:date>2012-05-21T13:36:28</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42101">
    <title>libquota units</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42101</link>
    <description>&lt;pre&gt;I was somewhat surprised to learn that with libquota, qv_usage etc.
were still in units of what someone called "a constant of nature introduced
by DEC", e.g., 512-byte "blocks".
Given the fields are 64 bits wide, I would have expected them to be in
bytes instead, but there are probably reasons not do do that.
So, I would at least expect that to be documented or machine-readable.

&lt;/pre&gt;</description>
    <dc:creator>Edgar Fuß</dc:creator>
    <dc:date>2012-05-20T16:10:04</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42096">
    <title>accessing another process' resource limits</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42096</link>
    <description>&lt;pre&gt;Is there an interface for reading (or even writing) another process' ulimits?

&lt;/pre&gt;</description>
    <dc:creator>Edgar Fuß</dc:creator>
    <dc:date>2012-05-19T16:51:48</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42082">
    <title>Editing (new) quota for a new user</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42082</link>
    <description>&lt;pre&gt;I just started to play around with the new quota system.
I tried to set quotas for a user that didn't own any files on the
file system in question.
With an "interactive" edquota, I got
edquota: /export/test (ufs/ffs quota v2):
: bad format
With a edquota -h ... -s ..., I got a zero exit status, a following
"interactive" edquota showing what I entered, but repquota not showing
anything for that user.

When I allocate a file for that user, edquota -h ... -s ... works, but an
"interactive" edquota throws the same error and disables that user's quota.

Is this expected behaviour?

&lt;/pre&gt;</description>
    <dc:creator>Edgar Fuß</dc:creator>
    <dc:date>2012-05-14T15:58:46</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42065">
    <title>Crashes in uaudio</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42065</link>
    <description>&lt;pre&gt;Hi,

I see kernel crashes when playing a sample via a USB audio device:

  uaudio0 at uhub0 port 2 configuration 1 interface 0
  uaudio0: Logitech Logitech USB Headset, rev 1.10/10.13, addr 3
  uaudio0: ignored input endpoint of type adaptive
  uaudio_identify_as: too much tSamFreq: 5
  uaudio_identify_as: too much tSamFreq: 5
  uaudio0: audio rev 1.00
  audio1 at uaudio0: full duplex, playback, capture, independent

note the "uaudio_identify_as: too much tSamFreq: 5" lines here.  With extra
debug printf(), I can see that the attach adds sample rates of 8000 and 11025
before the test added in r1.130 of uaudio.c [*] applies and breaks out of the
loop.  The problem is that the number of frequencies is still set to the old
value (i.e., frequency_type = 5) and when playing any audio, the frequency
list is looped over in auconv_rateconv_check_rates().  With extra debug there,
I see:

  auconv_rateconv_check_rates: sample_rate = 44100
  frequency[0] = 8000, minrate = 8000, maxrate = 8000
  frequency[1] = 8000, minrate = 8000, maxrate = 11025
  frequency[2] = 8000, minrate = 8000, maxrate = 778925428
  frequency[3] = 8000, minrate = 8000, maxrate = 1694498816
  frequency[4] = 8000, minrate = 8000, maxrate = 1694498816

this causes it to set a sample rate of 1694498816 (junk value).  This then
causes uaudio_chan_ptransfer() to try and add 67M bytes to the 64K channel
buffer.  The machine crashes when writing past the end of the channel buffer
into an unmapped page.

The simple solution here is to set frequency_type to 2 because we aborted
the loop in the test at line 1852 of src/sys/dev/usb/uaudio.c.  But, the
value 2 is significant here, because the gcc -O3 check notices that we
fall off the end of the tSamFreq[] array when calling UA_GETSAMP() (defined
in src/sys/dev/usb/uaudioreg.h) with a second parameter not 0 or 1.  But,
with this check commented out, I see that all 5 sample rates (8000, 11025,
22050, 44100, and 48000) are added.  So, it seems that we are overwriting
the end of usb_audio_streaming_type1_descriptor for every descriptor where
the number of rates is more than 2.  The problem is that we only notice when
we come to read.  So, I think that we should set:

  uBytetSamFreq[3*AUFMT_MAX_FREQUENCIES];

in the usb_audio_streaming_type1_descriptor definition (uaudioreg.h), make
sure that we only copy the correct maximum number of bytes when setting it
up, and remove the test at line 1852 of uaudio.c.  We probably should also
set:

  auf-&amp;gt;frequency_type = AUFMT_MAX_FREQUENCIES;

in the test at line 1846, just in case we do meet a device which advertises
more frequencies than we can handle (if we don't, we could end up reading
memory after the end of the usb_audio_streaming_type1_descriptor).

However, I'm not 100% sure that I've not missed anything else here.  Comments?

Thanks,

J

[*] http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/usb/uaudio.c.diff?r1=1.129&amp;amp;r2=1.130

&lt;/pre&gt;</description>
    <dc:creator>Julian Coleman</dc:creator>
    <dc:date>2012-05-11T13:42:11</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42063">
    <title>choosing the file system block size</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42063</link>
    <description>&lt;pre&gt;Is there some utility, that, given a file system with real data on it,
will compute the optimum file system block size for that data set?

If not, is it a reasonable assumption that the space allocated to a file
will be the file's data size, rounded up to the fragment size?

&lt;/pre&gt;</description>
    <dc:creator>Edgar Fuß</dc:creator>
    <dc:date>2012-05-11T10:21:31</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42055">
    <title>RAIDframe performance vs. stripe size</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42055</link>
    <description>&lt;pre&gt;Does anyone have some real-world experience with RAIDframe (Level 5)
performance vs. stripe size?
My impression would be that, with a not to large number of components (4+1,
in my case), chances are rather low to spread simultaneous accesses to
different physical discs, so the best choice seems the file system's block
size.
On the other hand, the Carnegie Mellon paper suggests something around
1/2*(througput)*(access time),
which would amount to more than a Megabyte with my discs.
So, what are the real-world benefits of a large stripe size? My application
are home and mail directories exported via NFS.

&lt;/pre&gt;</description>
    <dc:creator>Edgar Fuß</dc:creator>
    <dc:date>2012-05-10T15:46:38</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42051">
    <title>Broken builds</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42051</link>
    <description>&lt;pre&gt;Does anybody understand why this happens on several archs in -current?

http://releng.netbsd.org/builds/HEAD/201205041410Z/amiga.build.failed

dependall ===&amp;gt; sys/modules/hfs
WARNING: ioconf is an experimental feature
WARNING: pseudo-root is an experimental feature
dependall ===&amp;gt; sys/modules/iic
WARNING: ioconf is an experimental feature
/home/builds/ab/HEAD/src/sys/dev/i2c/files.i2c:3: file system or option `I2C_SCAN' already defined
/home/builds/ab/HEAD/src/sys/dev/i2c/files.i2c:4: attribute `i2cbus' already defined
/home/builds/ab/HEAD/src/sys/dev/i2c/files.i2c:5: attribute `i2cexec' already defined
/home/builds/ab/HEAD/src/sys/dev/i2c/files.i2c:7: redefinition of `iic'
/home/builds/ab/HEAD/src/sys/dev/i2c/files.i2c:8: redefinition of `iic'
/home/builds/ab/HEAD/src/sys/dev/i2c/files.i2c:9: duplicate file dev/i2c/i2c.c
/home/builds/ab/HEAD/src/sys/dev/i2c/files.i2c:9: here is the original definition
/home/builds/ab/HEAD/src/sys/dev/i2c/files.i2c:10: duplicate file dev/i2c/i2c_exec.c
/home/builds/ab/HEAD/src/sys/dev/i2c/files.i2c:10: here is the original definition
/home/builds/ab/HEAD/src/sys/dev/i2c/files.i2c:11: duplicate file dev/i2c/i2c_subr.c
...


Martin

&lt;/pre&gt;</description>
    <dc:creator>Martin Husemann</dc:creator>
    <dc:date>2012-05-05T09:46:01</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42044">
    <title>broken puffs atf</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42044</link>
    <description>&lt;pre&gt;Hi

I recently committeda fix that broke two puffs tests:
src/sys/kern/vfs_syscalls.c 1.451-1.454

http://releng.netbsd.org/b5reports/i386/build/2012.04.30.13.47.52/test.html#fail
ed-tcs-summary

I have trouble figuring what goes wrong. Both in mountfuzz7 and mountfuzz8, it
panics "mount: lost mount" in src/sys/kern/vfs_mount.c:mount_checkdirs()

The offending change is below. Basically, it moved from the situation where
mount_checkdirs() founds v_usecount ==1 (and it just returns) to the situation
where v_usecount  == 2 (it calls VFS_ROOT(olddp-&amp;gt;v_mountedhere, &amp;amp;newdp) and
panics) 

Any suggestion on how to fix that proprely? I call vref(vp) before
mount_domount() sothat I can acccess vp-&amp;gt;v_mountedhere after mount_domount sets
vp to NULL, but it seems this is not The Right Way.

Index: vfs_syscalls.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_syscalls.c,v
retrieving revision 1.451
retrieving revision 1.454
diff -U4 -r1.451 -r1.454
--- vfs_syscalls.c      17 Apr 2012 19:15:15 -0000      1.451
+++ vfs_syscalls.c      30 Apr 2012 10:05:12 -0000      1.454
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -457,21 +457,32 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
                *retval = data_len;
        } else if (flags &amp;amp; MNT_UPDATE) {
                error = mount_update(l, vp, path, flags, data_buf, &amp;amp;data_len);
        } else {
+               struct vnode *svp;
+
+               /* Save vp as mount_domount sets it to NULL */
+               vref(vp);
+               svp = vp;       
+
                /* Locking is handled internally in mount_domount(). */
                KASSERT(vfsopsrele == true);
                error = mount_domount(l, &amp;amp;vp, vfsops, path, flags, data_buf,
                    &amp;amp;data_len);
                vfsopsrele = false;
 
                if ((error == 0) &amp;amp;&amp;amp; (flags &amp;amp; MNT_EXTATTR)) {
-                       if (VFS_EXTATTRCTL(vp-&amp;gt;v_mount, EXTATTR_CMD_START, 
+                       KASSERT(svp-&amp;gt;v_mountedhere != NULL);
+
+                       if (VFS_EXTATTRCTL(svp-&amp;gt;v_mountedhere,
+                                          EXTATTR_CMD_START, 
                                           NULL, 0, NULL) != 0)
                                printf("%s: failed to start extattr",
-                                      vp-&amp;gt;v_mount-&amp;gt;mnt_stat.f_mntonname);
+                                    svp-&amp;gt;v_mountedhere-&amp;gt;mnt_stat.f_mntonname);
                                /* XXX remove flag */
                }
+
+               vrele(svp);
        }
 
     done:
        if (vfsopsrele)


&lt;/pre&gt;</description>
    <dc:creator>Emmanuel Dreyfus</dc:creator>
    <dc:date>2012-05-04T15:12:27</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42035">
    <title>watching dynamic device attachment?</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42035</link>
    <description>&lt;pre&gt;I have an application where I want to watch USB devices come and go.
I've written code basd on usb(4), and it works - but the devices in
question are disks, which show up as, for example,

umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2 targets, 1 lun per target
sd0 at scsibus1 target 0 lun 0: &amp;lt;Generic, External, 2.10&amp;gt; disk fixed

So, I'm wondering if there's some way to watch devices come and go
beyond what /dev/usb gives me (which stops with the umass attachment).
Even some way to inspect the current device tree would help; I can
watch umass attach and then query the tree to see what's underneath it.
I have a fuzzy memory of seeing something that looked like device-tree
data, but the memory's too fuzzy to be of much use here.  kern.drivers
appears to be part of what I'd want, but only part; I'd much rather not
have to scrape dmesg output. :/

The machine in question is currently at 4.0.1.  If this is possible
with a more recent version but not with 4.0.1, I might be able to talk
its admins into switching, but I suspect they'd rather not; it _is_ a
production machine.

/~\ The ASCII  Mouse
\ / Ribbon Campaign
 X  Against HTMLmouse&amp;lt; at &amp;gt;rodents-montreal.org
/ \ Email!     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

&lt;/pre&gt;</description>
    <dc:creator>Mouse</dc:creator>
    <dc:date>2012-05-04T00:01:23</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42023">
    <title>error in sys/cdefs.h ?</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42023</link>
    <description>&lt;pre&gt;While trying to muddle my way through the net80211 module mess, I noticed the 
following line in sys/cdefs.h:

#define       __link_set_entry(set, idx)      (__link_set_begin(set)[idx])

This is the only place where __link_set_begin is referenced in the entire 
source tree, and I think that it really should have been

#define       __link_set_entry(set, idx)      (__link_set_start(set)[idx])

Fortunately, there is also nothing else in the source tree that uses the 
__link_set_entry macro(), so this isn't causing any real pain.  But I think it 
should be corrected before someone does try to use it.


Any reason this should not be changed?


-------------------------------------------------------------------------
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |                          | pgoyette at netbsd.org  |
-------------------------------------------------------------------------

&lt;/pre&gt;</description>
    <dc:creator>Paul Goyette</dc:creator>
    <dc:date>2012-04-30T19:06:27</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42005">
    <title>ENOATTR vs ENODATA</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42005</link>
    <description>&lt;pre&gt;Hi

There is a choice to be made about returing ENOATTR or ENODATA  when we
do not find an extended attribute. 

Here are the existing behaviors:

1) return ENOATTR, while ENODATA is defined and has other usages: NetBSD
and MacOS X

2) return ENODATA, while ENOATTR is not defined: Linux

3) return ENOATTR, while ENODATA is not defined: FreeBSD

The problem is that some userland program may test (errno == ENODATA)
and get a different semantic on NetBSD and Linux. glusterfs does that,
for instance.

It seems there is no standard about this. OpenGroup only defines
ENODATA, but for another usage (STREAM). 

In order to get the broader compatibility, I suggest patching our
errno.h to define ENOATTR as ENODATA. Opinions?

Index: sys/errno.h
===================================================================
RCS file: /cvsroot/src/sys/sys/errno.h,v
retrieving revision 1.39
diff -U 4 -r1.39 errno.h
--- sys/errno.h 31 Oct 2006 00:38:07 -0000      1.39
+++ sys/errno.h 30 Apr 2012 09:17:43 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -164,9 +164,9 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
 #define ENOSTR         91              /* Not a STREAM */
 #define ETIME          92              /* STREAM ioctl timeout */
 
 /* File system extended attribute errors */
-#define        ENOATTR         93              /* Attribute not found
*/
+#define        ENOATTR         ENODATA         /* Attribute not found
*/
 
 /* Realtime, XSI STREAMS option errors */
 #define        EMULTIHOP       94              /* Multihop attempted */
 #define        ENOLINK         95              /* Link has been severed
*/
 
 

&lt;/pre&gt;</description>
    <dc:creator>Emmanuel Dreyfus</dc:creator>
    <dc:date>2012-04-30T09:20:42</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42002">
    <title>How to get a struct mount</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/42002</link>
    <description>&lt;pre&gt;Hello

I hace a filesystem mounted on /foo how do I retreive its struct mount?

Using namei_simple_user(), I can get a vnode for /foo but its v_mount is
the one for the root filesystem. Looking up /foo/ produces an error.
(bad address). 

How do I cross the mount point and get a vnode for the monted filesystem
root? Or should I get the struct mount by another method?



&lt;/pre&gt;</description>
    <dc:creator>Emmanuel Dreyfus</dc:creator>
    <dc:date>2012-04-30T00:47:08</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/41996">
    <title>Removal of POOL_DIAGNOSTIC</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/41996</link>
    <description>&lt;pre&gt;Hi,

Unless anyone objects, I will remove POOL_DIAGNOSTIC.  Since default
allocator is pool_cache(9), in post-netbsd-5 it is not really useful
nor really used (note that after kmem(9) changes it does not compile).
For pool_cache(9), existing consistency checks and safeguards under
DEBUG/DIAGNOSTIC are fairly effective.

http://www.netbsd.org/~rmind/pool_diag.diff

&lt;/pre&gt;</description>
    <dc:creator>Mindaugas Rasiukevicius</dc:creator>
    <dc:date>2012-04-28T23:51:08</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/41992">
    <title>UFS extended attributes broken</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/41992</link>
    <description>&lt;pre&gt;Hi

On -current and netbsd-6, starting extended attributes is broken. I just
fixed a NULL pointer reference that caused a panic, but there is another
problem.

ufs_extattr_autostart() needs to lookup .attribute/user and
.attribute/system directories on the top of the filesystem. It is done
through ufs_extattr_lookup(),which does this:

        memset(&amp;amp;cnp, 0, sizeof(cnp));
        cnp.cn_nameiop = LOOKUP;
        cnp.cn_flags = ISLASTCN | lockparent;
        cnp.cn_cred = l-&amp;gt;l_cred;
        cnp.cn_nameptr = pnbuf;
        error = copystr(dirname, pnbuf, MAXPATHLEN, &amp;amp;cnp.cn_namelen);
        if (error) {
        /* removed error handling for clarty sake */
        }
        cnp.cn_namelen--;       /* trim nul termination */
        vargs.a_desc = NULL;
        vargs.a_dvp = start_dvp;
        vargs.a_vpp = &amp;amp;target_vp;
        vargs.a_cnp = &amp;amp;cnp;
        error = ufs_lookup(&amp;amp;vargs);
 
ufs_lookup now returns ENOENT while the directory exists. It did not do
that on netbsd-5. Any idea of what when wrong?

&lt;/pre&gt;</description>
    <dc:creator>Emmanuel Dreyfus</dc:creator>
    <dc:date>2012-04-28T17:36:08</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/41982">
    <title>4K sector size (again) &amp; cgd</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/41982</link>
    <description>&lt;pre&gt;Hello,

   I bought a new disk which included a warning label along the line of
"Warning: Uses 4K sector size!".

   I plugged it in, and NetBSD identifies it as:

umass0 at uhub6 port 1 configuration 1 interface 0
umass0: JMicron USB to ATA/ATAPI bridge, rev 2.00/1.00, addr 2
umass0: using SCSI over Bulk-Only
scsibus0 at umass0: 2 targets, 1 lun per target
sd0 at scsibus0 target 0 lun 0: &amp;lt;WDC WD75, 00AARX-00N0YB0, &amp;gt; disk fixed
sd0: 698 GB, 16383 cyl, 16 head, 63 sec, 4096 bytes/sect x 183143646 sectors

   disklabel identifies it as:
------------------------------
# /dev/rsd0d:
type: SCSI
disk: 00AARX-00N0YB0
label: fictitious
flags:
bytes/sector: 4096
sectors/track: 63
tracks/cylinder: 16
sectors/cylinder: 1008
cylinders: 16383
total sectors: 183143646
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # microseconds
track-to-track seek: 0  # microseconds
drivedata: 0
[---]
------------------------------

   So far so good; I can add a slice, and run newfs on the slice.
However, I want to run cgd on it, and that's where the problems start. I
can configure a cgd device on the sd0a, but "disklabel cgd3" returns:

------------------------------
# /dev/rcgd3d:
type: cgd
disk: cgd
label: default label
flags:
bytes/sector: 512
sectors/track: 2048
tracks/cylinder: 1
sectors/cylinder: 2048
cylinders: 89425
total sectors: 183143646
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # microseconds
track-to-track seek: 0  # microseconds
drivedata: 0

4 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 a: 183143646         0     4.2BSD      0     0     0  # (Cyl.      0 -
 89425*)
 d: 183143646         0     4.2BSD      0     0     0  # (Cyl.      0 -
 89425*)
disklabel: boot block size 0
disklabel: super block size 0
disklabel: partitions a and d overlap
------------------------------

   Whatever I try to do at this point, writing of the disklabel fails
(which I sort of expect, considering the discrepancies in the disklabel
outputs).

   cgd.c has:

------------------------------
/*
 * XXX here we should probe the underlying device.  If we
 *     are accessing a partition of type RAW_PART, then
 *     we should populate our initial geometry with the
 *     geometry that we discover from the device.
 */
pdg = &amp;amp;cs-&amp;gt;sc_dksc.sc_geom;
pdg-&amp;gt;pdg_secsize = DEV_BSIZE;
pdg-&amp;gt;pdg_ntracks = 1;
pdg-&amp;gt;pdg_nsectors = 1024 * (1024 / pdg-&amp;gt;pdg_secsize);
pdg-&amp;gt;pdg_ncylinders = cs-&amp;gt;sc_dksc.sc_size / pdg-&amp;gt;pdg_nsectors;
------------------------------

  .. which looks suspiciously ... suspicious. I'm assuming that fixing
that will increase the chances of the cgd device working properly on
this disk.

   Just so I don't waste a bunch of time poking in the wrong places; am
I looking at - what is likely - the problem?

   With regards to probing the underlying device: Any helpful pointers
to prior art is appreciated.

&lt;/pre&gt;</description>
    <dc:creator>Jan Danielsson</dc:creator>
    <dc:date>2012-04-28T01:52:38</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.os.netbsd.devel.kernel/41977">
    <title>Modularizing net80211 (was: link_set info needed)</title>
    <link>http://comments.gmane.org/gmane.os.netbsd.devel.kernel/41977</link>
    <description>&lt;pre&gt;Folks,

I would like to commit the attached patches to modularize the net80211 
code.  The changes include:

1. Protecting the inclusion of "opt_inet.h" with #ifdef _KERNEL
2. Removing CTLFLAG_PERMANENT from all of the sysctl(8) variables
3. Replacing the use of link_set with direct calls to all of the
    crypto/auth initializers.

At a future time, I propose to split the crypto/auth stuff out into 
their own modules, but that will require a bit more planning and a lot 
more testing.  :)

I have tested the attached changes on my home system, using a modular 
if_rum(4) driver (which I plan to commit separately).


Comments/feedback welcomed...



-------------------------------------------------------------------------
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |                          | pgoyette at netbsd.org  |
-------------------------------------------------------------------------Index: ieee80211.c
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211.c,v
retrieving revision 1.53
diff -u -p -r1.53 ieee80211.c
--- ieee80211.c5 Apr 2010 07:22:24 -00001.53
+++ ieee80211.c27 Apr 2012 12:34:49 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -43,7 +43,9 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; __KERNEL_RCSID(0, "$NetBSD: ieee80211.c,
  * IEEE 802.11 generic handler
  */
 
+#if defined(_KERNEL_OPT)
 #include "opt_inet.h"
+#endif
 
 #include &amp;lt;sys/param.h&amp;gt;
 #include &amp;lt;sys/systm.h&amp;gt; 
Index: ieee80211_crypto.c
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211_crypto.c,v
retrieving revision 1.15
diff -u -p -r1.15 ieee80211_crypto.c
--- ieee80211_crypto.c23 May 2011 15:37:36 -00001.15
+++ ieee80211_crypto.c27 Apr 2012 12:34:49 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -39,7 +39,9 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; __FBSDID("$FreeBSD: src/sys/net80211/iee
 __KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto.c,v 1.15 2011/05/23 15:37:36 drochner Exp $");
 #endif
 
+#if defined(_KERNEL_OPT)
 #include "opt_inet.h"
+#endif
 
 /*
  * IEEE 802.11 generic crypto support.
Index: ieee80211_input.c
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211_input.c,v
retrieving revision 1.72
diff -u -p -r1.72 ieee80211_input.c
--- ieee80211_input.c31 Dec 2011 20:41:58 -00001.72
+++ ieee80211_input.c27 Apr 2012 12:34:49 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -39,7 +39,9 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; __FBSDID("$FreeBSD: src/sys/net80211/iee
 __KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.72 2011/12/31 20:41:58 christos Exp $");
 #endif
 
+#if defined(_KERNEL_OPT)
 #include "opt_inet.h"
+#endif
 
 #ifdef __NetBSD__
 #endif /* __NetBSD__ */
Index: ieee80211_ioctl.c
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211_ioctl.c,v
retrieving revision 1.57
diff -u -p -r1.57 ieee80211_ioctl.c
--- ieee80211_ioctl.c31 Dec 2011 20:41:58 -00001.57
+++ ieee80211_ioctl.c27 Apr 2012 12:34:50 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -43,8 +43,10 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; __KERNEL_RCSID(0, "$NetBSD: ieee80211_io
  * IEEE 802.11 ioctl support (FreeBSD-specific)
  */
 
+#if defined(_KERNEL_OPT)
 #include "opt_inet.h"
 #include "opt_compat_netbsd.h"
+#endif
 
 #include &amp;lt;sys/endian.h&amp;gt;
 #include &amp;lt;sys/param.h&amp;gt;
Index: ieee80211_netbsd.c
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211_netbsd.c,v
retrieving revision 1.20
diff -u -p -r1.20 ieee80211_netbsd.c
--- ieee80211_netbsd.c19 Nov 2011 22:51:25 -00001.20
+++ ieee80211_netbsd.c27 Apr 2012 12:34:50 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -40,6 +40,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; __KERNEL_RCSID(0, "$NetBSD: ieee80211_ne
 #include &amp;lt;sys/kernel.h&amp;gt;
 #include &amp;lt;sys/systm.h&amp;gt; 
 #include &amp;lt;sys/mbuf.h&amp;gt;   
+#include &amp;lt;sys/module.h&amp;gt;
 #include &amp;lt;sys/proc.h&amp;gt;
 #include &amp;lt;sys/sysctl.h&amp;gt;
 #include &amp;lt;sys/once.h&amp;gt;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -72,6 +73,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int ieee80211_sysctl_node(SYSCTLF
 intieee80211_debug = 0;
 #endif
 
+#ifdef NOTYET /* Currently we can't use link sets in modules */
+
 typedef void (*ieee80211_setup_func)(void);
 
 __link_set_decl(ieee80211_funcs, ieee80211_setup_func);
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -81,7 +84,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; ieee80211_init0(void)
 {
 ieee80211_setup_func * const *ieee80211_setup, f;
 
-        __link_set_foreach(ieee80211_setup, ieee80211_funcs) {
+__link_set_foreach(ieee80211_setup, ieee80211_funcs) {
 f = (void*)*ieee80211_setup;
 (*f)();
 }
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -96,6 +99,29 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; ieee80211_init(void)
 
 RUN_ONCE(&amp;amp;ieee80211_init_once, ieee80211_init0);
 }
+#else
+/*
+ * One-time initialization
+ *
+ * XXX Make sure you update the list of CYPTO initializers if new
+ * XXX mechanisms are added!
+ */
+
+void ccmp_register(void);
+void tkip_register(void);
+void wep_register(void);
+void ieee80211_external_auth_setup(void);
+
+void
+ieee80211_init(void)
+{
+
+ccmp_register();
+tkip_register();
+wep_register();
+ieee80211_external_auth_setup();
+}
+#endif/* NOT_YET */
 
 static int
 ieee80211_sysctl_inact(SYSCTLFN_ARGS)
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -146,18 +172,18 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; ieee80211_sysctl_treetop(struct sysctllo
 const struct sysctlnode *rnode;
 
 if ((rc = sysctl_createv(log, 0, NULL, &amp;amp;rnode,
-    CTLFLAG_PERMANENT, CTLTYPE_NODE, "net", NULL,
+    0, CTLTYPE_NODE, "net", NULL,
     NULL, 0, NULL, 0, CTL_NET, CTL_EOL)) != 0)
 goto err;
 
 if ((rc = sysctl_createv(log, 0, &amp;amp;rnode, &amp;amp;rnode,
-    CTLFLAG_PERMANENT, CTLTYPE_NODE, "link",
+    0, CTLTYPE_NODE, "link",
     "link-layer statistics and controls",
     NULL, 0, NULL, 0, PF_LINK, CTL_EOL)) != 0)
 goto err;
 
 if ((rc = sysctl_createv(log, 0, &amp;amp;rnode, &amp;amp;rnode,
-    CTLFLAG_PERMANENT, CTLTYPE_NODE, "ieee80211",
+    0, CTLTYPE_NODE, "ieee80211",
     "IEEE 802.11 WLAN statistics and controls",
     NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL)) != 0)
 goto err;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -181,13 +207,13 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; ieee80211_sysctl_attach(struct ieee80211
 snprintf(num, sizeof(num), "vap%u", ic-&amp;gt;ic_vap);
 
 if ((rc = sysctl_createv(&amp;amp;ic-&amp;gt;ic_sysctllog, 0, &amp;amp;rnode, &amp;amp;rnode,
-    CTLFLAG_PERMANENT, CTLTYPE_NODE, num, SYSCTL_DESCR("virtual AP"),
+    0, CTLTYPE_NODE, num, SYSCTL_DESCR("virtual AP"),
     NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL)) != 0)
 goto err;
 
 /* control debugging printfs */
 if ((rc = sysctl_createv(&amp;amp;ic-&amp;gt;ic_sysctllog, 0, &amp;amp;rnode, &amp;amp;cnode,
-    CTLFLAG_PERMANENT|CTLFLAG_READONLY, CTLTYPE_STRING,
+    CTLFLAG_READONLY, CTLTYPE_STRING,
     "parent", SYSCTL_DESCR("parent device"),
     ieee80211_sysctl_parent, 0, ic, IFNAMSIZ, CTL_CREATE,
     CTL_EOL)) != 0)
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -196,7 +222,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; ieee80211_sysctl_attach(struct ieee80211
 #ifdef IEEE80211_DEBUG
 /* control debugging printfs */
 if ((rc = sysctl_createv(&amp;amp;ic-&amp;gt;ic_sysctllog, 0, &amp;amp;rnode, &amp;amp;cnode,
-    CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+    CTLFLAG_READWRITE, CTLTYPE_INT,
     "debug", SYSCTL_DESCR("control debugging printfs"),
     NULL, ieee80211_debug, &amp;amp;ic-&amp;gt;ic_debug, 0,
     CTL_CREATE, CTL_EOL)) != 0)
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -204,39 +230,39 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; ieee80211_sysctl_attach(struct ieee80211
 #endif
 /* XXX inherit from tunables */
 if ((rc = sysctl_createv(&amp;amp;ic-&amp;gt;ic_sysctllog, 0, &amp;amp;rnode, &amp;amp;cnode,
-    CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+    CTLFLAG_READWRITE, CTLTYPE_INT,
     "inact_run", SYSCTL_DESCR("station inactivity timeout (sec)"),
     ieee80211_sysctl_inact, 0, &amp;amp;ic-&amp;gt;ic_inact_run, 0,
     CTL_CREATE, CTL_EOL)) != 0)
 goto err;
 if ((rc = sysctl_createv(&amp;amp;ic-&amp;gt;ic_sysctllog, 0, &amp;amp;rnode, &amp;amp;cnode,
-    CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+    CTLFLAG_READWRITE, CTLTYPE_INT,
     "inact_probe",
     SYSCTL_DESCR("station inactivity probe timeout (sec)"),
     ieee80211_sysctl_inact, 0, &amp;amp;ic-&amp;gt;ic_inact_probe, 0,
     CTL_CREATE, CTL_EOL)) != 0)
 goto err;
 if ((rc = sysctl_createv(&amp;amp;ic-&amp;gt;ic_sysctllog, 0, &amp;amp;rnode, &amp;amp;cnode,
-    CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+    CTLFLAG_READWRITE, CTLTYPE_INT,
     "inact_auth",
     SYSCTL_DESCR("station authentication timeout (sec)"),
     ieee80211_sysctl_inact, 0, &amp;amp;ic-&amp;gt;ic_inact_auth, 0,
     CTL_CREATE, CTL_EOL)) != 0)
 goto err;
 if ((rc = sysctl_createv(&amp;amp;ic-&amp;gt;ic_sysctllog, 0, &amp;amp;rnode, &amp;amp;cnode,
-    CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+    CTLFLAG_READWRITE, CTLTYPE_INT,
     "inact_init",
     SYSCTL_DESCR("station initial state timeout (sec)"),
     ieee80211_sysctl_inact, 0, &amp;amp;ic-&amp;gt;ic_inact_init, 0,
     CTL_CREATE, CTL_EOL)) != 0)
 goto err;
 if ((rc = sysctl_createv(&amp;amp;ic-&amp;gt;ic_sysctllog, 0, &amp;amp;rnode, &amp;amp;cnode,
-    CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+    CTLFLAG_READWRITE, CTLTYPE_INT,
     "driver_caps", SYSCTL_DESCR("driver capabilities"),
     NULL, 0, &amp;amp;ic-&amp;gt;ic_caps, 0, CTL_CREATE, CTL_EOL)) != 0)
 goto err;
 if ((rc = sysctl_createv(&amp;amp;ic-&amp;gt;ic_sysctllog, 0, &amp;amp;rnode, &amp;amp;cnode,
-    CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+    CTLFLAG_READWRITE, CTLTYPE_INT,
     "bmiss_max", SYSCTL_DESCR("consecutive beacon misses before scanning"),
     NULL, 0, &amp;amp;ic-&amp;gt;ic_bmiss_max, 0, CTL_CREATE, CTL_EOL)) != 0)
 goto err;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -457,8 +483,6 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; cleanup:
 
 /*
  * Setup sysctl(3) MIB, net.ieee80211.*
- *
- * TBD condition CTLFLAG_PERMANENT on being a module or not
  */
 SYSCTL_SETUP(sysctl_ieee80211, "sysctl ieee80211 subtree setup")
 {
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -469,14 +493,14 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; SYSCTL_SETUP(sysctl_ieee80211, "sysctl i
 return;
 
 if ((rc = sysctl_createv(clog, 0, &amp;amp;rnode, NULL,
-    CTLFLAG_PERMANENT, CTLTYPE_NODE, "nodes", "client/peer stations",
+    0, CTLTYPE_NODE, "nodes", "client/peer stations",
     ieee80211_sysctl_node, 0, NULL, 0, CTL_CREATE, CTL_EOL)) != 0)
 goto err;
 
 #ifdef IEEE80211_DEBUG
 /* control debugging printfs */
 if ((rc = sysctl_createv(clog, 0, &amp;amp;rnode, &amp;amp;cnode,
-    CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+    CTLFLAG_READWRITE, CTLTYPE_INT,
     "debug", SYSCTL_DESCR("control debugging printfs"),
     NULL, 0, &amp;amp;ieee80211_debug, 0, CTL_CREATE, CTL_EOL)) != 0)
 goto err;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -769,3 +793,24 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; ieee80211_load_module(const char *modnam
 printf("%s: load the %s module by hand for now.\n", __func__, modname);
 #endif
 }
+
+MODULE(MODULE_CLASS_MISC, net80211, NULL);
+ 
+static int
+net80211_modcmd(modcmd_t cmd, void *aux)
+{
+int error = 0;
+static struct sysctllog *clog;
+   
+switch (cmd) {
+case MODULE_CMD_INIT:
+ieee80211_init();
+sysctl_ieee80211(&amp;amp;clog);
+return error;
+case MODULE_CMD_FINI:
+sysctl_teardown(&amp;amp;clog);
+return error;
+default:
+return ENOTTY;
+}
+}
Index: ieee80211_netbsd.h
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211_netbsd.h,v
retrieving revision 1.17
diff -u -p -r1.17 ieee80211_netbsd.h
--- ieee80211_netbsd.h31 Dec 2011 20:41:58 -00001.17
+++ ieee80211_netbsd.h27 Apr 2012 12:34:50 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -243,10 +243,18 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; voidieee80211_sysctl_detach(struct ieee
 voidieee80211_load_module(const char *);
 
 voidieee80211_init(void);
+
+#ifdef NOT_YET /* We currently cannot use link sets in modules */
 #defineIEEE80211_CRYPTO_SETUP(name)\
 static void name(void);\
 __link_set_add_text(ieee80211_funcs, name);\
 static void name(void)
-#endif
+#else
+#defineIEEE80211_CRYPTO_SETUP(name)\
+void name(void);\
+void name(void)
+#endif/* NOT_YET */
+
+#endif/* _KERNEL */
 
 #endif /* !_NET80211_IEEE80211_NETBSD_H_ */
Index: ieee80211_node.c
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211_node.c,v
retrieving revision 1.63
diff -u -p -r1.63 ieee80211_node.c
--- ieee80211_node.c3 Jan 2009 03:43:23 -00001.63
+++ ieee80211_node.c27 Apr 2012 12:34:50 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -39,7 +39,9 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; __FBSDID("$FreeBSD: src/sys/net80211/iee
 __KERNEL_RCSID(0, "$NetBSD: ieee80211_node.c,v 1.63 2009/01/03 03:43:23 yamt Exp $");
 #endif
 
+#if defined(_KERNEL_OPT)
 #include "opt_inet.h"
+#endif
 
 #include &amp;lt;sys/param.h&amp;gt;
 #include &amp;lt;sys/systm.h&amp;gt; 
Index: ieee80211_output.c
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211_output.c,v
retrieving revision 1.51
diff -u -p -r1.51 ieee80211_output.c
--- ieee80211_output.c31 Dec 2011 20:41:58 -00001.51
+++ ieee80211_output.c27 Apr 2012 12:34:50 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -39,7 +39,9 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; __FBSDID("$FreeBSD: src/sys/net80211/iee
 __KERNEL_RCSID(0, "$NetBSD: ieee80211_output.c,v 1.51 2011/12/31 20:41:58 christos Exp $");
 #endif
 
+#if defined(_KERNEL_OPT)
 #include "opt_inet.h"
+#endif
 
 #ifdef __NetBSD__
 #endif /* __NetBSD__ */
Index: ieee80211_proto.c
===================================================================
RCS file: /cvsroot/src/sys/net80211/ieee80211_proto.c,v
retrieving revision 1.29
diff -u -p -r1.29 ieee80211_proto.c
--- ieee80211_proto.c13 Jan 2008 13:01:12 -00001.29
+++ ieee80211_proto.c27 Apr 2012 12:34:50 -0000
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -43,7 +43,9 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; __KERNEL_RCSID(0, "$NetBSD: ieee80211_pr
  * IEEE 802.11 protocol support.
  */
 
+#if defined(_KERNEL_OPT)
 #include "opt_inet.h"
+#endif
 
 #include &amp;lt;sys/param.h&amp;gt;
 #include &amp;lt;sys/kernel.h&amp;gt;
&lt;/pre&gt;</description>
    <dc:creator>Paul Goyette</dc:creator>
    <dc:date>2012-04-27T12:51:30</dc:date>
  </item>
  <textinput rdf:about="http://search.gmane.org/?group=$group=gmane.os.netbsd.devel.kernel">
    <title>Search Engine</title>
    <description>Search the mailing list at Gmane</description>
    <name>query</name>
    <link>http://search.gmane.org/?group=$group=gmane.os.netbsd.devel.kernel</link>
  </textinput>
</rdf:RDF>

