Thanks to naddy, here's the list of ports that will break when
<uvm/uvm_extern.h> will stop to include <sys/vmmeter.h>.  I'd
appreciate if the maintainers of the ports below could have a
look and fix their ports.

If the application is only using the VM_METER sysctl(3) to get
memory statics, then it should be converted to the VM_UVMEXP
one.  See the attached diff for examples.

If the application also uses the process stats from the "struct
vmtotal", then you should also include <sys/vmmeter.h>.  You can
have a look at usr.sbin/vmstat/vmstat.c if you want an example.

Attached are three diffs for the following ports,  I'm looking
for reviews/oks.

        databases/pg_top
        sysutils/libstatgrab
        x11/xfce4/xfce4-taskmanager

These are the remaining ports to fix:

        lang/erlang
        sysutils/monit
        sysutils/symon
        sysutils/toprump
        sysutils/wmmon
        sysutils/xstatbar
        telephony/asterisk
        www/chromium
        x11/kde/base3
        x11/kde4/workspace


And here's the diff that I'd like to commit but breaks these ports:

Index: sys/arch/amd64/amd64/fpu.c
===================================================================
RCS file: /home/ncvs/src/sys/arch/amd64/amd64/fpu.c,v
retrieving revision 1.28
diff -u -p -r1.28 fpu.c
--- sys/arch/amd64/amd64/fpu.c  29 Mar 2014 18:09:28 -0000      1.28
+++ sys/arch/amd64/amd64/fpu.c  8 Apr 2014 14:06:24 -0000
@@ -40,7 +40,6 @@
 #include <sys/user.h>
 #include <sys/ioctl.h>
 #include <sys/device.h>
-#include <sys/vmmeter.h>
 #include <sys/signalvar.h>
 
 #include <uvm/uvm_extern.h>
Index: sys/kern/kern_fork.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_fork.c,v
retrieving revision 1.162
diff -u -p -r1.162 kern_fork.c
--- sys/kern/kern_fork.c        30 Mar 2014 21:54:48 -0000      1.162
+++ sys/kern/kern_fork.c        8 Apr 2014 14:06:24 -0000
@@ -48,6 +48,7 @@
 #include <sys/resourcevar.h>
 #include <sys/signalvar.h>
 #include <sys/vnode.h>
+#include <sys/vmmeter.h>
 #include <sys/file.h>
 #include <sys/acct.h>
 #include <sys/ktrace.h>
Index: sys/miscfs/procfs/procfs_vfsops.c
===================================================================
RCS file: /home/ncvs/src/sys/miscfs/procfs/procfs_vfsops.c,v
retrieving revision 1.29
diff -u -p -r1.29 procfs_vfsops.c
--- sys/miscfs/procfs/procfs_vfsops.c   15 Apr 2013 15:32:19 -0000      1.29
+++ sys/miscfs/procfs/procfs_vfsops.c   8 Apr 2014 14:06:24 -0000
@@ -169,13 +169,10 @@ procfs_start(struct mount *mp, int flags
 int
 procfs_statfs(struct mount *mp, struct statfs *sbp, struct proc *p)
 {
-       struct vmtotal  vmtotals;
-
-       uvm_total(&vmtotals);
        sbp->f_bsize = PAGE_SIZE;
        sbp->f_iosize = PAGE_SIZE;
-       sbp->f_blocks = vmtotals.t_vm;
-       sbp->f_bfree = vmtotals.t_vm - vmtotals.t_avm;
+       sbp->f_blocks = uvmexp.npages - uvmexp.free + uvmexp.swpginuse;
+       sbp->f_bfree = uvmexp.npages - uvmexp.free - uvmexp.active;
        sbp->f_bavail = 0;
        sbp->f_files = maxprocess;              /* approx */
        sbp->f_ffree = maxprocess - nprocesses; /* approx */
Index: sys/uvm/uvm_extern.h
===================================================================
RCS file: /home/ncvs/src/sys/uvm/uvm_extern.h,v
retrieving revision 1.112
diff -u -p -r1.112 uvm_extern.h
--- sys/uvm/uvm_extern.h        3 Apr 2014 21:40:10 -0000       1.112
+++ sys/uvm/uvm_extern.h        8 Apr 2014 14:06:24 -0000
@@ -394,7 +394,6 @@ extern struct uvmexp uvmexp;
 /*
  * Finally, bring in standard UVM headers.
  */
-#include <sys/vmmeter.h>
 #include <sys/queue.h>
 #include <sys/tree.h>
 #include <sys/lock.h>
@@ -484,7 +483,6 @@ struct loadavg;
 struct proc;
 struct pmap;
 struct vmspace;
-struct vmtotal;
 struct mount;
 struct vnode;
 struct core;
@@ -677,7 +675,6 @@ void                        uvmspace_share(struct proc *, 
str
 void                   uvm_meter(void);
 int                    uvm_sysctl(int *, u_int, void *, size_t *, 
                                void *, size_t, struct proc *);
-void                   uvm_total(struct vmtotal *);
 
 /* uvm_mmap.c */
 int                    uvm_mmap(vm_map_t, vaddr_t *, vsize_t,
Index: sys/uvm/uvm_meter.c
===================================================================
RCS file: /home/ncvs/src/sys/uvm/uvm_meter.c,v
retrieving revision 1.30
diff -u -p -r1.30 uvm_meter.c
--- sys/uvm/uvm_meter.c 23 Mar 2013 16:12:31 -0000      1.30
+++ sys/uvm/uvm_meter.c 8 Apr 2014 14:06:24 -0000
@@ -45,7 +45,7 @@
 #include <sys/proc.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <uvm/uvm_extern.h>
+#include <sys/vmmeter.h>
 #include <sys/sysctl.h>
 #include <sys/exec.h>
 
@@ -79,11 +79,8 @@ static fixpt_t cexp[3] = {
        0.9944598480048967 * FSCALE,    /* exp(-1/180) */
 };
 
-/*
- * prototypes
- */
-
 static void uvm_loadav(struct loadavg *);
+void uvm_total(struct vmtotal *);
 
 /*
  * uvm_meter: calculate load average and wake up the swapper (if needed)
Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/sysutils/libstatgrab/Makefile,v
retrieving revision 1.9
diff -u -p -r1.9 Makefile
--- Makefile    21 Mar 2013 08:48:54 -0000      1.9
+++ Makefile    10 Apr 2014 12:44:14 -0000
@@ -4,6 +4,7 @@ COMMENT=        system statistics gathering lib
 
 DISTNAME=      libstatgrab-0.17
 CATEGORIES=    sysutils
+REVISION=      0
 
 HOMEPAGE=      http://www.i-scream.org/libstatgrab/
 
Index: patches/patch-src_libstatgrab_memory_stats_c
===================================================================
RCS file: 
/home/ncvs/ports/sysutils/libstatgrab/patches/patch-src_libstatgrab_memory_stats_c,v
retrieving revision 1.1
diff -u -p -r1.1 patch-src_libstatgrab_memory_stats_c
--- patches/patch-src_libstatgrab_memory_stats_c        6 Jul 2011 12:45:04 
-0000       1.1
+++ patches/patch-src_libstatgrab_memory_stats_c        10 Apr 2014 12:44:14 
-0000
@@ -1,15 +1,82 @@
 $OpenBSD: patch-src_libstatgrab_memory_stats_c,v 1.1 2011/07/06 12:45:04 
jasper Exp $
 
-Fix implicit declarations of sysconf() and bzero().
+Prefer the UVM way to the vmmeter one to get memory stats.
 
---- src/libstatgrab/memory_stats.c.orig        Wed Jul  6 14:37:07 2011
-+++ src/libstatgrab/memory_stats.c     Wed Jul  6 14:38:26 2011
-@@ -50,6 +50,8 @@
- #include <sys/types.h>
- #include <sys/sysctl.h>
- #include <sys/unistd.h>
-+#include <unistd.h>
-+#include <string.h>
+--- src/libstatgrab/memory_stats.c.orig        Sun Feb 21 11:04:26 2010
++++ src/libstatgrab/memory_stats.c     Thu Apr 10 14:43:24 2014
+@@ -91,15 +91,9 @@ sg_mem_stats *sg_get_mem_stats(){
+       u_long inactive_count;
+       int pagesize;
  #endif
- #ifdef HPUX
- #include <sys/param.h>
+-#if defined(NETBSD)
++#if defined(NETBSD) || defined(OPENBSD)
+       struct uvmexp *uvm;
+ #endif
+-#if defined(OPENBSD)
+-      int mib[2];
+-      struct vmtotal vmtotal;
+-      size_t size;
+-      int pagesize, page_multiplier;
+-#endif
+ #ifdef WIN32
+       MEMORYSTATUSEX memstats;
+ #endif
+@@ -240,53 +234,15 @@ sg_mem_stats *sg_get_mem_stats(){
+       mem_stat.free = uvm->pagesize * (uvm->free + uvm->inactive);
+       mem_stat.used = mem_stat.total - mem_stat.free;
+ #endif
+-
+ #if defined(OPENBSD)
+-      /* The code in this section is based on the code in the OpenBSD
+-       * top utility, located at src/usr.bin/top/machine.c in the
+-       * OpenBSD source tree.
+-       *
+-       * For fun, and like OpenBSD top, we will do the multiplication
+-       * converting the memory stats in pages to bytes in base 2.
+-       */
+-
+-      /* All memory stats in OpenBSD are returned as the number of pages.
+-       * To convert this into the number of bytes we need to know the
+-       * page size on this system.
+-       */
+-      pagesize = sysconf(_SC_PAGESIZE);
+-
+-      /* The pagesize gives us the base 10 multiplier, so we need to work
+-       * out what the base 2 multiplier is. This means dividing
+-       * pagesize by 2 until we reach unity, and counting the number of
+-       * divisions required.
+-       */
+-      page_multiplier = 0;
+-
+-      while (pagesize > 1) {
+-              page_multiplier++;
+-              pagesize >>= 1;
+-      }
+-
+-      /* We can now ret the the raw VM stats (in pages) using the
+-       * sysctl interface.
+-       */
+-      mib[0] = CTL_VM;
+-      mib[1] = VM_METER;
+-      size = sizeof(vmtotal);
+-
+-      if (sysctl(mib, 2, &vmtotal, &size, NULL, 0) < 0) {
+-              bzero(&vmtotal, sizeof(vmtotal));
+-              sg_set_error_with_errno(SG_ERROR_SYSCTL, "CTL_VM.VM_METER");
++      if ((uvm = sg_get_uvmexp()) == NULL) {
+               return NULL;
+       }
+ 
+-      /* Convert the raw stats to bytes, and return these to the caller
+-       */
+-      mem_stat.used = (vmtotal.t_rm << page_multiplier);   /* total real mem 
in use */
+-      mem_stat.cache = 0;                                  /* no cache stats 
*/
+-      mem_stat.free = (vmtotal.t_free << page_multiplier); /* free memory 
pages */
+-      mem_stat.total = (mem_stat.used + mem_stat.free);
++      mem_stat.total = uvm->pagesize * uvm->npages;
++      mem_stat.cache = 0;
++      mem_stat.free = uvm->pagesize * (uvm->free + uvm->inactive);
++      mem_stat.used = mem_stat.total - mem_stat.free;
+ #endif
+ 
+ #ifdef WIN32
Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/databases/pg_top/Makefile,v
retrieving revision 1.9
diff -u -p -r1.9 Makefile
--- Makefile    11 Mar 2013 02:52:07 -0000      1.9
+++ Makefile    10 Apr 2014 13:03:43 -0000
@@ -4,7 +4,7 @@ COMMENT =       top for monitoring PostgreSQL 
 
 DISTNAME =     pg_top-3.6.2
 CATEGORIES =   databases sysutils
-REVISION =     2
+REVISION =     3
 
 HOMEPAGE =     http://ptop.projects.postgresql.org/
 MASTER_SITES = http://pgfoundry.org/frs/download.php/1781/
Index: patches/patch-machine_m_openbsd_c
===================================================================
RCS file: /home/ncvs/ports/databases/pg_top/patches/patch-machine_m_openbsd_c,v
retrieving revision 1.3
diff -u -p -r1.3 patch-machine_m_openbsd_c
--- patches/patch-machine_m_openbsd_c   18 Dec 2012 21:38:12 -0000      1.3
+++ patches/patch-machine_m_openbsd_c   10 Apr 2014 13:03:43 -0000
@@ -1,6 +1,6 @@
 $OpenBSD: patch-machine_m_openbsd_c,v 1.3 2012/12/18 21:38:12 sthen Exp $
---- machine/m_openbsd.c.orig   Sat Apr  5 11:09:06 2008
-+++ machine/m_openbsd.c        Thu Dec  6 15:30:59 2012
+--- machine/m_openbsd.c.orig   Sat Apr  5 19:09:06 2008
++++ machine/m_openbsd.c        Thu Apr 10 15:03:09 2014
 @@ -38,6 +38,7 @@
  #include <stdlib.h>
  #include <string.h>
@@ -37,6 +37,42 @@ $OpenBSD: patch-machine_m_openbsd_c,v 1.
  
  /* these are for getting the memory statistics */
  static int      pageshift;    /* log base 2 of the pagesize */
+@@ -238,9 +239,9 @@ void
+ get_system_info(struct system_info *si)
+ {
+       static int sysload_mib[] = {CTL_VM, VM_LOADAVG};
+-      static int vmtotal_mib[] = {CTL_VM, VM_METER};
++      static int uvmexp_mib[] = {CTL_VM, VM_UVMEXP};
+       struct loadavg sysload;
+-      struct vmtotal vmtotal;
++      struct uvmexp uvmexp;
+       double *infoloadp;
+       size_t size;
+       int i;
+@@ -280,17 +281,17 @@ get_system_info(struct system_info *si)
+ 
+ 
+       /* get total -- systemwide main memory usage structure */
+-      size = sizeof(vmtotal);
+-      if (sysctl(vmtotal_mib, 2, &vmtotal, &size, NULL, 0) < 0) {
++      size = sizeof(uvmexp);
++      if (sysctl(uvmexp_mib, 2, &uvmexp, &size, NULL, 0) < 0) {
+               warn("sysctl failed");
+-              bzero(&vmtotal, sizeof(vmtotal));
++              bzero(&uvmexp, sizeof(uvmexp));
+       }
+       /* convert memory stats to Kbytes */
+       memory_stats[0] = -1;
+-      memory_stats[1] = pagetok(vmtotal.t_arm);
+-      memory_stats[2] = pagetok(vmtotal.t_rm);
++      memory_stats[1] = pagetok(uvmexp.active);
++      memory_stats[2] = pagetok(uvmexp.npages - uvmexp.free);
+       memory_stats[3] = -1;
+-      memory_stats[4] = pagetok(vmtotal.t_free);
++      memory_stats[4] = pagetok(uvmexp.free);
+       memory_stats[5] = -1;
+ 
+       if (!swapmode(&memory_stats[6], &memory_stats[7])) {
 @@ -312,7 +313,7 @@ get_process_info(struct system_info *si, struct proces
  {
        int show_idle, show_system, show_threads, show_uid, show_cmd;
Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/x11/xfce4/xfce4-taskmanager/Makefile,v
retrieving revision 1.14
diff -u -p -r1.14 Makefile
--- Makefile    9 Jan 2014 21:09:16 -0000       1.14
+++ Makefile    10 Apr 2014 12:29:12 -0000
@@ -4,6 +4,7 @@ COMMENT=        Xfce4 task manager and system m
 
 XFCE_VERSION=  1.0.1
 XFCE_GOODIE=   xfce4-taskmanager
+REVISION=      0
 
 # GPLv2
 PERMIT_PACKAGE_CDROM=  Yes
Index: patches/patch-src_task-manager-bsd_c
===================================================================
RCS file: 
/home/ncvs/ports/x11/xfce4/xfce4-taskmanager/patches/patch-src_task-manager-bsd_c,v
retrieving revision 1.3
diff -u -p -r1.3 patch-src_task-manager-bsd_c
--- patches/patch-src_task-manager-bsd_c        9 Jan 2014 21:09:16 -0000       
1.3
+++ patches/patch-src_task-manager-bsd_c        10 Apr 2014 12:29:12 -0000
@@ -1,6 +1,9 @@
 $OpenBSD: patch-src_task-manager-bsd_c,v 1.3 2014/01/09 21:09:16 landry Exp $
---- src/task-manager-bsd.c.orig        Thu Jan  9 22:05:05 2014
-+++ src/task-manager-bsd.c     Thu Jan  9 22:05:37 2014
+
+Prefer the UVM way to the vmmeter one to get memory stats.
+
+--- src/task-manager-bsd.c.orig        Wed Jan  8 19:42:02 2014
++++ src/task-manager-bsd.c     Thu Apr 10 14:25:30 2014
 @@ -25,6 +25,7 @@
  #include <sys/param.h>
  #include <sys/sched.h>
@@ -9,3 +12,38 @@ $OpenBSD: patch-src_task-manager-bsd_c,v
  /* for swapctl() */
  #include <sys/swap.h>
  /* for strlcpy() */
+@@ -213,11 +214,26 @@ gboolean get_cpu_usage (gushort *cpu_count, gfloat *cp
+ 
+ gboolean get_memory_usage (guint64 *memory_total, guint64 *memory_free, 
guint64 *memory_cache, guint64 *memory_buffers, guint64 *swap_total, guint64 
*swap_free)
+ {
++#ifdef __OpenBSD__
++      int mib[] = {CTL_VM, VM_UVMEXP};
++      struct uvmexp  uvmexp;
++#else
+       int mib[] = {CTL_VM, VM_METER};
+       struct vmtotal vmtotal;
++#endif
+       struct swapent *swdev;
+       int nswap, i;
+       size_t size;
++#ifdef __OpenBSD__
++      size = sizeof(uvmexp);
++      if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0)
++              errx(1,"failed to get vm.uvmexp");
++      /* cheat : rm = tot used, add free to get total */
++      *memory_total = pagetok(uvmexp.npages);
++      *memory_free = pagetok(uvmexp.free);
++      *memory_cache = 0;
++      *memory_buffers = pagetok(uvmexp.npages - uvmexp.free -uvmexp.active);
++#else
+       size = sizeof(vmtotal);
+       if (sysctl(mib, 2, &vmtotal, &size, NULL, 0) < 0)
+               errx(1,"failed to get vm.meter");
+@@ -226,6 +242,7 @@ gboolean get_memory_usage (guint64 *memory_total, guin
+       *memory_free = pagetok(vmtotal.t_free);
+       *memory_cache = 0;
+       *memory_buffers = pagetok(vmtotal.t_rm - vmtotal.t_arm);
++#endif
+ 
+       /* get swap stats */
+       if ((nswap = swapctl(SWAP_NSWAP, 0, 0)) == 0)

Reply via email to