From owner-lockmeter@oss.sgi.com Wed May 31 07:57:35 2000 Received: by oss.sgi.com id ; Wed, 31 May 2000 07:57:26 -0700 Received: from lowell.missioncriticallinux.com ([208.51.139.16]:21882 "EHLO orourke.mclinux.com") by oss.sgi.com with ESMTP id ; Wed, 31 May 2000 07:57:11 -0700 Received: from orourke.mclinux.com (IDENT:orourke@localhost.localdomain [127.0.0.1]) by orourke.mclinux.com (8.9.3/8.9.3) with ESMTP id KAA02082 for ; Wed, 31 May 2000 10:58:42 -0400 Message-Id: <200005311458.KAA02082@orourke.mclinux.com> X-Mailer: exmh version 2.0.3 To: lockmeter@oss.sgi.com Subject: bug in lockstat Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 31 May 2000 10:58:42 -0400 From: "Pat O'Rourke" Sender: owner-lockmeter@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;lockmeter-outgoing The function get_kernel_data() in lockstat has a hardcoded assumption that jiffies is incremented 100X / second, which is incorrect for alpha based systems. The command also re-defined the HZ macro (also to be 100). Here is a patch which will take HZ from param.h and replace the hardcoded use of 100.0 with a call to sysconf(). This seems to do the right thing on both x86 and alpha architectures, although there may be a more appropriate method. Pat $ diff -u lockstat.c /tmp/lockstat.c --- lockstat.c Tue Apr 4 12:54:15 2000 +++ /tmp/lockstat.c Wed May 31 10:43:13 2000 @@ -30,6 +30,8 @@ #include #include #include +#include +#include typedef unsigned int uint32_t; typedef unsigned long long uint64_t; @@ -43,8 +45,6 @@ #define TSTAMP(s) #endif -#define HZ 100 - char *helpstr[] = { "Name" " lockstat - display kernel lock statistics", @@ -789,10 +789,13 @@ int ret_count; int cpu_counts_len; int directory_len; + double ticks; if (debugopt == 2) return; + ticks = (double)sysconf(_SC_CLK_TCK); + ret_count = read(dataFile, general_read_buf, general_read_buf_len); if (ret_count != general_read_buf_len) { fprintf(stderr, @@ -839,7 +842,7 @@ } end_time = request.current_time; end_jiffies = request.current_jiffies; - deltatime = (double) (end_jiffies - start_jiffies) / 100.0; + deltatime = (double) (end_jiffies - start_jiffies) / ticks; } next_free_dir_index = request.next_free_dir_index; -- Patrick O'Rourke orourke@missioncriticallinux.com From owner-lockmeter@oss.sgi.com Wed May 31 08:21:45 2000 Received: by oss.sgi.com id ; Wed, 31 May 2000 08:21:35 -0700 Received: from mercury.Sun.COM ([192.9.25.1]:39382 "EHLO mercury.Sun.COM") by oss.sgi.com with ESMTP id ; Wed, 31 May 2000 08:21:13 -0700 Received: from emuc05-home.Germany.Sun.COM ([129.157.51.10]) by mercury.Sun.COM (8.9.3+Sun/8.9.3) with ESMTP id IAA23088 for ; Wed, 31 May 2000 08:22:31 -0700 (PDT) Received: from sunhsc (sunhsc [129.157.167.92]) by emuc05-home.Germany.Sun.COM (8.8.8+Sun/8.8.8/ENSMAIL,v1.7) with SMTP id RAA12925 for ; Wed, 31 May 2000 17:22:30 +0200 (MET DST) Message-Id: <200005311522.RAA12925@emuc05-home.Germany.Sun.COM> Date: Wed, 31 May 2000 17:24:47 +0200 (MET DST) From: Frank Hofmann - Sun Germany Technical Solution Center - Munich Reply-To: Frank Hofmann - Sun Germany Technical Solution Center - Munich Subject: Re: bug in lockstat To: lockmeter@oss.sgi.com MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii Content-MD5: /gC1SicmwSWn4P2S9+XHZg== X-Mailer: dtmail 1.3.0 @(#)CDE Version 1.3.2 SunOS 5.7 sun4u sparc Sender: owner-lockmeter@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;lockmeter-outgoing > To: lockmeter@oss.sgi.com > Subject: bug in lockstat > Mime-Version: 1.0 > X-Orcpt: rfc822;lockmeter@oss.sgi.com > > > The function get_kernel_data() in lockstat has a hardcoded assumption > that jiffies is incremented 100X / second, which is incorrect for alpha > based systems. The command also re-defined the HZ macro (also to be 100). > > Here is a patch which will take HZ from param.h and replace the hardcoded > use of 100.0 with a call to sysconf(). This seems to do the right thing > on both x86 and alpha architectures, although there may be a more appropriate > method. If I remember right, this was done back then because on 2.2.x some architectures did not provide a HZ define. I've checked 2.3.99 with regard to this; all asm/param.h have the define by now. Bye, Frank Hofmann > > Pat > > $ diff -u lockstat.c /tmp/lockstat.c > --- lockstat.c Tue Apr 4 12:54:15 2000 > +++ /tmp/lockstat.c Wed May 31 10:43:13 2000 > @@ -30,6 +30,8 @@ > #include > #include > #include > +#include > +#include > > typedef unsigned int uint32_t; > typedef unsigned long long uint64_t; > @@ -43,8 +45,6 @@ > #define TSTAMP(s) > #endif > > -#define HZ 100 > - > char *helpstr[] = { > "Name" > " lockstat - display kernel lock statistics", > @@ -789,10 +789,13 @@ > int ret_count; > int cpu_counts_len; > int directory_len; > + double ticks; > > if (debugopt == 2) > return; > > + ticks = (double)sysconf(_SC_CLK_TCK); > + > ret_count = read(dataFile, general_read_buf, general_read_buf_len); > if (ret_count != general_read_buf_len) { > fprintf(stderr, > @@ -839,7 +842,7 @@ > } > end_time = request.current_time; > end_jiffies = request.current_jiffies; > - deltatime = (double) (end_jiffies - start_jiffies) / 100.0; > + deltatime = (double) (end_jiffies - start_jiffies) / ticks; > } > > next_free_dir_index = request.next_free_dir_index; > > -- > Patrick O'Rourke > orourke@missioncriticallinux.com >