Print this page
XXXX initialize cpu's sys and vm stats properly

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/cpu.c
          +++ new/usr/src/uts/common/os/cpu.c
↓ open down ↓ 3113 lines elided ↑ open up ↑
3114 3114  
3115 3115          ASSERT(MUTEX_HELD(&cpu_lock));
3116 3116  
3117 3117          if (pool_pset_enabled())
3118 3118                  zoneid = GLOBAL_ZONEID;
3119 3119          else
3120 3120                  zoneid = ALL_ZONES;
3121 3121          /*
3122 3122           * Create named kstats
3123 3123           */
3124      -#define CPU_STATS_KS_CREATE(name, tsize, update_func)                    \
     3124 +#define CPU_STATS_KS_CREATE(name, template, update_func)                 \
3125 3125          ksp = kstat_create_zone(module, instance, (name), class,         \
3126      -            KSTAT_TYPE_NAMED, (tsize) / sizeof (kstat_named_t), 0,       \
3127      -            zoneid);                                                     \
     3126 +            KSTAT_TYPE_NAMED, sizeof (template) / sizeof (kstat_named_t),\
     3127 +            0, zoneid);                                                  \
3128 3128          if (ksp != NULL) {                                               \
     3129 +                bcopy(&template, ksp->ks_data, sizeof (template));       \
3129 3130                  ksp->ks_private = cp;                                    \
3130 3131                  ksp->ks_update = (update_func);                          \
3131 3132                  kstat_install(ksp);                                      \
3132      -        } else                                                           \
     3133 +        } else {                                                         \
3133 3134                  cmn_err(CE_WARN, "cpu: unable to create %s:%d:%s kstat", \
3134      -                    module, instance, (name));
     3135 +                    module, instance, (name));                           \
     3136 +        }                                                                \
3135 3137  
3136      -        CPU_STATS_KS_CREATE("sys", sizeof (cpu_sys_stats_ks_data_template),
     3138 +        CPU_STATS_KS_CREATE("sys", cpu_sys_stats_ks_data_template,
3137 3139              cpu_sys_stats_ks_update);
3138      -        CPU_STATS_KS_CREATE("vm", sizeof (cpu_vm_stats_ks_data_template),
     3140 +        CPU_STATS_KS_CREATE("vm", cpu_vm_stats_ks_data_template,
3139 3141              cpu_vm_stats_ks_update);
3140 3142  
3141 3143          /*
3142 3144           * Export the familiar cpu_stat_t KSTAT_TYPE_RAW kstat.
3143 3145           */
3144 3146          ksp = kstat_create_zone("cpu_stat", cp->cpu_id, NULL,
3145 3147              "misc", KSTAT_TYPE_RAW, sizeof (cpu_stat_t), 0, zoneid);
3146 3148          if (ksp != NULL) {
3147 3149                  ksp->ks_update = cpu_stat_ks_update;
3148 3150                  ksp->ks_private = cp;
↓ open down ↓ 295 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX