Bug#665999: #define HZ, libgtop and time accounting

2012-04-16 Thread Michael Biebl
Hi Christoph,

On 13.04.2012 19:46, Michael Biebl wrote:
 forwarded 665999 https://bugzilla.gnome.org/show_bug.cgi?id=674064
 thanks
 
 On 29.03.2012 00:32, Christoph Egger wrote:
 tag 665999 + patch
 quit
 
 Thanks for the patch, I've forwarded it upstream.

could you please have a look at upstream's question and reply to [1].

Cheers,
Michael

[1] https://bugzilla.gnome.org/show_bug.cgi?id=674064#c2


-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?



signature.asc
Description: OpenPGP digital signature


Bug#665999: #define HZ, libgtop and time accounting

2012-04-13 Thread Michael Biebl
forwarded 665999 https://bugzilla.gnome.org/show_bug.cgi?id=674064
thanks

On 29.03.2012 00:32, Christoph Egger wrote:
 tag 665999 + patch
 quit

Thanks for the patch, I've forwarded it upstream.


-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?



signature.asc
Description: OpenPGP digital signature


Bug#665999: #define HZ, libgtop and time accounting

2012-03-28 Thread Christoph Egger
tag 665999 + patch
quit

Michael Biebl bi...@debian.org writes:
 Source: gnome-system-monitor

 procproperties.cpp:27:23: fatal error: asm/param.h: No such file or directory

Needed for the HZ macro.

Reading why this would be needed, diving into libgtop. This is basically
for reading the rtime field of glibtop_proc_time which is filled on
linux by reading from /proc/stat 

/* clock_t  (1/100 s) */
buf-utime  = strtoull (p, p, 0);
buf-stime  = strtoull (p, p, 0);
buf-rtime = buf-utime + buf-stime;

So seemingly non-normalized values

but on freebsd  with

pinfo = kvm_getprocs (server-machine.kd, KERN_PROC_PID, pid, count);
if ((pinfo == NULL) || (count != 1)) {
glibtop_warn_io_r (server, kvm_getprocs (%d), pid);
glibtop_suid_leave (server);
return;
}

glibtop_suid_leave (server);

buf-rtime = pinfo [0].ki_runtime * 1e-6;

len = sizeof (ci);
if (sysctlbyname (kern.clockrate, ci, len, NULL, 0)) {
glibtop_warn_io_r (server, sysctl (kern.clockrate) (%d), pid);
glibtop_suid_leave (server);
return;
}

buf-frequency = (ci.stathz ? ci.stathz : ci.hz);
buf-flags = _glibtop_sysdeps_proc_time;

buf-rtime *= buf-frequency;

where kvm_getprocs is, according to [0], returning the value in
microsecs which is then normalized away with * 1e-6 and then again
multiplied by sysctl kernel.clockrate field stathz

kern.clockrate: { hz = 1000, tick = 1000, profhz = 8128, stathz = 127 }

so 127.

Please everyone recheck my math here, it's nearly 1 am in the morning
here ;-)

[0] http://bintree.net/freebsd/d8/ddb/user_8h_source.html#l00139

--- gnome-system-monitor-3.4.0.orig/src/procproperties.cpp
+++ gnome-system-monitor-3.4.0/src/procproperties.cpp
@@ -24,7 +24,14 @@
 #include glibtop/procmem.h
 #include glibtop/procmap.h
 #include glibtop/procstate.h
+#ifdef __linux__
 #include asm/param.h
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#include sys/types.h
+#include sys/sysctl.h
+#include sys/time.h
+#include assert.h
+#endif

 #include procman.h
 #include procproperties.h
@@ -106,6 +113,21 @@ fill_proc_properties (GtkWidget *tree, P
 {
 guint i;
 GtkListStore *store;
+guint hz;
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+struct clockinfo ci;
+size_t len;
+
+len = sizeof (ci);
+if (sysctlbyname (kern.clockrate, ci, len, NULL, 0)) {
+assert(false);
+}
+
+hz = (ci.stathz ? ci.stathz : ci.hz);
+#elif defined (__linux__)
+hz = HZ;
+#endif

 get_process_memory_info(info);

@@ -120,7 +142,7 @@ fill_proc_properties (GtkWidget *tree, P
 { N_(Shared Memory), format_memsize(info-memshared)},
 { N_(X Server Memory), format_memsize(info-memxserver)},
 { N_(CPU), g_strdup_printf(%d%%, info-pcpu)},
-{ N_(CPU Time), g_strdup_printf(ngettext(%lld second, %lld 
seconds, info-cpu_time/HZ), (unsigned long long)info-cpu_time/HZ) },
+{ N_(CPU Time), g_strdup_printf(ngettext(%lld second, %lld 
seconds, info-cpu_time/hz), (unsigned long long)info-cpu_time/hz) },
 { N_(Started), g_strdup_printf(%s, ctime((const 
time_t*)(info-start_time)))},
 { N_(Nice), g_strdup_printf(%d, info-nice)},
 { N_(Priority), g_strdup_printf(%s, 
procman::get_nice_level(info-nice)) },

-- 
9FED 5C6C E206 B70A 5857  70CA 9655 22B9 D49A E731
Debian Developer | Lisp Hacker | CaCert Assurer



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org