From owner-freebsd-current@FreeBSD.ORG Wed Jun 9 16:09:29 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0AFA11065672 for ; Wed, 9 Jun 2010 16:09:29 +0000 (UTC) (envelope-from uqs@spoerlein.net) Received: from acme.spoerlein.net (acme.spoerlein.net [IPv6:2001:470:9a47::1]) by mx1.freebsd.org (Postfix) with ESMTP id 8F40E8FC1B for ; Wed, 9 Jun 2010 16:09:28 +0000 (UTC) Received: from acme.spoerlein.net (localhost.spoerlein.net [IPv6:::1]) by acme.spoerlein.net (8.14.4/8.14.4) with ESMTP id o59G9Pjv063538 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 9 Jun 2010 18:09:25 +0200 (CEST) (envelope-from uqs@spoerlein.net) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=spoerlein.net; s=dkim200908; t=1276099766; bh=3Giz9PRncLRMROc6rpLvOG299QVc4+mCnH5FWv/eG28=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Transfer-Encoding:In-Reply-To; b=ZGuRE1TQZWLDLBwAK8Z1MCid+XuGJAXWYUr8QQmK7xcDJLJqsx8sDQF6aEJIicWcf S38S0YI8iFwoYh+ctJsjhU10OxzmHFDwIMyOKZuhquyDn+ch0pCAuACUy5mcCEoLAI s6TmCC2Wbri98Z+wyDsnn2OkfpVjEW7jDE39DWQo= Received: (from uqs@localhost) by acme.spoerlein.net (8.14.4/8.14.4/Submit) id o59G9P8J063537; Wed, 9 Jun 2010 18:09:25 +0200 (CEST) (envelope-from uqs@spoerlein.net) Date: Wed, 9 Jun 2010 18:09:25 +0200 From: Ulrich =?utf-8?B?U3DDtnJsZWlu?= To: Gustau =?utf-8?B?UMOpcmV6?= Message-ID: <20100609160925.GY39829@acme.spoerlein.net> Mail-Followup-To: Gustau =?utf-8?B?UMOpcmV6?= , freebsd-current@freebsd.org References: <20100609104857.GM39829@acme.spoerlein.net> <4C0F8DC6.806@entel.upc.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4C0F8DC6.806@entel.upc.edu> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-current@freebsd.org Subject: Re: Patch for really fixing bsnmpd hrProcessorLoad values X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jun 2010 16:09:29 -0000 On Wed, 09.06.2010 at 14:49:10 +0200, Gustau Pérez wrote: > En/na Ulrich Spörlein ha escrit: > > Hi guys, > > > > I finally got fed up with bsnmpd no longer returning the right CPU load > > values when running under ULE. After taking a look at how top(1) does > > it, I came up with the following initial patch to bsnmpd, that seems to > > DTRT. > > > > A few technical questions remain: > > > > - Is the idle state guaranteed to always be in the last cp_time column? > > - Is handling overflow of kern.cp_times worth it? There's only a 60s > > window of reporting wrong stats, better than what we have now anyway. > > - Why is kern.cp_times often times *way* longer than hw.ncpu * > > CPUSTATES? Is it guaranteed that the first n entries correspond to the > > first n*CPUSTATES values in kern.cp_times? Can there be holes? > > > > Patch has been tested on 8-STABLE, 4xCPUs and SCHED_ULE. Other reports > > would be very much appreciated. > > > > Regards, > > Uli > > > Hi Uli, > > I've just recompiled a RELENG_8_0 kernel, with SCHED_ULE, 2xQuad > Core and your patch applied to /usr/src. I get 0 values for all > processors : > > ***************************************************************************** > > [root@host ~]# snmpwalk -v 2c -c host IP_HOST | grep hrProcessor > HOST-RESOURCES-MIB::hrProcessorFrwID.6 = OID: SNMPv2-SMI::zeroDotZero > HOST-RESOURCES-MIB::hrProcessorFrwID.10 = OID: SNMPv2-SMI::zeroDotZero > HOST-RESOURCES-MIB::hrProcessorFrwID.14 = OID: SNMPv2-SMI::zeroDotZero > HOST-RESOURCES-MIB::hrProcessorFrwID.18 = OID: SNMPv2-SMI::zeroDotZero > HOST-RESOURCES-MIB::hrProcessorFrwID.22 = OID: SNMPv2-SMI::zeroDotZero > HOST-RESOURCES-MIB::hrProcessorFrwID.26 = OID: SNMPv2-SMI::zeroDotZero > HOST-RESOURCES-MIB::hrProcessorFrwID.30 = OID: SNMPv2-SMI::zeroDotZero > HOST-RESOURCES-MIB::hrProcessorFrwID.34 = OID: SNMPv2-SMI::zeroDotZero > HOST-RESOURCES-MIB::hrProcessorLoad.6 = INTEGER: 0 > HOST-RESOURCES-MIB::hrProcessorLoad.10 = INTEGER: 0 > HOST-RESOURCES-MIB::hrProcessorLoad.14 = INTEGER: 0 > HOST-RESOURCES-MIB::hrProcessorLoad.18 = INTEGER: 0 > HOST-RESOURCES-MIB::hrProcessorLoad.22 = INTEGER: 0 > HOST-RESOURCES-MIB::hrProcessorLoad.26 = INTEGER: 0 > HOST-RESOURCES-MIB::hrProcessorLoad.30 = INTEGER: 0 > HOST-RESOURCES-MIB::hrProcessorLoad.34 = INTEGER: 0 > HOST-RESOURCES-MIB::hrSWRunParameters.3655 = STRING: "hrProcessor" > [root@host ~]# uname -arn > FreeBSD host 8.0-RELEASE-p3 FreeBSD 8.0-RELEASE-p3 #2: Wed Jun 9 > 14:23:16 CEST 2010 root@host:/usr/obj/usr/src/sys/CUSTOM i386 > > ***************************************************************************** > > If time permits I may try it in CURRENT. But I don't know when I'll > be able ... > > Did I do anything wrong ? I applied the patch, recompiled and > reinstalled $SRC/usr.sbin/bsnmpd, recompiled $PORTS/net-mngt/bsnmp-ucd > (just in case) and then recompiled and reinstalled the kernel with ULE > (I was keeping 4BSD, because hrProcessorLoad used to work only with > 4BSD). Hello Gustau, thanks for testing this. I should have mentioned, that bsnmpd needs at least 30s to gather enough samples for the CPU load. If you still don't see anything after that, then that's my fault. Please also make sure you have some load going on. I recommend running # cpuset -c -l 0 /bin/sh # while :; do:; done which will spin while being stuck to CPU 0. If you still don't see anything, please run bsnmpd in the foreground like this: # bsnmpd -d -Devents and you should see debugging output like that: HRDEBUG: processor_refill_tbl: hw_ncpu=4 detected_processor_count=4 HRDEBUG: save_sample: CPU no. 0 state 0 value 752372 HRDEBUG: save_sample: CPU no. 0 state 1 value 1188915 HRDEBUG: save_sample: CPU no. 0 state 2 value 469569 HRDEBUG: save_sample: CPU no. 0 state 3 value 3115 HRDEBUG: save_sample: CPU no. 0 state 4 value 81501078 HRDEBUG: get_avg_usage: CPU no. 0 delta ticks 6003 pct usage 0.18 Please also provide me with the output of: # sysctl kern.boottime kern.cp_times hw.ncpu Thanks! Uli