Print this page
XXXX Check for uninitialized kernel statistics

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/kstat_fr.c
          +++ new/usr/src/uts/common/os/kstat_fr.c
↓ open down ↓ 1199 lines elided ↑ open up ↑
1200 1200                  if (lp != NULL && MUTEX_NOT_HELD(lp)) {
1201 1201                          mutex_enter(lp);
1202 1202                          (void) KSTAT_UPDATE(ksp, KSTAT_WRITE);
1203 1203                          mutex_exit(lp);
1204 1204                  } else {
1205 1205                          (void) KSTAT_UPDATE(ksp, KSTAT_WRITE);
1206 1206                  }
1207 1207                  ksp->ks_flags &= ~KSTAT_FLAG_DORMANT;
1208 1208          }
1209 1209  
     1210 +#ifdef DEBUG
     1211 +        /*
     1212 +         * Search for uninitialized kstats.
     1213 +         */
     1214 +        switch (ksp->ks_type) {
     1215 +        case KSTAT_TYPE_NAMED: {
     1216 +                uint_t i;
     1217 +                kstat_named_t *knp = KSTAT_NAMED_PTR(ksp);
     1218 +
     1219 +                for (i = 0; i < ksp->ks_ndata; i++, knp++) {
     1220 +                        if (knp->data_type > KSTAT_DATA_STRING) {
     1221 +                                cmn_err(CE_WARN,
     1222 +                                    "kstat_install('%s', %d, '%s'): "
     1223 +                                    "invalid data type",
     1224 +                                    ksp->ks_module, ksp->ks_instance,
     1225 +                                    ksp->ks_name);
     1226 +                        }
     1227 +
     1228 +                        /*
     1229 +                         * If the name of this kstat is empty
     1230 +                         * we assume it is uninitialized.
     1231 +                         */
     1232 +                        if (knp->name[0] == '\0') {
     1233 +                                cmn_err(CE_WARN,
     1234 +                                    "kstat_install('%s', %d, '%s'): "
     1235 +                                    "uninitialized kstat",
     1236 +                                    ksp->ks_module, ksp->ks_instance,
     1237 +                                    ksp->ks_name);
     1238 +                        }
     1239 +                }
     1240 +
     1241 +                break;
     1242 +        }
     1243 +        default:
     1244 +                break;
     1245 +        }
     1246 +#endif
     1247 +
1210 1248          /*
1211 1249           * Now that the kstat is active, make it visible to the kstat driver.
1212 1250           */
1213 1251          ksp->ks_flags &= ~KSTAT_FLAG_INVALID;
1214 1252          kstat_rele(ksp);
1215 1253  }
1216 1254  
1217 1255  /*
1218 1256   * Remove a kstat from the system.  Or, if it's a persistent kstat,
1219 1257   * just update the data and mark it as dormant.
↓ open down ↓ 234 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX