bring back r1.131:
authordlg <dlg@openbsd.org>
Mon, 11 Aug 2014 12:37:36 +0000 (12:37 +0000)
committerdlg <dlg@openbsd.org>
Mon, 11 Aug 2014 12:37:36 +0000 (12:37 +0000)
take the pools mutex when copying stats out of it in the sysctl
path so we are guaranteed a consistent snapshot.

sys/kern/subr_pool.c

index 438f065..9797190 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: subr_pool.c,v 1.138 2014/07/10 13:34:39 tedu Exp $    */
+/*     $OpenBSD: subr_pool.c,v 1.139 2014/08/11 12:37:36 dlg Exp $     */
 /*     $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $       */
 
 /*-
@@ -1473,6 +1473,8 @@ sysctl_dopool(int *name, u_int namelen, char *where, size_t *sizep)
                return copyout(pp->pr_wchan, where, len);
        case KERN_POOL_POOL:
                memset(&pi, 0, sizeof(pi));
+
+               mtx_enter(&pp->pr_mtx);
                pi.pr_size = pp->pr_size;
                pi.pr_pgsize = pp->pr_alloc->pa_pagesz;
                pi.pr_itemsperpage = pp->pr_itemsperpage;
@@ -1488,6 +1490,8 @@ sysctl_dopool(int *name, u_int namelen, char *where, size_t *sizep)
                pi.pr_npagefree = pp->pr_npagefree;
                pi.pr_hiwat = pp->pr_hiwat;
                pi.pr_nidle = pp->pr_nidle;
+               mtx_leave(&pp->pr_mtx);
+
                return copyout(&pi, where, buflen);
        }
        /* NOTREACHED */