lockmeter
[Top] [All Lists]

Re: bug in lockstat

To: lockmeter@xxxxxxxxxxx
Subject: Re: bug in lockstat
From: Frank Hofmann - Sun Germany Technical Solution Center - Munich <Frank.Hofmann@xxxxxxxxxxxxxxx>
Date: Wed, 31 May 2000 17:24:47 +0200 (MET DST)
Reply-to: Frank Hofmann - Sun Germany Technical Solution Center - Munich <Frank.Hofmann@xxxxxxxxxxxxxxx>
Sender: owner-lockmeter@xxxxxxxxxxx
> To: lockmeter@xxxxxxxxxxx
> Subject: bug in lockstat
> Mime-Version: 1.0
> X-Orcpt: rfc822;lockmeter@xxxxxxxxxxx
> 
> 
> 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 <string.h>
>  #include <sys/time.h>
>  #include <sys/utsname.h>
> +#include <sys/param.h>
> +#include <unistd.h>
>  
>  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@xxxxxxxxxxxxxxxxxxxxxxxx
> 


<Prev in Thread] Current Thread [Next in Thread>
  • bug in lockstat, Pat O'Rourke
    • Re: bug in lockstat, Frank Hofmann - Sun Germany Technical Solution Center - Munich <=