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


3104  * online via p_online(2).
3105  */
3106 static void
3107 cpu_stats_kstat_create(cpu_t *cp)
3108 {
3109         int     instance = cp->cpu_id;
3110         char    *module = "cpu";
3111         char    *class = "misc";
3112         kstat_t *ksp;
3113         zoneid_t zoneid;
3114 
3115         ASSERT(MUTEX_HELD(&cpu_lock));
3116 
3117         if (pool_pset_enabled())
3118                 zoneid = GLOBAL_ZONEID;
3119         else
3120                 zoneid = ALL_ZONES;
3121         /*
3122          * Create named kstats
3123          */
3124 #define CPU_STATS_KS_CREATE(name, tsize, update_func)                    \
3125         ksp = kstat_create_zone(module, instance, (name), class,         \
3126             KSTAT_TYPE_NAMED, (tsize) / sizeof (kstat_named_t), 0,       \
3127             zoneid);                                                     \
3128         if (ksp != NULL) {                                               \

3129                 ksp->ks_private = cp;                                    \
3130                 ksp->ks_update = (update_func);                          \
3131                 kstat_install(ksp);                                      \
3132         } else                                                           \
3133                 cmn_err(CE_WARN, "cpu: unable to create %s:%d:%s kstat", \
3134                     module, instance, (name));

3135 
3136         CPU_STATS_KS_CREATE("sys", sizeof (cpu_sys_stats_ks_data_template),
3137             cpu_sys_stats_ks_update);
3138         CPU_STATS_KS_CREATE("vm", sizeof (cpu_vm_stats_ks_data_template),
3139             cpu_vm_stats_ks_update);
3140 
3141         /*
3142          * Export the familiar cpu_stat_t KSTAT_TYPE_RAW kstat.
3143          */
3144         ksp = kstat_create_zone("cpu_stat", cp->cpu_id, NULL,
3145             "misc", KSTAT_TYPE_RAW, sizeof (cpu_stat_t), 0, zoneid);
3146         if (ksp != NULL) {
3147                 ksp->ks_update = cpu_stat_ks_update;
3148                 ksp->ks_private = cp;
3149                 kstat_install(ksp);
3150         }
3151 }
3152 
3153 static void
3154 cpu_stats_kstat_destroy(cpu_t *cp)
3155 {
3156         char ks_name[KSTAT_STRLEN];
3157 
3158         (void) sprintf(ks_name, "cpu_stat%d", cp->cpu_id);




3104  * online via p_online(2).
3105  */
3106 static void
3107 cpu_stats_kstat_create(cpu_t *cp)
3108 {
3109         int     instance = cp->cpu_id;
3110         char    *module = "cpu";
3111         char    *class = "misc";
3112         kstat_t *ksp;
3113         zoneid_t zoneid;
3114 
3115         ASSERT(MUTEX_HELD(&cpu_lock));
3116 
3117         if (pool_pset_enabled())
3118                 zoneid = GLOBAL_ZONEID;
3119         else
3120                 zoneid = ALL_ZONES;
3121         /*
3122          * Create named kstats
3123          */
3124 #define CPU_STATS_KS_CREATE(name, template, update_func)                 \
3125         ksp = kstat_create_zone(module, instance, (name), class,         \
3126             KSTAT_TYPE_NAMED, sizeof (template) / sizeof (kstat_named_t),\
3127             0, zoneid);                                                  \
3128         if (ksp != NULL) {                                               \
3129                 bcopy(&template, ksp->ks_data, sizeof (template));       \
3130                 ksp->ks_private = cp;                                    \
3131                 ksp->ks_update = (update_func);                          \
3132                 kstat_install(ksp);                                      \
3133         } else {                                                         \
3134                 cmn_err(CE_WARN, "cpu: unable to create %s:%d:%s kstat", \
3135                     module, instance, (name));                           \
3136         }                                                                \
3137 
3138         CPU_STATS_KS_CREATE("sys", cpu_sys_stats_ks_data_template,
3139             cpu_sys_stats_ks_update);
3140         CPU_STATS_KS_CREATE("vm", cpu_vm_stats_ks_data_template,
3141             cpu_vm_stats_ks_update);
3142 
3143         /*
3144          * Export the familiar cpu_stat_t KSTAT_TYPE_RAW kstat.
3145          */
3146         ksp = kstat_create_zone("cpu_stat", cp->cpu_id, NULL,
3147             "misc", KSTAT_TYPE_RAW, sizeof (cpu_stat_t), 0, zoneid);
3148         if (ksp != NULL) {
3149                 ksp->ks_update = cpu_stat_ks_update;
3150                 ksp->ks_private = cp;
3151                 kstat_install(ksp);
3152         }
3153 }
3154 
3155 static void
3156 cpu_stats_kstat_destroy(cpu_t *cp)
3157 {
3158         char ks_name[KSTAT_STRLEN];
3159 
3160         (void) sprintf(ks_name, "cpu_stat%d", cp->cpu_id);