From owner-cvs-all Fri Feb 23 15:51:56 2001 Delivered-To: cvs-all@freebsd.org Received: from mail.gmx.net (sproxy.gmx.de [194.221.183.20]) by hub.freebsd.org (Postfix) with SMTP id 6E6CC37B491 for ; Fri, 23 Feb 2001 15:51:43 -0800 (PST) (envelope-from tmoestl@gmx.net) Received: (qmail 29226 invoked by uid 0); 23 Feb 2001 23:51:40 -0000 Received: from pc19ebfb5.dip.t-dialin.net (HELO forge.local) (193.158.191.181) by mail.gmx.net (mp013-rz3) with SMTP; 23 Feb 2001 23:51:40 -0000 Received: from tmm by forge.local with local (Exim 3.20 #1) id 14WRzy-0000f5-00 for ; Sat, 24 Feb 2001 00:51:42 +0100 Date: Sat, 24 Feb 2001 00:51:42 +0100 From: Thomas Moestl To: cvs-all@freebsd.org Subject: Re: cvs commit: src/sys/sys conf.h src/sys/vm swap_pager.c vm_swap.c Message-ID: <20010224005142.A2470@crow.dom2ip.de> Mail-Followup-To: Thomas Moestl , cvs-all@freebsd.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="VS++wcV0S1rZb1Fb" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --VS++wcV0S1rZb1Fb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Feb 23, 2001 at 05:50:55PM -0500, Robert Watson wrote: > On Fri, 23 Feb 2001, Bill Fumerola wrote: > > On Fri, Feb 23, 2001 at 01:49:09PM -0800, Mike Smith wrote: > > > JFYI, convention for implementing this sort of thing is to have a node > > > "vm.swapdev_acct" and then pass it an extra OID value which is the index. > > > > yes > > > > speaking as someone who has been spending too much time w/ snmp, it would > > be really good if all indexed sysctls followed this convention. > Thomas is generating updated patches that address this concern and > hopefully we'll get something committed in the next day or two to re-work > the MIB a bit. I propose the attached set of patches. They change the old model to a hierarchy like: vm.swap.nswapdev: 1 vm.swap.dev.0.flags: 1 vm.swap.dev.0.nblks: 65536 vm.swap.dev.0.used: 8176 vm.swap.dev.0.dev: { major = 116, minor = 0x20001 } all have fixed ID's, the nodes for devices (vm.swap.dev.0, vm.swap.dev.1 etc) have the ID's 1, 2 and so forth (0 being reserved). There are some other swap related sysctls in vm, but I wouldn't like to move those do vm.swap (for compatability reasons). If this is a problem, I'd rather rename vm.swap. I'm right now still testing these, but I think they should be ready tomorrow. swd.diff is for the kernel part, libkvmswd.diff makes libkvm use the ID's to index the devices (cheaper). Please comment, -thomas --VS++wcV0S1rZb1Fb Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="swd.diff" diff -cr sys.swd.orig/vm/vm_param.h sys.swd/vm/vm_param.h *** sys.swd.orig/vm/vm_param.h Fri Feb 23 23:08:51 2001 --- sys.swd/vm/vm_param.h Sat Feb 24 00:18:25 2001 *************** *** 87,93 **** #define VM_V_PAGEOUT_FREE_MIN 9 /* cnt.v_pageout_free_min */ #define VM_PAGEOUT_ALGORITHM 10 /* pageout algorithm */ #define VM_SWAPPING_ENABLED 11 /* swapping enabled */ ! #define VM_MAXID 12 /* number of valid vm ids */ #define CTL_VM_NAMES { \ { 0, 0 }, \ --- 87,111 ---- #define VM_V_PAGEOUT_FREE_MIN 9 /* cnt.v_pageout_free_min */ #define VM_PAGEOUT_ALGORITHM 10 /* pageout algorithm */ #define VM_SWAPPING_ENABLED 11 /* swapping enabled */ ! #define VM_SWAP 12 /* swap stats */ ! #define VM_MAXID 13 /* number of valid vm ids */ ! ! /* ! * sysctl vm.swap.* indentifiers. ! */ ! #define VM_SWAP_NSWAPDEV 1 /* number of configured dev's */ ! #define VM_SWAP_DEV 2 /* node to hold the devices */ ! ! /* ! * sysctl vm.swap.dev.* indentifiers VM_SWAP_FIRSRTDEV is the oid of the first ! * swap device, the oid of a swap device being (number + VM_SWAP_FIRSTDEV). ! */ ! #define VM_SWAP_DEV_FLAGS 1 /* flags for swap device */ ! #define VM_SWAP_DEV_NBLKS 2 /* # of blocks */ ! #define VM_SWAP_DEV_USED 3 /* # of blocks in use */ ! #define VM_SWAP_DEV_DEV 4 /* udev_t of the device */ ! ! #define VM_SWAP_DEV_FIRST 1 /* Node for the first device */ #define CTL_VM_NAMES { \ { 0, 0 }, \ *************** *** 102,107 **** --- 120,126 ---- { "v_pageout_free_min", CTLTYPE_INT}, \ { "pageout_algorithm", CTLTYPE_INT}, \ { "swapping_enabled", CTLTYPE_INT},\ + { "swap", CTLTYPE_NODE},\ } /* Only in sys.swd/vm: vm_param.h~ diff -cr sys.swd.orig/vm/vm_swap.c sys.swd/vm/vm_swap.c *** sys.swd.orig/vm/vm_swap.c Fri Feb 23 23:08:51 2001 --- sys.swd/vm/vm_swap.c Sat Feb 24 00:18:45 2001 *************** *** 55,60 **** --- 55,61 ---- #include #include #include + #include #include /* *************** *** 70,76 **** int nswdev = NSWAPDEV; int vm_swap_size; static int ncswdev = 0; /* # of configured swap devs */ ! SYSCTL_INT(_vm, OID_AUTO, nswapdev, CTLFLAG_RD, &ncswdev, 0, "Number of swap devices"); static int swapdev_strategy __P((struct vop_strategy_args *ap)); --- 71,80 ---- int nswdev = NSWAPDEV; int vm_swap_size; static int ncswdev = 0; /* # of configured swap devs */ ! ! SYSCTL_NODE(_vm, VM_SWAP, swap, CTLFLAG_RD, 0, "Swap statistics"); ! SYSCTL_NODE(_vm_swap, VM_SWAP_DEV, dev, CTLFLAG_RD, 0, "Swap devices"); ! SYSCTL_INT(_vm_swap, VM_SWAP_NSWAPDEV, nswapdev, CTLFLAG_RD, &ncswdev, 0, "Number of swap devices"); static int swapdev_strategy __P((struct vop_strategy_args *ap)); *************** *** 251,257 **** int error; u_long aligned_nblks; struct sysctl_oid *oid; ! char name[11]; if (!swapdev_vp) { error = getnewvnode(VT_NON, NULL, swapdev_vnodeop_p, --- 255,261 ---- int error; u_long aligned_nblks; struct sysctl_oid *oid; ! char name[5]; if (!swapdev_vp) { error = getnewvnode(VT_NON, NULL, swapdev_vnodeop_p, *************** *** 338,358 **** * Add sysctl entries for new swap area. XXX: if some day swap devices * can be removed, add an oid member to swdevt. */ ! if (snprintf(name, sizeof(name), "swapdev%d", ncswdev) < sizeof(name)) { ! oid = SYSCTL_ADD_NODE(NULL, SYSCTL_STATIC_CHILDREN(_vm), ! OID_AUTO, name, CTLFLAG_RD, NULL, "Swap device stats"); if (oid != NULL) { ! SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, ! "flags", CTLFLAG_RD, &sp->sw_flags, 0, "Flags"); ! SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, ! "nblks", CTLFLAG_RD, &sp->sw_nblks, 0, ! "Number of blocks"); ! SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, ! "used", CTLFLAG_RD, &sp->sw_used, 0, ! "Number of blocks in use"); ! SYSCTL_ADD_OPAQUE(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, ! "dev", CTLFLAG_RD, &sp->sw_dev, sizeof(sp->sw_dev), ! "T,dev_t", "Device"); } } else printf("XXX: swaponvp() name buffer too small!\n"); --- 342,364 ---- * Add sysctl entries for new swap area. XXX: if some day swap devices * can be removed, add an oid member to swdevt. */ ! if (snprintf(name, sizeof(name), "%d", ncswdev) < sizeof(name)) { ! oid = SYSCTL_ADD_NODE(NULL, SYSCTL_STATIC_CHILDREN(_vm_swap_dev), ! ncswdev + VM_SWAP_DEV_FIRST, name, CTLFLAG_RD, NULL, ! "Swap device stats"); if (oid != NULL) { ! SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(oid), ! VM_SWAP_DEV_FLAGS, "flags", CTLFLAG_RD, ! &sp->sw_flags, 0, "Flags"); ! SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(oid), ! VM_SWAP_DEV_NBLKS, "nblks", CTLFLAG_RD, ! &sp->sw_nblks, 0, "Number of blocks"); ! SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(oid), ! VM_SWAP_DEV_USED, "used", CTLFLAG_RD, &sp->sw_used, ! 0, "Number of blocks in use"); ! SYSCTL_ADD_OPAQUE(NULL, SYSCTL_CHILDREN(oid), ! VM_SWAP_DEV_DEV, "dev", CTLFLAG_RD, &sp->sw_dev, ! sizeof(sp->sw_dev), "T,dev_t", "Device"); } } else printf("XXX: swaponvp() name buffer too small!\n"); Only in sys.swd/vm: vm_swap.c~ --VS++wcV0S1rZb1Fb Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="libkvmswd.diff" diff -cr libkvm.1o/kvm_getswapinfo.c libkvm.1os/kvm_getswapinfo.c *** libkvm.1o/kvm_getswapinfo.c Fri Feb 23 01:09:53 2001 --- libkvm.1os/kvm_getswapinfo.c Sat Feb 24 00:37:54 2001 *************** *** 25,30 **** --- 25,32 ---- #include #include + #include + #include #include #include *************** *** 64,70 **** static int kvm_getswapinfo_sysctl(kvm_t *, struct kvm_swap *, int, int); static int nlist_init(kvm_t *); static int getsysctl(kvm_t *, char *, void *, int); ! static int getsysctl2(kvm_t *, char *, char *, char *, int, void *, int); #define SVAR(var) __STRING(var) /* to force expansion */ --- 66,72 ---- static int kvm_getswapinfo_sysctl(kvm_t *, struct kvm_swap *, int, int); static int nlist_init(kvm_t *); static int getsysctl(kvm_t *, char *, void *, int); ! static int getsysctloid(kvm_t *, int *, int, void *, int); #define SVAR(var) __STRING(var) /* to force expansion */ *************** *** 458,466 **** #define GETSYSCTL(kd, name, var) \ getsysctl(kd, name, &(var), sizeof(var)) ! #define GETSYSCTL2(kd, pref, suff, buf, var) \ ! getsysctl2(kd, pref, suff, buf, sizeof(buf), &(var), \ ! sizeof(var)) int kvm_getswapinfo_sysctl( --- 460,467 ---- #define GETSYSCTL(kd, name, var) \ getsysctl(kd, name, &(var), sizeof(var)) ! #define GETSYSCTLOID(kd, oid, oidlen, var) \ ! getsysctloid(kd, oid, oidlen, &(var), sizeof(var)) int kvm_getswapinfo_sysctl( *************** *** 471,481 **** ) { int ti = 0; udev_t dev; - char node[15]; - char buf[20]; int used, ttl, i; ! if (!GETSYSCTL(kd, "vm.nswapdev", unswdev)) return -1; ti = unswdev; --- 472,484 ---- ) { int ti = 0; udev_t dev; int used, ttl, i; + int soid[5]; ! soid[0] = CTL_VM; ! soid[1] = VM_SWAP; ! soid[2] = VM_SWAP_NSWAPDEV; ! if (!GETSYSCTLOID(kd, soid, 3, unswdev)) return -1; ti = unswdev; *************** *** 488,510 **** if (!GETSYSCTL(kd, "vm.dmmax", dmmax)) return -1; for (i = 0; i < unswdev; ++i) { ! if (snprintf(node, sizeof(node), "vm.swapdev%d.", i) >= ! sizeof(node)) { ! _kvm_err(kd, kd->program, "XXX: node buffer too small"); ! return -1; ! } ! ! if (!GETSYSCTL2(kd, node, "nblks", buf, ttl)) return -1; ! if (!GETSYSCTL2(kd, node, "used", buf, used)) return -1; ttl -= dmmax; if (i < ti) { ! if (!GETSYSCTL2(kd, node, "dev", buf, dev)) return -1; ! if (!GETSYSCTL2(kd, node, "flags", buf, swap_ary[i].ksw_flags)) return -1; swap_ary[i].ksw_total = ttl; --- 491,514 ---- if (!GETSYSCTL(kd, "vm.dmmax", dmmax)) return -1; + soid[2] = VM_SWAP_DEV; for (i = 0; i < unswdev; ++i) { ! soid[3] = i + 1; ! ! soid[4] = VM_SWAP_DEV_NBLKS; ! if (!GETSYSCTLOID(kd, soid, 5, ttl)) return -1; ! soid[4] = VM_SWAP_DEV_USED; ! if (!GETSYSCTLOID(kd, soid, 5, used)) return -1; ttl -= dmmax; if (i < ti) { ! soid[4] = VM_SWAP_DEV_DEV; ! if (!GETSYSCTLOID(kd, soid, 5, dev)) return -1; ! soid[4] = VM_SWAP_DEV_FLAGS; ! if (!GETSYSCTLOID(kd, soid, 5, swap_ary[i].ksw_flags)) return -1; swap_ary[i].ksw_total = ttl; *************** *** 587,608 **** } static int ! getsysctl2 ( kvm_t *kd, ! char *pref, ! char *suff, ! char *buf, ! int buflen, void *ptr, int len ) { ! if (strlcpy(buf, pref, buflen) >= buflen) { ! _kvm_err(kd, kd->program, "getsysctl2: string buffer too small"); return (0); } ! if (strlcat(buf, suff, buflen) >= buflen) { ! _kvm_err(kd, kd->program, "getsysctl2: string buffer too small"); return (0); } ! return getsysctl(kd, buf, ptr, len); } --- 591,611 ---- } static int ! getsysctloid ( kvm_t *kd, ! int *oid, ! int oidlen, void *ptr, int len ) { ! int nlen = len; ! if (sysctl(oid, oidlen, ptr, &nlen, NULL, 0) == -1) { ! _kvm_err(kd, kd->program, "cannot read sysctl."); return (0); } ! if (nlen != len) { ! _kvm_err(kd, kd->program, "sysctl has unexpected size"); return (0); } ! return (1); } Only in libkvm.1o: kvm_getswapinfo.c~ Binary files libkvm.1o/kvm_getswapinfo.o and libkvm.1os/kvm_getswapinfo.o differ Binary files libkvm.1o/libkvm.a and libkvm.1os/libkvm.a differ --VS++wcV0S1rZb1Fb-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message