public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Xuekun Hu <xuekun.hu@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: raybry@sgi.com, akpm@osdl.org
Subject: Re: lockmeter: fix lock counter roll over issue
Date: Mon, 15 Aug 2005 15:35:49 +0800	[thread overview]
Message-ID: <398d69300508150035246230af@mail.gmail.com> (raw)
In-Reply-To: <398d69300508132100327e3712@mail.gmail.com>

Does anyone have inputs?

On 8/14/05, Xuekun Hu <xuekun.hu@gmail.com> wrote:
> When I collected lockmeter data for a longer duration, sometimes the
> locks counter could roll over. I'm sure someone else maybe meet the
> same situation. So I wrote the below patch, could you have a look?
> 
> diff -Nraup linux/include/linux/lockmeter.h
> linux.lockmeter/include/linux/lockmeter.h
> --- linux/include/linux/lockmeter.h     2005-08-09 10:46:53.302083832 +0800
> +++ linux.lockmeter/include/linux/lockmeter.h   2005-08-05
> 17:22:37.000000000 +0800
> @@ -150,7 +150,7 @@ typedef struct {
>        uint32_t    max_wait_ww_ticks;  /* max wait time writer vs writer  */
>                                        /* prev 2 only used for write locks*/
>        uint32_t    acquire_time;       /* time lock acquired this CPU     */
> -       uint32_t    count[LSTAT_ACT_MAX_VALUES];
> +       uint64_t    count[LSTAT_ACT_MAX_VALUES];
>  } lstat_lock_counts_t;
> 
>  typedef lstat_lock_counts_t    lstat_cpu_counts_t[LSTAT_MAX_STAT_INDEX];
> @@ -167,7 +167,7 @@ typedef lstat_lock_counts_t lstat_cpu_co
>  #define LSTAT_MAX_READ_LOCK_INDEX 1000
>  typedef struct {
>        POINTER     lock_ptr;            /* address of lock for output stats */
> -       uint32_t    read_lock_count;
> +       uint64_t    read_lock_count;
>        int64_t     cum_hold_ticks;       /* sum of read lock hold times over */
>                                          /* all callers. ....................*/
>        uint32_t    write_index;          /* last write lock hash table index */
> 
> I also modified lockstat to compliant with this modification against
> lockstat 1.4.11 version.
> 
> diff -Nraup lockstat/include/linux/lockmeter.h
> lockstat.fix/include/linux/lockmeter.h
> --- lockstat/include/linux/lockmeter.h  2004-09-14 07:02:05.000000000 +0800
> +++ lockstat.fix/include/linux/lockmeter.h      2005-08-05 17:38:46.000000000 +0800
> @@ -150,7 +150,7 @@ typedef struct {
>        uint32_t    max_wait_ww_ticks;  /* max wait time writer vs writer  */
>                                        /* prev 2 only used for write locks*/
>        uint32_t    acquire_time;       /* time lock acquired this CPU     */
> -       uint32_t    count[LSTAT_ACT_MAX_VALUES];
> +       uint64_t    count[LSTAT_ACT_MAX_VALUES];
>  } lstat_lock_counts_t;
> 
>  typedef lstat_lock_counts_t    lstat_cpu_counts_t[LSTAT_MAX_STAT_INDEX];
> @@ -167,7 +167,7 @@ typedef lstat_lock_counts_t lstat_cpu_co
>  #define LSTAT_MAX_READ_LOCK_INDEX 1000
>  typedef struct {
>        POINTER     lock_ptr;            /* address of lock for output stats */
> -       uint32_t    read_lock_count;
> +       uint64_t    read_lock_count;
>        int64_t     cum_hold_ticks;       /* sum of read lock hold times over */
>                                          /* all callers. ....................*/
>        uint32_t    write_index;          /* last write lock hash table index */
> diff -Nraup lockstat/lockstat.c lockstat.fix/lockstat.c
> --- lockstat/lockstat.c 2004-09-14 07:01:41.000000000 +0800
> +++ lockstat.fix/lockstat.c     2005-08-09 10:35:18.305356776 +0800
> @@ -36,7 +36,7 @@ static char lockstat_version[]  = "1.4.1
>  #include <stdlib.h>
>  #include <string.h>
>  #include <errno.h>
> -#include <sys/time.h>
> +#include <time.h>
>  #include <linux/lockmeter.h>
> 
>  extern void    closeFiles(void);
> @@ -267,7 +267,7 @@ typedef enum        {Null_Entry, Spin_Entry, RL
> 
>  typedef struct {
>        lstat_lock_counts_t  counts;
> -       uint32_t        total;
> +       uint64_t        total;
>        double          contention;
>        double          persec;
>        double          utilization;
> @@ -999,7 +999,8 @@ add_counts(lock_summary_t *sump, lstat_l
>  int
>  sum_counts(lock_summary_t *sump, entry_type_enum entry_type)
>  {
> -       int             total, i, j;
> +       int             i, j;
> +       uint64_t        total;
>        double  contention;
>        double  utilization;
> 
> @@ -1171,7 +1172,7 @@ print_lock(char *name, lock_summary_t *s
>        float mean_hold_time, max_hold_time;
>        float wait_time, mean_wait_time, max_wait_time, mean_wait_ww_time,
> max_wait_ww_time;
>        double temp_time;
> -       uint32_t total_spin_count = 0;
> +       uint64_t total_spin_count = 0;
> 
>        print_header();
> 
> @@ -1317,7 +1318,7 @@ print_lock(char *name, lock_summary_t *s
>        }
> 
>        /* following done for ALL types of locks, except as indicated */
> -       printf(" %9d", sump->total);
> +       printf(" %20ld", sump->total);
>        print_percentage('
> ',100.0*(double)sump->counts.count[LSTAT_ACT_NO_WAIT]/(double)sump->total,0);
>        print_percentage('
> ',100.0*(double)sump->counts.count[LSTAT_ACT_SPIN]/(double)sump->total,0);
>        if (entry_type == WLspin_Entry) {
> @@ -1325,7 +1326,7 @@ print_lock(char *name, lock_summary_t *s
>                                 ')');
>        }
>  #ifdef notyet
> -       printf("%9d", sump->counts.count[LSTAT_ACT_SLEPT]);
> +       printf("%20ld", sump->counts.count[LSTAT_ACT_SLEPT]);
>  #endif
>        if (entry_type == Spin_Entry) {
>                /* We only see these for spinlock_t, and even then it's rare. */
> 
> Any comments?
>

  reply	other threads:[~2005-08-15  7:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-14  4:00 lockmeter: fix lock counter roll over issue Xuekun Hu
2005-08-15  7:35 ` Xuekun Hu [this message]
2005-08-15 14:16   ` Ray Bryant
2005-08-18 12:41     ` Xuekun Hu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=398d69300508150035246230af@mail.gmail.com \
    --to=xuekun.hu@gmail.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=raybry@sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox