From owner-freebsd-ports-bugs@FreeBSD.ORG Sun Dec 18 13:20:09 2011 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BDF411065670 for ; Sun, 18 Dec 2011 13:20:09 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 908F18FC19 for ; Sun, 18 Dec 2011 13:20:09 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id pBIDK915071657 for ; Sun, 18 Dec 2011 13:20:09 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id pBIDK9w8071656; Sun, 18 Dec 2011 13:20:09 GMT (envelope-from gnats) Resent-Date: Sun, 18 Dec 2011 13:20:09 GMT Resent-Message-Id: <201112181320.pBIDK9w8071656@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Rene Ladan Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C5FA1065673 for ; Sun, 18 Dec 2011 13:10:35 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 2BBE18FC1C for ; Sun, 18 Dec 2011 13:10:35 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id pBIDAZ3w025886 for ; Sun, 18 Dec 2011 13:10:35 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id pBIDAY0d025885; Sun, 18 Dec 2011 13:10:34 GMT (envelope-from nobody) Message-Id: <201112181310.pBIDAY0d025885@red.freebsd.org> Date: Sun, 18 Dec 2011 13:10:34 GMT From: Rene Ladan To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/163430: sysutils/xfce4-cpugraph-plugin : fix multiple CPU support X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Dec 2011 13:20:09 -0000 >Number: 163430 >Category: ports >Synopsis: sysutils/xfce4-cpugraph-plugin : fix multiple CPU support >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Dec 18 13:20:09 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Rene Ladan >Release: FreeBSD 10.0/amd64 >Organization: FreeBSD/Xfce team >Environment: FreeBSD acer 10.0-CURRENT FreeBSD 10.0-CURRENT #8 r228276M: Mon Dec 5 14:33:06 CET 2011 rene@acer:/usr/obj/usr/src/sys/ACER amd64 kernel = GENERIC + netmap + CAPABILITIES xfce4-cpugraph-plugin-1.0.1_1 >Description: This patch fixes support for multiple CPUs/cores (as determined by `sysctl hw.ncpu') on FreeBSD: - modify detect_cpu_number() to return the output of `sysctl hw.ncpu' (via sysctl(3)) instead of the constant 1 - modify read_cpu_data() to return the data of CPU/core i in data[i] and the average in data[0].load . Note that data[0].previous_used and data[0].previous_total are not longer written, which is also the case for the NetBSD/OpenBSD case. - Bump PORTREVISION >How-To-Repeat: >Fix: Patch attached with submission follows: ? work Index: Makefile =================================================================== RCS file: /home/pcvs/ports/sysutils/xfce4-cpugraph-plugin/Makefile,v retrieving revision 1.41 diff -u -r1.41 Makefile --- Makefile 26 Oct 2011 20:27:20 -0000 1.41 +++ Makefile 18 Dec 2011 12:59:11 -0000 @@ -7,7 +7,7 @@ PORTNAME= xfce4-cpugraph-plugin PORTVERSION= 1.0.1 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= sysutils xfce MASTER_SITES= ${MASTER_SITE_XFCE} MASTER_SITE_SUBDIR= src/panel-plugins/${PORTNAME}/${PORTVERSION:R} Index: files/patch-panel-plugin__os.c =================================================================== RCS file: files/patch-panel-plugin__os.c diff -N files/patch-panel-plugin__os.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ files/patch-panel-plugin__os.c 18 Dec 2011 12:59:11 -0000 @@ -0,0 +1,57 @@ +--- panel-plugin/os.c.orig 2010-11-07 13:58:22.000000000 +0100 ++++ panel-plugin/os.c 2011-12-18 13:52:22.000000000 +0100 +@@ -134,28 +134,41 @@ + #elif defined (__FreeBSD__) + guint detect_cpu_number() + { +- return 1; ++ static gint mib[] = {CTL_HW, HW_NCPU}; ++ gint ncpu; ++ gsize len = sizeof( gint ); ++ if( sysctl( mib, 2, &ncpu, &len, NULL, 0 ) < 0 ) ++ return 0; ++ else ++ return ncpu; + } + + gboolean read_cpu_data( CpuData *data, guint nb_cpu) + { + glong used, total; +- glong cp_time[CPUSTATES]; ++ glong cp_time[CPUSTATES * nb_cpu]; ++ glong *cp_time1; + gsize len = sizeof( cp_time ); ++ gint i; + +- if( sysctlbyname( "kern.cp_time", &cp_time, &len, NULL, 0 ) < 0 ) ++ data[0].load = 0; ++ if( sysctlbyname( "kern.cp_times", &cp_time, &len, NULL, 0 ) < 0 ) + return FALSE; ++ for (i = 1; i <= nb_cpu; i++ ) ++ { ++ cp_time1 = cp_time + CPUSTATES * (i - 1); ++ used = cp_time1[CP_USER] + cp_time1[CP_NICE] + cp_time1[CP_SYS] + cp_time1[CP_INTR]; ++ total = used + cp_time1[CP_IDLE]; ++ if( (total - data[i].previous_total) != 0 ) ++ data[i].load = (CPU_SCALE * (used - data[i].previous_used))/(total - data[i].previous_total); ++ else ++ data[i].load = 0; + +- used = cp_time[CP_USER] + cp_time[CP_NICE] + cp_time[CP_SYS] + cp_time[CP_INTR]; +- total = used + cp_time[CP_IDLE]; +- if( (total - data[0].previous_total) != 0 ) +- data[0].load = (CPU_SCALE * (used - data[0].previous_used))/(total - data[0].previous_total); +- else +- data[0].load = 0; +- +- data[0].previous_used = used; +- data[0].previous_total = total; +- ++ data[i].previous_used = used; ++ data[i].previous_total = total; ++ data[0].load += data[i].load; ++ } ++ data[0].load /= nb_cpu; + return TRUE; + } + >Release-Note: >Audit-Trail: >Unformatted: