NetBSD Problem Report #34671

From jandres@gmx.net  Sat Sep 30 13:09:18 2006
Return-Path: <jandres@gmx.net>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id F1F6063B8CA
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 30 Sep 2006 13:09:17 +0000 (UTC)
Message-Id: <20060930130914.85E311EC7@delta.home.jan>
Date: Sat, 30 Sep 2006 15:09:14 +0200 (MEST)
From: Jan Andres <jandres@gmx.net>
Reply-To: jandres@gmx.net
To: gnats-bugs@NetBSD.org
Subject: [Patch] 64-bitness fix and some enhancements to the net-snmp port
X-Send-Pr-Version: 3.95

>Number:         34671
>Category:       pkg
>Synopsis:       [Patch] 64-bitness fix and some enhancements to the net-snmp port
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    adam
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Sep 30 13:10:00 +0000 2006
>Closed-Date:    Mon Oct 19 18:43:37 +0000 2020
>Last-Modified:  Mon Oct 19 18:43:37 +0000 2020
>Originator:     Jan Andres
>Release:        NetBSD 4.0_BETA
>Organization:

>Environment:


System: NetBSD delta.home.jan 4.0_BETA NetBSD 4.0_BETA (DELTA_PF) #2: Wed Aug 9 06:39:28 MEST 2006 jan@pitr.home.jan:/xfs/0/jan/nb/obj-alpha/sys/arch/alpha/compile/DELTA_PF alpha
Architecture: alpha
Machine: alpha
>Description:
I've made some small fixes and enhancements to the net-snmp port:

- Support for 64-bit counters in the Disk I/O MIB
- Support raw counters for IRQs, context switches, swap I/O (in ucd-snmp
  MIB)
- Fix 64-bitness issue in measurement of CPU usage. int is used as target
  of the oldlenp pointer passed to sysctl(3) where it should be size_t.

I've emailed those patches to the port maintainer a while ago, but he
never replied.

Please find the patch in the "Fix" section.

Regards,
Jan

>How-To-Repeat:

>Fix:
diff -ur net-snmp-5.3.1/agent/mibgroup/ucd-snmp/diskio.c net-snmp-5.3.1-patched/agent/mibgroup/ucd-snmp/diskio.c
--- net-snmp-5.3.1/agent/mibgroup/ucd-snmp/diskio.c	2006-09-30 14:36:55.000000000 +0200
+++ net-snmp-5.3.1-patched/agent/mibgroup/ucd-snmp/diskio.c	2006-09-30 14:35:38.000000000 +0200
@@ -498,8 +498,9 @@
            size_t * length,
            int exact, size_t * var_len, WriteMethod ** write_method)
 {
-    static long     long_ret;
-    unsigned int    indx;
+    static long               long_ret;
+    static struct counter64   c64_ret;
+    unsigned int              indx;

     if (getstats() == 0)
         return 0;
@@ -561,6 +562,32 @@
 #endif
         return (u_char *) & long_ret;

+    case DISKIO_NREADX:
+#ifdef HW_DISKSTATS
+     	c64_ret.low = dk[indx].dk_rbytes & 0xffffffff;
+     	c64_ret.high = dk[indx].dk_rbytes >> 32;
+#endif
+#ifdef HW_IOSTATS
+	if (dk[indx].type == IOSTAT_DISK) {
+	    c64_ret.low = dk[indx].rbytes & 0xffffffff;
+	    c64_ret.high = dk[indx].rbytes >> 32;
+	}
+#endif
+        return (u_char *) & c64_ret;
+
+    case DISKIO_NWRITTENX:
+#ifdef HW_DISKSTATS
+     	c64_ret.low = dk[indx].dk_wbytes & 0xffffffff;
+     	c64_ret.high = dk[indx].dk_wbytes >> 32;
+#endif
+#ifdef HW_IOSTATS
+	if (dk[indx].type == IOSTAT_DISK) {
+	    c64_ret.low = dk[indx].wbytes & 0xffffffff;
+	    c64_ret.high = dk[indx].wbytes >> 32;
+	}
+#endif
+        return (u_char *) & c64_ret;
+
     default:
         ERROR_MSG("diskio.c: don't know how to handle this request.");
     }
diff -ur net-snmp-5.3.1/agent/mibgroup/ucd-snmp/vmstat_netbsd1.c net-snmp-5.3.1-patched/agent/mibgroup/ucd-snmp/vmstat_netbsd1.c
--- net-snmp-5.3.1/agent/mibgroup/ucd-snmp/vmstat_netbsd1.c	2004-07-07 22:31:54.000000000 +0200
+++ net-snmp-5.3.1-patched/agent/mibgroup/ucd-snmp/vmstat_netbsd1.c	2006-09-30 14:35:42.000000000 +0200
@@ -95,6 +95,14 @@
          {CPURAWKERNEL}},
         {CPURAWINTR, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
          {CPURAWINTR}},
+        {SYSRAWINTERRUPTS, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
+         {SYSRAWINTERRUPTS}},
+        {SYSRAWCONTEXT, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
+         {SYSRAWCONTEXT}},
+        {RAWSWAPIN, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
+         {RAWSWAPIN}},
+        {RAWSWAPOUT, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
+         {RAWSWAPOUT}},

         /*
          * Future use: 
@@ -170,7 +178,7 @@

     static struct uvmexp mem_old, mem_new;
     int             mem_mib[] = { CTL_VM, VM_UVMEXP };
-    int             mem_size = sizeof(struct uvmexp);
+    size_t          mem_size = sizeof(struct uvmexp);

     static long     long_ret;
     static char     errmsg[300];
@@ -186,13 +194,13 @@
     if (time_new != time_old) {
 #ifdef KERN_CP_TIME
         int             mib[2] = { CTL_KERN, KERN_CP_TIME };
-        int             ssize = sizeof(cpu_new);
+        size_t          ssize = sizeof(cpu_new);

         if (sysctl(mib, 2, cpu_new, &ssize, NULL, 0) < 0)
             memset(cpu_new, 0, sizeof(cpu_new));
 #elif defined(KERN_CPTIME)
         int             mib[2] = { CTL_KERN, KERN_CPTIME };
-        int             ssize = sizeof(cpu_new);
+        size_t          ssize = sizeof(cpu_new);

         if (sysctl(mib, 2, cpu_new, &ssize, NULL, 0) < 0)
             memset(cpu_new, 0, sizeof(cpu_new));
@@ -301,6 +309,20 @@
     case CPURAWINTR:
         long_ret = cpu_new[CP_INTR];
         return ((u_char *) (&long_ret));
+    case SYSRAWINTERRUPTS:
+        long_ret = mem_new.intrs;
+        return ((u_char *) (&long_ret));
+    case SYSRAWCONTEXT:
+        long_ret = mem_new.swtch;
+        return ((u_char *) (&long_ret));
+    case RAWSWAPIN:
+        long_ret = mem_new.pgswapin * (mem_new.pagesize >> 9);
+        return ((u_char *) (&long_ret));
+    case RAWSWAPOUT:
+        long_ret = mem_new.pgswapout * (mem_new.pagesize >> 9);
+        return ((u_char *) (&long_ret));
+
+
         /*
          * reserved for future use 
          */

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->adam
Responsible-Changed-By: reed@netbsd.org
Responsible-Changed-When: Sat, 30 Sep 2006 13:28:34 +0000
Responsible-Changed-Why:
Assigned to maintainer.


From: Sergey Svishchev <svs@ropnet.ru>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/34671
Date: Tue, 18 Oct 2011 22:46:13 +0400

 64-bit diskio patch is already merged upstream, others aren't.

 -- 
 Sergey Svishchev

State-Changed-From-To: open->feedback
State-Changed-By: christos@NetBSD.org
State-Changed-When: Thu, 04 Apr 2013 19:56:51 -0400
State-Changed-Why:
this is probably fixed by now


State-Changed-From-To: feedback->closed
State-Changed-By: bsiegert@NetBSD.org
State-Changed-When: Mon, 19 Oct 2020 18:43:37 +0000
State-Changed-Why:
feedback timeout


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.