Lines Matching refs:ss
70 acquire_cpus(struct snapshot *ss, kstat_ctl_t *kc)
74 ss->s_nr_cpus = sysconf(_SC_CPUID_MAX) + 1;
75 ss->s_cpus = calloc(ss->s_nr_cpus, sizeof (struct cpu_snapshot));
76 if (ss->s_cpus == NULL)
79 for (i = 0; i < ss->s_nr_cpus; i++) {
82 ss->s_cpus[i].cs_id = ID_NO_CPU;
83 ss->s_cpus[i].cs_state = p_online(i, P_STATUS);
85 if (ss->s_cpus[i].cs_state == -1)
87 ss->s_cpus[i].cs_id = i;
92 (void) pset_assign(PS_QUERY, i, &ss->s_cpus[i].cs_pset_id);
93 if (ss->s_cpus[i].cs_pset_id == PS_NONE)
94 ss->s_cpus[i].cs_pset_id = ID_NO_PSET;
96 if (!CPU_ACTIVE(&ss->s_cpus[i]))
102 if (kstat_copy(ksp, &ss->s_cpus[i].cs_vm))
108 if (kstat_copy(ksp, &ss->s_cpus[i].cs_sys))
118 acquire_psets(struct snapshot *ss)
141 ss->s_psets = calloc(pids_nr + 1, sizeof (struct pset_snapshot));
142 if (ss->s_psets == NULL)
144 ss->s_nr_psets = pids_nr + 1;
147 ps = &ss->s_psets[0];
149 ps->ps_cpus = calloc(ss->s_nr_cpus, sizeof (struct cpu_snapshot *));
154 for (i = 1; i < ss->s_nr_psets; i++) {
155 ps = &ss->s_psets[i];
159 calloc(ss->s_nr_cpus, sizeof (struct cpu_snapshot *));
164 for (i = 0; i < ss->s_nr_psets; i++) {
165 ps = &ss->s_psets[i];
167 for (j = 0; j < ss->s_nr_cpus; j++) {
168 if (!CPU_ACTIVE(&ss->s_cpus[j]))
170 if (ss->s_cpus[j].cs_pset_id != ps->ps_id)
173 ps->ps_cpus[ps->ps_nr_cpus++] = &ss->s_cpus[j];
184 acquire_intrs(struct snapshot *ss, kstat_ctl_t *kc)
192 ss->s_nr_intrs = 1;
196 ss->s_nr_intrs++;
199 ss->s_intrs = calloc(ss->s_nr_intrs, sizeof (struct intr_snapshot));
200 if (ss->s_intrs == NULL)
211 (void) strlcpy(ss->s_intrs[0].is_name, "clock", KSTAT_STRLEN);
212 ss->s_intrs[0].is_total = clock->value.ui32;
227 (void) strlcpy(ss->s_intrs[i].is_name, ksp->ks_name,
229 ss->s_intrs[i].is_total = 0;
232 ss->s_intrs[i].is_total += ki->intrs[j];
243 acquire_sys(struct snapshot *ss, kstat_ctl_t *kc)
252 if (kstat_read(kc, ksp, &ss->s_sys.ss_sysinfo) == -1)
258 if (kstat_read(kc, ksp, &ss->s_sys.ss_vminfo) == -1)
264 if (kstat_read(kc, ksp, &ss->s_sys.ss_nc) == -1)
277 ss->s_sys.ss_ticks = knp->value.l;
283 ss->s_sys.ss_deficit = knp->value.l;
285 for (i = 0; i < ss->s_nr_cpus; i++) {
286 if (!CPU_ACTIVE(&ss->s_cpus[i]))
289 if (kstat_add(&ss->s_cpus[i].cs_sys, &ss->s_sys.ss_agg_sys))
291 if (kstat_add(&ss->s_cpus[i].cs_vm, &ss->s_sys.ss_agg_vm))
293 ss->s_nr_active_cpus++;
302 struct snapshot *ss = NULL;
308 free_snapshot(ss);
310 ss = safe_alloc(sizeof (struct snapshot));
312 (void) memset(ss, 0, sizeof (struct snapshot));
314 ss->s_types = types;
325 err = acquire_intrs(ss, kc);
328 err = acquire_cpus(ss, kc);
331 err = acquire_psets(ss);
335 err = acquire_iodevs(ss, kc, iodev_filter);
338 err = acquire_sys(ss, kc);
354 return (ss);
358 free_snapshot(struct snapshot *ss)
362 if (ss == NULL)
365 while (ss->s_iodevs) {
366 struct iodev_snapshot *tmp = ss->s_iodevs;
367 ss->s_iodevs = ss->s_iodevs->is_next;
371 if (ss->s_cpus) {
372 for (i = 0; i < ss->s_nr_cpus; i++) {
373 free(ss->s_cpus[i].cs_vm.ks_data);
374 free(ss->s_cpus[i].cs_sys.ks_data);
376 free(ss->s_cpus);
379 if (ss->s_psets) {
380 for (i = 0; i < ss->s_nr_psets; i++)
381 free(ss->s_psets[i].ps_cpus);
382 free(ss->s_psets);
385 free(ss->s_sys.ss_agg_sys.ks_data);
386 free(ss->s_sys.ss_agg_vm.ks_data);
387 free(ss);
499 nr_active_cpus(struct snapshot *ss)
503 for (i = 0; i < ss->s_nr_cpus; i++) {
504 if (CPU_ACTIVE(&ss->s_cpus[i]))