Print this page
patch nuke-the-dbuf-hash
*** 498,588 ****
db.db_holds.rc_count, path);
return (DCMD_OK);
}
- /* ARGSUSED */
- static int
- dbuf_stats(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
- {
- #define HISTOSZ 32
- uintptr_t dbp;
- dmu_buf_impl_t db;
- dbuf_hash_table_t ht;
- uint64_t bucket, ndbufs;
- uint64_t histo[HISTOSZ];
- uint64_t histo2[HISTOSZ];
- int i, maxidx;
-
- if (mdb_readvar(&ht, "dbuf_hash_table") == -1) {
- mdb_warn("failed to read 'dbuf_hash_table'");
- return (DCMD_ERR);
- }
-
- for (i = 0; i < HISTOSZ; i++) {
- histo[i] = 0;
- histo2[i] = 0;
- }
-
- ndbufs = 0;
- for (bucket = 0; bucket < ht.hash_table_mask+1; bucket++) {
- int len;
-
- if (mdb_vread(&dbp, sizeof (void *),
- (uintptr_t)(ht.hash_table+bucket)) == -1) {
- mdb_warn("failed to read hash bucket %u at %p",
- bucket, ht.hash_table+bucket);
- return (DCMD_ERR);
- }
-
- len = 0;
- while (dbp != 0) {
- if (mdb_vread(&db, sizeof (dmu_buf_impl_t),
- dbp) == -1) {
- mdb_warn("failed to read dbuf at %p", dbp);
- return (DCMD_ERR);
- }
- dbp = (uintptr_t)db.db_hash_next;
- for (i = MIN(len, HISTOSZ - 1); i >= 0; i--)
- histo2[i]++;
- len++;
- ndbufs++;
- }
-
- if (len >= HISTOSZ)
- len = HISTOSZ-1;
- histo[len]++;
- }
-
- mdb_printf("hash table has %llu buckets, %llu dbufs "
- "(avg %llu buckets/dbuf)\n",
- ht.hash_table_mask+1, ndbufs,
- (ht.hash_table_mask+1)/ndbufs);
-
- mdb_printf("\n");
- maxidx = 0;
- for (i = 0; i < HISTOSZ; i++)
- if (histo[i] > 0)
- maxidx = i;
- mdb_printf("hash chain length number of buckets\n");
- for (i = 0; i <= maxidx; i++)
- mdb_printf("%u %llu\n", i, histo[i]);
-
- mdb_printf("\n");
- maxidx = 0;
- for (i = 0; i < HISTOSZ; i++)
- if (histo2[i] > 0)
- maxidx = i;
- mdb_printf("hash chain depth number of dbufs\n");
- for (i = 0; i <= maxidx; i++)
- mdb_printf("%u or more %llu %llu%%\n",
- i, histo2[i], histo2[i]*100/ndbufs);
-
-
- return (DCMD_OK);
- }
-
#define CHAIN_END 0xffff
/*
* ::zap_leaf [-v]
*
* Print a zap_leaf_phys_t, assumed to be 16k
--- 498,507 ----
*** 3268,3278 ****
static const mdb_dcmd_t dcmds[] = {
{ "arc", "[-bkmg]", "print ARC variables", arc_print },
{ "blkptr", ":", "print blkptr_t", blkptr },
{ "dbuf", ":", "print dmu_buf_impl_t", dbuf },
- { "dbuf_stats", ":", "dbuf stats", dbuf_stats },
{ "dbufs",
"\t[-O objset_t*] [-n objset_name | \"mos\"] "
"[-o object | \"mdn\"] \n"
"\t[-l level] [-b blkid | \"bonus\"]",
"find dmu_buf_impl_t's that match specified criteria", dbufs },
--- 3187,3196 ----