~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to libdb/mp/mp_stat.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*-
2
 
 * See the file LICENSE for redistribution information.
3
 
 *
4
 
 * Copyright (c) 1996-2002
5
 
 *      Sleepycat Software.  All rights reserved.
6
 
 */
7
 
#include "db_config.h"
8
 
 
9
 
#ifndef lint
10
 
static const char revid[] = "$Id$";
11
 
#endif /* not lint */
12
 
 
13
 
#ifndef NO_SYSTEM_INCLUDES
14
 
#include <sys/types.h>
15
 
 
16
 
#include <stdio.h>
17
 
#include <string.h>
18
 
#include <unistd.h>
19
 
#endif
20
 
 
21
 
#include "db_int.h"
22
 
#include "dbinc/db_page.h"
23
 
#include "dbinc/db_shash.h"
24
 
#include "dbinc/db_am.h"
25
 
#include "dbinc/mp.h"
26
 
 
27
 
static void __memp_dumpcache __P((DB_ENV *,
28
 
                DB_MPOOL *, REGINFO *, size_t *, FILE *, u_int32_t));
29
 
static void __memp_pbh __P((DB_MPOOL *, BH *, size_t *, FILE *));
30
 
static void __memp_stat_wait __P((REGINFO *, MPOOL *, DB_MPOOL_STAT *, int));
31
 
 
32
 
/*
33
 
 * __memp_stat --
34
 
 *      Display MPOOL statistics.
35
 
 *
36
 
 * PUBLIC: int __memp_stat
37
 
 * PUBLIC:     __P((DB_ENV *, DB_MPOOL_STAT **, DB_MPOOL_FSTAT ***, u_int32_t));
38
 
 */
39
 
int
40
 
__memp_stat(dbenv, gspp, fspp, flags)
41
 
        DB_ENV *dbenv;
42
 
        DB_MPOOL_STAT **gspp;
43
 
        DB_MPOOL_FSTAT ***fspp;
44
 
        u_int32_t flags;
45
 
{
46
 
        DB_MPOOL *dbmp;
47
 
        DB_MPOOL_FSTAT **tfsp, *tstruct;
48
 
        DB_MPOOL_STAT *sp;
49
 
        MPOOL *c_mp, *mp;
50
 
        MPOOLFILE *mfp;
51
 
        size_t len, nlen, pagesize;
52
 
        u_int32_t pages, i;
53
 
        int ret;
54
 
        char *name, *tname;
55
 
 
56
 
        PANIC_CHECK(dbenv);
57
 
        ENV_REQUIRES_CONFIG(dbenv,
58
 
            dbenv->mp_handle, "memp_stat", DB_INIT_MPOOL);
59
 
 
60
 
        if ((ret = __db_fchk(dbenv,
61
 
            "DB_ENV->memp_stat", flags, DB_STAT_CLEAR)) != 0)
62
 
                return (ret);
63
 
 
64
 
        dbmp = dbenv->mp_handle;
65
 
        mp = dbmp->reginfo[0].primary;
66
 
 
67
 
        /* Global statistics. */
68
 
        if (gspp != NULL) {
69
 
                *gspp = NULL;
70
 
 
71
 
                if ((ret = __os_umalloc(dbenv, sizeof(**gspp), gspp)) != 0)
72
 
                        return (ret);
73
 
                memset(*gspp, 0, sizeof(**gspp));
74
 
                sp = *gspp;
75
 
 
76
 
                /*
77
 
                 * Initialization and information that is not maintained on
78
 
                 * a per-cache basis.
79
 
                 */
80
 
                c_mp = dbmp->reginfo[0].primary;
81
 
                sp->st_gbytes = c_mp->stat.st_gbytes;
82
 
                sp->st_bytes = c_mp->stat.st_bytes;
83
 
                sp->st_ncache = dbmp->nreg;
84
 
                sp->st_regsize = dbmp->reginfo[0].rp->size;
85
 
 
86
 
                /* Walk the cache list and accumulate the global information. */
87
 
                for (i = 0; i < mp->nreg; ++i) {
88
 
                        c_mp = dbmp->reginfo[i].primary;
89
 
 
90
 
                        sp->st_map += c_mp->stat.st_map;
91
 
                        sp->st_cache_hit += c_mp->stat.st_cache_hit;
92
 
                        sp->st_cache_miss += c_mp->stat.st_cache_miss;
93
 
                        sp->st_page_create += c_mp->stat.st_page_create;
94
 
                        sp->st_page_in += c_mp->stat.st_page_in;
95
 
                        sp->st_page_out += c_mp->stat.st_page_out;
96
 
                        sp->st_ro_evict += c_mp->stat.st_ro_evict;
97
 
                        sp->st_rw_evict += c_mp->stat.st_rw_evict;
98
 
                        sp->st_page_trickle += c_mp->stat.st_page_trickle;
99
 
                        sp->st_pages += c_mp->stat.st_pages;
100
 
                        /*
101
 
                         * st_page_dirty        calculated by __memp_stat_hash
102
 
                         * st_page_clean        calculated here
103
 
                         */
104
 
                        __memp_stat_hash(
105
 
                            &dbmp->reginfo[i], c_mp, &sp->st_page_dirty);
106
 
                        sp->st_page_clean = sp->st_pages - sp->st_page_dirty;
107
 
                        sp->st_hash_buckets += c_mp->stat.st_hash_buckets;
108
 
                        sp->st_hash_searches += c_mp->stat.st_hash_searches;
109
 
                        sp->st_hash_longest += c_mp->stat.st_hash_longest;
110
 
                        sp->st_hash_examined += c_mp->stat.st_hash_examined;
111
 
                        /*
112
 
                         * st_hash_nowait       calculated by __memp_stat_wait
113
 
                         * st_hash_wait
114
 
                         */
115
 
                        __memp_stat_wait(&dbmp->reginfo[i], c_mp, sp, flags);
116
 
                        sp->st_region_nowait +=
117
 
                            dbmp->reginfo[i].rp->mutex.mutex_set_nowait;
118
 
                        sp->st_region_wait +=
119
 
                            dbmp->reginfo[i].rp->mutex.mutex_set_wait;
120
 
                        sp->st_alloc += c_mp->stat.st_alloc;
121
 
                        sp->st_alloc_buckets += c_mp->stat.st_alloc_buckets;
122
 
                        if (sp->st_alloc_max_buckets <
123
 
                            c_mp->stat.st_alloc_max_buckets)
124
 
                                sp->st_alloc_max_buckets =
125
 
                                    c_mp->stat.st_alloc_max_buckets;
126
 
                        sp->st_alloc_pages += c_mp->stat.st_alloc_pages;
127
 
                        if (sp->st_alloc_max_pages <
128
 
                            c_mp->stat.st_alloc_max_pages)
129
 
                                sp->st_alloc_max_pages =
130
 
                                    c_mp->stat.st_alloc_max_pages;
131
 
 
132
 
                        if (LF_ISSET(DB_STAT_CLEAR)) {
133
 
                                dbmp->reginfo[i].rp->mutex.mutex_set_wait = 0;
134
 
                                dbmp->reginfo[i].rp->mutex.mutex_set_nowait = 0;
135
 
                                pages = c_mp->stat.st_pages;
136
 
                                memset(&c_mp->stat, 0, sizeof(c_mp->stat));
137
 
                                c_mp->stat.st_hash_buckets = c_mp->htab_buckets;
138
 
                                c_mp->stat.st_pages = pages;
139
 
                        }
140
 
                }
141
 
 
142
 
                /*
143
 
                 * We have duplicate statistics fields in per-file structures
144
 
                 * and the cache.  The counters are only incremented in the
145
 
                 * per-file structures, except if a file is flushed from the
146
 
                 * mpool, at which time we copy its information into the cache
147
 
                 * statistics.  We added the cache information above, now we
148
 
                 * add the per-file information.
149
 
                 */
150
 
                R_LOCK(dbenv, dbmp->reginfo);
151
 
                for (mfp = SH_TAILQ_FIRST(&mp->mpfq, __mpoolfile);
152
 
                    mfp != NULL; mfp = SH_TAILQ_NEXT(mfp, q, __mpoolfile)) {
153
 
                        sp->st_map += mfp->stat.st_map;
154
 
                        sp->st_cache_hit += mfp->stat.st_cache_hit;
155
 
                        sp->st_cache_miss += mfp->stat.st_cache_miss;
156
 
                        sp->st_page_create += mfp->stat.st_page_create;
157
 
                        sp->st_page_in += mfp->stat.st_page_in;
158
 
                        sp->st_page_out += mfp->stat.st_page_out;
159
 
                        if (fspp == NULL && LF_ISSET(DB_STAT_CLEAR)) {
160
 
                                pagesize = mfp->stat.st_pagesize;
161
 
                                memset(&mfp->stat, 0, sizeof(mfp->stat));
162
 
                                mfp->stat.st_pagesize = pagesize;
163
 
                        }
164
 
                }
165
 
                R_UNLOCK(dbenv, dbmp->reginfo);
166
 
        }
167
 
 
168
 
        /* Per-file statistics. */
169
 
        if (fspp != NULL) {
170
 
                *fspp = NULL;
171
 
 
172
 
                /* Count the MPOOLFILE structures. */
173
 
                R_LOCK(dbenv, dbmp->reginfo);
174
 
                for (i = 0, len = 0,
175
 
                    mfp = SH_TAILQ_FIRST(&mp->mpfq, __mpoolfile);
176
 
                    mfp != NULL;
177
 
                    ++i, mfp = SH_TAILQ_NEXT(mfp, q, __mpoolfile))
178
 
                        len += sizeof(DB_MPOOL_FSTAT *) +
179
 
                            sizeof(DB_MPOOL_FSTAT) +
180
 
                            strlen(__memp_fns(dbmp, mfp)) + 1;
181
 
                len += sizeof(DB_MPOOL_FSTAT *);        /* Trailing NULL */
182
 
                R_UNLOCK(dbenv, dbmp->reginfo);
183
 
 
184
 
                if (i == 0)
185
 
                        return (0);
186
 
 
187
 
                /* Allocate space */
188
 
                if ((ret = __os_umalloc(dbenv, len, fspp)) != 0)
189
 
                        return (ret);
190
 
 
191
 
                /*
192
 
                 * Build each individual entry.  We assume that an array of
193
 
                 * pointers are aligned correctly to be followed by an array
194
 
                 * of structures, which should be safe (in this particular
195
 
                 * case, the first element of the structure is a pointer, so
196
 
                 * we're doubly safe).  The array is followed by space for
197
 
                 * the text file names.
198
 
                 *
199
 
                 * Add 1 to i because we need to skip over the NULL.
200
 
                 */
201
 
                tfsp = *fspp;
202
 
                tstruct = (DB_MPOOL_FSTAT *)(tfsp + i + 1);
203
 
                tname = (char *)(tstruct + i);
204
 
 
205
 
                /*
206
 
                 * Files may have been opened since we counted, don't walk
207
 
                 * off the end of the allocated space.
208
 
                 */
209
 
                R_LOCK(dbenv, dbmp->reginfo);
210
 
                for (mfp = SH_TAILQ_FIRST(&mp->mpfq, __mpoolfile);
211
 
                    mfp != NULL && i-- > 0;
212
 
                    ++tfsp, ++tstruct, tname += nlen,
213
 
                    mfp = SH_TAILQ_NEXT(mfp, q, __mpoolfile)) {
214
 
                        name = __memp_fns(dbmp, mfp);
215
 
                        nlen = strlen(name) + 1;
216
 
                        *tfsp = tstruct;
217
 
                        *tstruct = mfp->stat;
218
 
                        if (LF_ISSET(DB_STAT_CLEAR)) {
219
 
                                pagesize = mfp->stat.st_pagesize;
220
 
                                memset(&mfp->stat, 0, sizeof(mfp->stat));
221
 
                                mfp->stat.st_pagesize = pagesize;
222
 
                        }
223
 
                        tstruct->file_name = tname;
224
 
                        memcpy(tname, name, nlen);
225
 
                }
226
 
                R_UNLOCK(dbenv, dbmp->reginfo);
227
 
 
228
 
                *tfsp = NULL;
229
 
        }
230
 
        return (0);
231
 
}
232
 
 
233
 
#define FMAP_ENTRIES    200                     /* Files we map. */
234
 
 
235
 
#define MPOOL_DUMP_HASH 0x01                    /* Debug hash chains. */
236
 
#define MPOOL_DUMP_MEM  0x04                    /* Debug region memory. */
237
 
#define MPOOL_DUMP_ALL  0x07                    /* Debug all. */
238
 
 
239
 
/*
240
 
 * __memp_dump_region --
241
 
 *      Display MPOOL structures.
242
 
 *
243
 
 * PUBLIC: int __memp_dump_region __P((DB_ENV *, char *, FILE *));
244
 
 */
245
 
int
246
 
__memp_dump_region(dbenv, area, fp)
247
 
        DB_ENV *dbenv;
248
 
        char *area;
249
 
        FILE *fp;
250
 
{
251
 
        static const FN fn[] = {
252
 
                { MP_CAN_MMAP,  "mmapped" },
253
 
                { MP_DEADFILE,  "dead" },
254
 
                { MP_DIRECT,    "no buffer" },
255
 
                { MP_EXTENT,    "extent" },
256
 
                { MP_TEMP,      "temporary" },
257
 
                { MP_UNLINK,    "unlink" },
258
 
                { 0,            NULL }
259
 
        };
260
 
        DB_MPOOL *dbmp;
261
 
        DB_MPOOLFILE *dbmfp;
262
 
        MPOOL *mp;
263
 
        MPOOLFILE *mfp;
264
 
        size_t fmap[FMAP_ENTRIES + 1];
265
 
        u_int32_t i, flags;
266
 
        int cnt;
267
 
        u_int8_t *p;
268
 
 
269
 
        PANIC_CHECK(dbenv);
270
 
        ENV_REQUIRES_CONFIG(dbenv,
271
 
            dbenv->mp_handle, "memp_dump_region", DB_INIT_MPOOL);
272
 
 
273
 
        dbmp = dbenv->mp_handle;
274
 
 
275
 
        /* Make it easy to call from the debugger. */
276
 
        if (fp == NULL)
277
 
                fp = stderr;
278
 
 
279
 
        for (flags = 0; *area != '\0'; ++area)
280
 
                switch (*area) {
281
 
                case 'A':
282
 
                        LF_SET(MPOOL_DUMP_ALL);
283
 
                        break;
284
 
                case 'h':
285
 
                        LF_SET(MPOOL_DUMP_HASH);
286
 
                        break;
287
 
                case 'm':
288
 
                        LF_SET(MPOOL_DUMP_MEM);
289
 
                        break;
290
 
                }
291
 
 
292
 
        mp = dbmp->reginfo[0].primary;
293
 
 
294
 
        /* Display MPOOL structures. */
295
 
        (void)fprintf(fp, "%s\nPool (region addr 0x%lx)\n",
296
 
            DB_LINE, P_TO_ULONG(dbmp->reginfo[0].addr));
297
 
 
298
 
        /* Display the MPOOLFILE structures. */
299
 
        R_LOCK(dbenv, dbmp->reginfo);
300
 
        for (cnt = 0, mfp = SH_TAILQ_FIRST(&mp->mpfq, __mpoolfile);
301
 
            mfp != NULL; mfp = SH_TAILQ_NEXT(mfp, q, __mpoolfile), ++cnt) {
302
 
                (void)fprintf(fp, "File #%d: %s: pagesize %lu\n", cnt + 1,
303
 
                    __memp_fns(dbmp, mfp), (u_long)mfp->stat.st_pagesize);
304
 
                (void)fprintf(fp, "\t type %ld; ref %lu; blocks %lu; last %lu;",
305
 
                    (long)mfp->ftype, (u_long)mfp->mpf_cnt,
306
 
                    (u_long)mfp->block_cnt, (u_long)mfp->last_pgno);
307
 
                __db_prflags(mfp->flags, fn, fp);
308
 
 
309
 
                (void)fprintf(fp, "\n\t UID: ");
310
 
                p = R_ADDR(dbmp->reginfo, mfp->fileid_off);
311
 
                for (i = 0; i < DB_FILE_ID_LEN; ++i, ++p) {
312
 
                        (void)fprintf(fp, "%x", (u_int)*p);
313
 
                        if (i < DB_FILE_ID_LEN - 1)
314
 
                                (void)fprintf(fp, " ");
315
 
                }
316
 
                (void)fprintf(fp, "\n");
317
 
                if (cnt < FMAP_ENTRIES)
318
 
                        fmap[cnt] = R_OFFSET(dbmp->reginfo, mfp);
319
 
        }
320
 
        R_UNLOCK(dbenv, dbmp->reginfo);
321
 
 
322
 
        MUTEX_THREAD_LOCK(dbenv, dbmp->mutexp);
323
 
        for (dbmfp = TAILQ_FIRST(&dbmp->dbmfq);
324
 
            dbmfp != NULL; dbmfp = TAILQ_NEXT(dbmfp, q), ++cnt) {
325
 
                (void)fprintf(fp, "File #%d: %s: per-process, %s\n",
326
 
                    cnt + 1, __memp_fn(dbmfp),
327
 
                    F_ISSET(dbmfp, MP_READONLY) ? "readonly" : "read/write");
328
 
                    if (cnt < FMAP_ENTRIES)
329
 
                        fmap[cnt] = R_OFFSET(dbmp->reginfo, mfp);
330
 
        }
331
 
        MUTEX_THREAD_UNLOCK(dbenv, dbmp->mutexp);
332
 
        if (cnt < FMAP_ENTRIES)
333
 
                fmap[cnt] = INVALID_ROFF;
334
 
        else
335
 
                fmap[FMAP_ENTRIES] = INVALID_ROFF;
336
 
 
337
 
        /* Dump the memory pools. */
338
 
        for (i = 0; i < mp->nreg; ++i) {
339
 
                (void)fprintf(fp, "%s\nCache #%d:\n", DB_LINE, i + 1);
340
 
                __memp_dumpcache(
341
 
                    dbenv, dbmp, &dbmp->reginfo[i], fmap, fp, flags);
342
 
        }
343
 
 
344
 
        /* Flush in case we're debugging. */
345
 
        (void)fflush(fp);
346
 
 
347
 
        return (0);
348
 
}
349
 
 
350
 
/*
351
 
 * __memp_dumpcache --
352
 
 *      Display statistics for a cache.
353
 
 */
354
 
static void
355
 
__memp_dumpcache(dbenv, dbmp, reginfo, fmap, fp, flags)
356
 
        DB_ENV *dbenv;
357
 
        DB_MPOOL *dbmp;
358
 
        REGINFO *reginfo;
359
 
        size_t *fmap;
360
 
        FILE *fp;
361
 
        u_int32_t flags;
362
 
{
363
 
        BH *bhp;
364
 
        DB_MPOOL_HASH *hp;
365
 
        MPOOL *c_mp;
366
 
        int bucket;
367
 
 
368
 
        c_mp = reginfo->primary;
369
 
 
370
 
        /* Display the hash table list of BH's. */
371
 
        if (LF_ISSET(MPOOL_DUMP_HASH)) {
372
 
                (void)fprintf(fp,
373
 
                    "%s\nBH hash table (%lu hash slots)\nbucket (priority):\n",
374
 
                    DB_LINE, (u_long)c_mp->htab_buckets);
375
 
                (void)fprintf(fp,
376
 
                    "\tpageno, file, ref, address [LSN] priority\n");
377
 
 
378
 
                for (hp = R_ADDR(reginfo, c_mp->htab),
379
 
                    bucket = 0; bucket < c_mp->htab_buckets; ++hp, ++bucket) {
380
 
                        MUTEX_LOCK(dbenv, &hp->hash_mutex);
381
 
                        if ((bhp =
382
 
                            SH_TAILQ_FIRST(&hp->hash_bucket, __bh)) != NULL)
383
 
                                (void)fprintf(fp, "%lu (%u):\n",
384
 
                                    (u_long)bucket, hp->hash_priority);
385
 
                        for (; bhp != NULL; bhp = SH_TAILQ_NEXT(bhp, hq, __bh))
386
 
                                __memp_pbh(dbmp, bhp, fmap, fp);
387
 
                        MUTEX_UNLOCK(dbenv, &hp->hash_mutex);
388
 
                }
389
 
        }
390
 
 
391
 
        /* Dump the memory pool. */
392
 
        if (LF_ISSET(MPOOL_DUMP_MEM))
393
 
                __db_shalloc_dump(reginfo->addr, fp);
394
 
}
395
 
 
396
 
/*
397
 
 * __memp_pbh --
398
 
 *      Display a BH structure.
399
 
 */
400
 
static void
401
 
__memp_pbh(dbmp, bhp, fmap, fp)
402
 
        DB_MPOOL *dbmp;
403
 
        BH *bhp;
404
 
        size_t *fmap;
405
 
        FILE *fp;
406
 
{
407
 
        static const FN fn[] = {
408
 
                { BH_CALLPGIN,          "callpgin" },
409
 
                { BH_DIRTY,             "dirty" },
410
 
                { BH_DIRTY_CREATE,      "created" },
411
 
                { BH_DISCARD,           "discard" },
412
 
                { BH_LOCKED,            "locked" },
413
 
                { BH_TRASH,             "trash" },
414
 
                { 0,                    NULL }
415
 
        };
416
 
        int i;
417
 
 
418
 
        for (i = 0; i < FMAP_ENTRIES; ++i)
419
 
                if (fmap[i] == INVALID_ROFF || fmap[i] == bhp->mf_offset)
420
 
                        break;
421
 
 
422
 
        if (fmap[i] == INVALID_ROFF)
423
 
                (void)fprintf(fp, "\t%5lu, %lu, %2lu, %8lu [%lu,%lu] %lu",
424
 
                    (u_long)bhp->pgno, (u_long)bhp->mf_offset,
425
 
                    (u_long)bhp->ref, (u_long)R_OFFSET(dbmp->reginfo, bhp),
426
 
                    (u_long)LSN(bhp->buf).file, (u_long)LSN(bhp->buf).offset,
427
 
                    (u_long)bhp->priority);
428
 
        else
429
 
                (void)fprintf(fp, "\t%5lu,   #%d,  %2lu, %8lu [%lu,%lu] %lu",
430
 
                    (u_long)bhp->pgno, i + 1,
431
 
                    (u_long)bhp->ref, (u_long)R_OFFSET(dbmp->reginfo, bhp),
432
 
                    (u_long)LSN(bhp->buf).file, (u_long)LSN(bhp->buf).offset,
433
 
                    (u_long)bhp->priority);
434
 
 
435
 
        __db_prflags(bhp->flags, fn, fp);
436
 
 
437
 
        (void)fprintf(fp, "\n");
438
 
}
439
 
 
440
 
/*
441
 
 * __memp_stat_hash --
442
 
 *      Total hash bucket stats (other than mutex wait) into the region.
443
 
 *
444
 
 * PUBLIC: void __memp_stat_hash __P((REGINFO *, MPOOL *, u_int32_t *));
445
 
 */
446
 
void
447
 
__memp_stat_hash(reginfo, mp, dirtyp)
448
 
        REGINFO *reginfo;
449
 
        MPOOL *mp;
450
 
        u_int32_t *dirtyp;
451
 
{
452
 
        DB_MPOOL_HASH *hp;
453
 
        u_int32_t dirty;
454
 
        int i;
455
 
 
456
 
        hp = R_ADDR(reginfo, mp->htab);
457
 
        for (i = 0, dirty = 0; i < mp->htab_buckets; i++, hp++)
458
 
                dirty += hp->hash_page_dirty;
459
 
        *dirtyp = dirty;
460
 
}
461
 
 
462
 
/*
463
 
 * __memp_stat_wait --
464
 
 *      Total hash bucket wait stats into the region.
465
 
 */
466
 
static void
467
 
__memp_stat_wait(reginfo, mp, mstat, flags)
468
 
        REGINFO *reginfo;
469
 
        MPOOL *mp;
470
 
        DB_MPOOL_STAT *mstat;
471
 
        int flags;
472
 
{
473
 
        DB_MPOOL_HASH *hp;
474
 
        DB_MUTEX *mutexp;
475
 
        int i;
476
 
 
477
 
        mstat->st_hash_max_wait = 0;
478
 
        hp = R_ADDR(reginfo, mp->htab);
479
 
        for (i = 0; i < mp->htab_buckets; i++, hp++) {
480
 
                mutexp = &hp->hash_mutex;
481
 
                mstat->st_hash_nowait += mutexp->mutex_set_nowait;
482
 
                mstat->st_hash_wait += mutexp->mutex_set_wait;
483
 
                if (mutexp->mutex_set_wait > mstat->st_hash_max_wait)
484
 
                        mstat->st_hash_max_wait = mutexp->mutex_set_wait;
485
 
 
486
 
                if (LF_ISSET(DB_STAT_CLEAR)) {
487
 
                        mutexp->mutex_set_wait = 0;
488
 
                        mutexp->mutex_set_nowait = 0;
489
 
                }
490
 
        }
491
 
}