Hello all.

On Thu, Oct 13, 2016 at 01:29:31PM +0000, Luca BRUNO wrote:
> On Thursday, 13 October 2016 13:59:27 UTC Andreas Henriksson wrote:
>  
> > Fwiw, there's a chain of {build-,}dependencies that would need to be
> > removed on ppc64el
> 
> Ah, when I wrote my previous answer I didn't realize that.
> Upon further inspection, it looks like it may be just enough to cherry-pick
> this fix on top of gopsutil:
> https://github.com/shirou/gopsutil/pull/261

I've tested applying PR 259 and 261 which indeed fixes the build on ppc64le
but the test-suite still fails.

The problem seems to boil down to gopsutil parsing of /proc/cpuinfo being
extremely (x86 centricly) naive, as cpuinfo content is very architecture
specific. Furter discussion on that topic is probably needed upstream...
Just satisfying what the testsuite needs to call it success is quite
simple though by treating "cpu" field as meaning the same as "model name".

I'm attaching a debdiff which I've testbuilt on the debian ppc64le porterbox.

(Despite this debdiff, asking for removal could possibly be a better
idea as there's obviously not enough backing to properly support ppc64le
right now and thus probably not for the lifetime of stretch.)

Regards,
Andreas Henriksson
diff -Nru golang-github-shirou-gopsutil-2.1/debian/changelog 
golang-github-shirou-gopsutil-2.1/debian/changelog
--- golang-github-shirou-gopsutil-2.1/debian/changelog  2016-07-14 
07:23:30.000000000 +0000
+++ golang-github-shirou-gopsutil-2.1/debian/changelog  2016-10-14 
08:43:23.000000000 +0000
@@ -1,3 +1,15 @@
+golang-github-shirou-gopsutil (2.1-2.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Add debian/patches/259.patch and debian/patches/261.patch
+    - upstream PR 259 + 261, should fix build on ppc64el.
+  * Add debian/patches/gopsutil-ppc64le-model-name.patch
+    - ppc64le /proc/cpuinfo doesn't follow the same style as x86 and
+      test-suite require atleast the "model name" field. Map that
+      to the "cpu" field which exists on ppc64le for now.
+
+ -- Andreas Henriksson <andr...@fatal.se>  Fri, 14 Oct 2016 08:43:23 +0000
+
 golang-github-shirou-gopsutil (2.1-2) unstable; urgency=medium
 
   * Extend "01-Disable_failing_tests.patch" to disable failing
diff -Nru golang-github-shirou-gopsutil-2.1/debian/patches/259.patch 
golang-github-shirou-gopsutil-2.1/debian/patches/259.patch
--- golang-github-shirou-gopsutil-2.1/debian/patches/259.patch  1970-01-01 
00:00:00.000000000 +0000
+++ golang-github-shirou-gopsutil-2.1/debian/patches/259.patch  2016-10-14 
08:43:23.000000000 +0000
@@ -0,0 +1,83 @@
+From eb4a57117f5b734246226c9b6d6b1f9edca2e4f2 Mon Sep 17 00:00:00 2001
+From: Thomas Hipp <th...@suse.de>
+Date: Fri, 16 Sep 2016 09:04:52 +0200
+Subject: [PATCH] process: determine page sizes via function
+
+Instead of hard-coding the page size for linux systems, use Go's
+`Getpagesize` function.
+
+This resolves #258.
+
+Signed-off-by: Thomas Hipp <th...@suse.de>
+---
+ process/process_linux.go       | 5 ++++-
+ process/process_linux_386.go   | 3 +--
+ process/process_linux_amd64.go | 3 +--
+ process/process_linux_arm.go   | 3 +--
+ process/process_linux_arm64.go | 3 +--
+ 5 files changed, 8 insertions(+), 9 deletions(-)
+
+diff --git a/process/process_linux.go b/process/process_linux.go
+index 158cb04..9eb4f44 100644
+--- a/process/process_linux.go
++++ b/process/process_linux.go
+@@ -20,7 +20,10 @@ import (
+       "github.com/shirou/gopsutil/net"
+ )
+ 
+-var ErrorNoChildren = errors.New("process does not have children")
++var (
++      ErrorNoChildren = errors.New("process does not have children")
++      PageSize        = uint64(os.Getpagesize())
++)
+ 
+ const (
+       PrioProcess = 0 // linux/resource.h
+diff --git a/process/process_linux_386.go b/process/process_linux_386.go
+index 541b854..c4df213 100644
+--- a/process/process_linux_386.go
++++ b/process/process_linux_386.go
+@@ -4,6 +4,5 @@
+ package process
+ 
+ const (
+-      ClockTicks = 100  // C.sysconf(C._SC_CLK_TCK)
+-      PageSize   = 4096 // C.sysconf(C._SC_PAGE_SIZE)
++      ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK)
+ )
+diff --git a/process/process_linux_amd64.go b/process/process_linux_amd64.go
+index b4a4ce8..99b6659 100644
+--- a/process/process_linux_amd64.go
++++ b/process/process_linux_amd64.go
+@@ -4,6 +4,5 @@
+ package process
+ 
+ const (
+-      ClockTicks = 100  // C.sysconf(C._SC_CLK_TCK)
+-      PageSize   = 4096 // C.sysconf(C._SC_PAGE_SIZE)
++      ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK)
+ )
+diff --git a/process/process_linux_arm.go b/process/process_linux_arm.go
+index c6123a4..8aef44c 100644
+--- a/process/process_linux_arm.go
++++ b/process/process_linux_arm.go
+@@ -4,6 +4,5 @@
+ package process
+ 
+ const (
+-      ClockTicks = 100  // C.sysconf(C._SC_CLK_TCK)
+-      PageSize   = 4096 // C.sysconf(C._SC_PAGE_SIZE)
++      ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK)
+ )
+diff --git a/process/process_linux_arm64.go b/process/process_linux_arm64.go
+index 529aeaa..493197c 100644
+--- a/process/process_linux_arm64.go
++++ b/process/process_linux_arm64.go
+@@ -4,6 +4,5 @@
+ package process
+ 
+ const (
+-      ClockTicks = 100  // C.sysconf(C._SC_CLK_TCK)
+-      PageSize   = 4096 // C.sysconf(C._SC_PAGE_SIZE)
++      ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK)
+ )
diff -Nru golang-github-shirou-gopsutil-2.1/debian/patches/261.patch 
golang-github-shirou-gopsutil-2.1/debian/patches/261.patch
--- golang-github-shirou-gopsutil-2.1/debian/patches/261.patch  1970-01-01 
00:00:00.000000000 +0000
+++ golang-github-shirou-gopsutil-2.1/debian/patches/261.patch  2016-10-14 
08:43:23.000000000 +0000
@@ -0,0 +1,94 @@
+From 68ad8d603c624c5f4dc986b333303da565570aa3 Mon Sep 17 00:00:00 2001
+From: Thomas Hipp <thomash...@gmail.com>
+Date: Sat, 17 Sep 2016 18:06:07 +0200
+Subject: [PATCH] process: make `ClockTicks` arch-independent
+
+The value for `ClockTicks` is defined as `100` by the Linux kernel for
+all currently supported architectures in Go. Therefore, there is no need
+to define this constant for each architecture separately.
+
+This fixes #260.
+
+Signed-off-by: Thomas Hipp <thomash...@gmail.com>
+---
+ process/process_linux.go       | 3 ++-
+ process/process_linux_386.go   | 8 --------
+ process/process_linux_amd64.go | 8 --------
+ process/process_linux_arm.go   | 8 --------
+ process/process_linux_arm64.go | 8 --------
+ 5 files changed, 2 insertions(+), 33 deletions(-)
+ delete mode 100644 process/process_linux_386.go
+ delete mode 100644 process/process_linux_amd64.go
+ delete mode 100644 process/process_linux_arm.go
+ delete mode 100644 process/process_linux_arm64.go
+
+diff --git a/process/process_linux.go b/process/process_linux.go
+index 9eb4f44..19c6655 100644
+--- a/process/process_linux.go
++++ b/process/process_linux.go
+@@ -26,7 +26,8 @@ var (
+ )
+ 
+ const (
+-      PrioProcess = 0 // linux/resource.h
++      PrioProcess = 0   // linux/resource.h
++      ClockTicks  = 100 // C.sysconf(C._SC_CLK_TCK)
+ )
+ 
+ // MemoryInfoExStat is different between OSes
+diff --git a/process/process_linux_386.go b/process/process_linux_386.go
+deleted file mode 100644
+index c4df213..0000000
+--- a/process/process_linux_386.go
++++ /dev/null
+@@ -1,8 +0,0 @@
+-// +build linux
+-// +build 386
+-
+-package process
+-
+-const (
+-      ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK)
+-)
+diff --git a/process/process_linux_amd64.go b/process/process_linux_amd64.go
+deleted file mode 100644
+index 99b6659..0000000
+--- a/process/process_linux_amd64.go
++++ /dev/null
+@@ -1,8 +0,0 @@
+-// +build linux
+-// +build amd64
+-
+-package process
+-
+-const (
+-      ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK)
+-)
+diff --git a/process/process_linux_arm.go b/process/process_linux_arm.go
+deleted file mode 100644
+index 8aef44c..0000000
+--- a/process/process_linux_arm.go
++++ /dev/null
+@@ -1,8 +0,0 @@
+-// +build linux
+-// +build arm
+-
+-package process
+-
+-const (
+-      ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK)
+-)
+diff --git a/process/process_linux_arm64.go b/process/process_linux_arm64.go
+deleted file mode 100644
+index 493197c..0000000
+--- a/process/process_linux_arm64.go
++++ /dev/null
+@@ -1,8 +0,0 @@
+-// +build linux
+-// +build arm64
+-
+-package process
+-
+-const (
+-      ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK)
+-)
diff -Nru 
golang-github-shirou-gopsutil-2.1/debian/patches/gopsutil-ppc64le-model-name.patch
 
golang-github-shirou-gopsutil-2.1/debian/patches/gopsutil-ppc64le-model-name.patch
--- 
golang-github-shirou-gopsutil-2.1/debian/patches/gopsutil-ppc64le-model-name.patch
  1970-01-01 00:00:00.000000000 +0000
+++ 
golang-github-shirou-gopsutil-2.1/debian/patches/gopsutil-ppc64le-model-name.patch
  2016-10-14 08:43:23.000000000 +0000
@@ -0,0 +1,18 @@
+From: Andreas Henriksson <andr...@fatal.se>
+Subject: use "cpu" as equivalent to "model name" field in /proc/cpuinfo
+
+ppc64le /proc/cpuinfo has no model name field.
+
+diff --git a/cpu/cpu_linux.go b/cpu/cpu_linux.go
+index 3537b2d..a8bfe58 100644
+--- a/cpu/cpu_linux.go
++++ b/cpu/cpu_linux.go
+@@ -144,7 +144,7 @@ func Info() ([]InfoStat, error) {
+                       c.Family = value
+               case "model":
+                       c.Model = value
+-              case "model name":
++              case "model name", "cpu":
+                       c.ModelName = value
+               case "stepping":
+                       t, err := strconv.ParseInt(value, 10, 64)
diff -Nru golang-github-shirou-gopsutil-2.1/debian/patches/series 
golang-github-shirou-gopsutil-2.1/debian/patches/series
--- golang-github-shirou-gopsutil-2.1/debian/patches/series     2016-06-20 
03:21:58.000000000 +0000
+++ golang-github-shirou-gopsutil-2.1/debian/patches/series     2016-10-14 
08:43:23.000000000 +0000
@@ -1 +1,4 @@
 01-Disable_failing_tests.patch
+259.patch
+261.patch
+gopsutil-ppc64le-model-name.patch

Reply via email to