pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/sysutils/libgtop Implement multi-processor load calcul...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/aa01ca7c5946
branches:  trunk
changeset: 390431:aa01ca7c5946
user:      youri <youri%pkgsrc.org@localhost>
date:      Mon Jan 21 03:31:05 2019 +0000

description:
Implement multi-processor load calculations for NetBSD,
this fills the graphs in mate and gnome system monitors.

diffstat:

 sysutils/libgtop/Makefile                        |   4 +-
 sysutils/libgtop/distinfo                        |   3 +-
 sysutils/libgtop/patches/patch-sysdeps_bsd_cpu.c |  85 ++++++++++++++++++++++++
 3 files changed, 89 insertions(+), 3 deletions(-)

diffs (119 lines):

diff -r 7b2a6a4d68a3 -r aa01ca7c5946 sysutils/libgtop/Makefile
--- a/sysutils/libgtop/Makefile Sun Jan 20 21:29:02 2019 +0000
+++ b/sysutils/libgtop/Makefile Mon Jan 21 03:31:05 2019 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.57 2018/08/22 09:46:35 wiz Exp $
+# $NetBSD: Makefile,v 1.58 2019/01/21 03:31:05 youri Exp $
 
 DISTNAME=              libgtop-2.28.4
-PKGREVISION=           13
+PKGREVISION=           14
 CATEGORIES=            sysutils gnome
 MASTER_SITES=          ${MASTER_SITE_GNOME:=sources/libgtop/2.28/}
 EXTRACT_SUFX=          .tar.bz2
diff -r 7b2a6a4d68a3 -r aa01ca7c5946 sysutils/libgtop/distinfo
--- a/sysutils/libgtop/distinfo Sun Jan 20 21:29:02 2019 +0000
+++ b/sysutils/libgtop/distinfo Mon Jan 21 03:31:05 2019 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.34 2018/05/28 15:16:39 youri Exp $
+$NetBSD: distinfo,v 1.35 2019/01/21 03:31:05 youri Exp $
 
 SHA1 (libgtop-2.28.4.tar.bz2) = b6f002cc80a61dc0908dd96e0b543113a46bc4b7
 RMD160 (libgtop-2.28.4.tar.bz2) = 96ac76aa409bbd202bedacd94df14cd549e10d6b
@@ -36,6 +36,7 @@
 SHA1 (patch-dl) = 9d6a44be02ec21d195076125c0cdfe5b51a0ab0a
 SHA1 (patch-dm) = ef08973aecacb1fb69f258632dd36edfdafd8c50
 SHA1 (patch-dn) = 66f66731a3abd1290f67d62f9ef654f68756bccb
+SHA1 (patch-sysdeps_bsd_cpu.c) = e6b2b1e90385340128505fcab1c5c4aa510e165a
 SHA1 (patch-sysdeps_bsd_glibtop__machine.h) = 1682156e3cb21d335499e38b6b91b8c315f1b962
 SHA1 (patch-sysdeps_bsd_netload.c) = d143e392982afdd095fd052f857bfca2319ac7e7
 SHA1 (patch-sysdeps_bsd_procmap.c) = 8b65993423099040f20256ea8b3f797ecbca21b0
diff -r 7b2a6a4d68a3 -r aa01ca7c5946 sysutils/libgtop/patches/patch-sysdeps_bsd_cpu.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/libgtop/patches/patch-sysdeps_bsd_cpu.c  Mon Jan 21 03:31:05 2019 +0000
@@ -0,0 +1,85 @@
+$NetBSD: patch-sysdeps_bsd_cpu.c,v 1.1 2019/01/21 03:31:06 youri Exp $
+
+Fix multi-processor cpu load calculations
+
+--- sysdeps/bsd/cpu.c.orig     2011-06-01 15:40:47.000000000 +0000
++++ sysdeps/bsd/cpu.c
+@@ -24,6 +24,8 @@
+ #include <glibtop/error.h>
+ #include <glibtop/cpu.h>
+ 
++#include <err.h>
++
+ #include <glibtop_suid.h>
+ 
+ #ifdef __NetBSD__
+@@ -84,6 +86,7 @@ glibtop_get_cpu_p (glibtop *server, glib
+       /* sysctl vars*/
+       struct clockinfo ci;
+       size_t length;
++      int ncpu, i = 0;
+ 
+       glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_CPU), 0);
+ 
+@@ -93,6 +96,10 @@ glibtop_get_cpu_p (glibtop *server, glib
+       if (server->sysdeps.cpu == 0)
+               return;
+ 
++      size_t len = sizeof(ncpu);
++      if (sysctlbyname("hw.ncpu", &ncpu, &len, NULL, 0) < 0)
++              errx(1, "Failed to get hw.cpu\n");
++
+ #ifdef KERN_CP_TIME
+       length = sizeof (cpts);
+       if (sysctl (mib2, mib_length, cpts, &length, NULL, 0)) {
+@@ -125,18 +132,43 @@ glibtop_get_cpu_p (glibtop *server, glib
+       /* set iowait (really just interrupt) time */
+       buf->iowait = cpts [CP_INTR];
+ 
+-      /* set frequency */
+-      /*
+-         FIXME --  is hz, tick, profhz or stathz wanted?
+-         buf->frequency = sysctl("kern.clockrate", ...);
+-
+-         struct clockinfo
+-      */
+       buf->frequency = ci.hz;
++
+       /* set total */
+       buf->total = cpts [CP_USER] + cpts [CP_NICE]
+               + cpts [CP_SYS] + cpts [CP_IDLE];
+ 
++
++      u_int64_t *cp_times;
++        length = sizeof(cp_times[0]) * CPUSTATES * ncpu;
++        cp_times = g_malloc(length);
++      int mib[] = { CTL_KERN, KERN_CP_TIME };
++      if (sysctl (mib, 2, cp_times, &length, NULL, 0) < 0) {
++              g_free(cp_times);
++              errx(1,"Failed to get kern.cp_time\n");
++      }
++      for (i = 0; i < ncpu; i++) {
++              if (cp_times) {
++                      int offset = i * CPUSTATES;
++                      buf->xcpu_user[i] = cp_times[offset + CP_USER]; 
++                      buf->xcpu_nice[i] = cp_times[offset + CP_NICE]; 
++                      buf->xcpu_sys[i] = cp_times[offset + CP_SYS];
++                      buf->xcpu_idle[i] = cp_times[offset + CP_IDLE];
++                      buf->xcpu_irq[i] = cp_times[offset + CP_INTR];
++              } else {
++                      buf->xcpu_user[i] = cpts[CP_USER] / ncpu;
++                      buf->xcpu_nice[i] = cpts[CP_NICE] / ncpu;
++                      buf->xcpu_sys[i] = cpts[CP_SYS] / ncpu;
++                      buf->xcpu_idle[i] = cpts[CP_IDLE] / ncpu;
++                      buf->xcpu_irq[i] = cpts[CP_INTR] / ncpu;
++              }
++              buf->xcpu_total[i] = buf->xcpu_user[i] + buf->xcpu_nice[i] \
++                                   + buf->xcpu_sys[i] + buf->xcpu_idle[i] \
++                                   + buf->xcpu_irq[i];
++      }
++
++      g_free(cp_times);
++
+       /* Set the flags last. */
+       buf->flags = _glibtop_sysdeps_cpu;
+ }



Home | Main Index | Thread Index | Old Index