ksp = kstat_create("unix", 0, "system_pages", "pages", KSTAT_TYPE_NAMED, sizeof (system_pages_kstat) / sizeof (kstat_named_t), KSTAT_FLAG_VIRTUAL); if (ksp) { ksp->ks_data = (void *) &system_pages_kstat; ksp->ks_update = system_pages_kstat_update; kstat_install(ksp); }
kstat 構造体には、ks_update という要素があり、kstat 構造体の情報をアップデートする関数のポインタが格納されている。system_pages_kstat_update() が上記 kstat 構造体をアップデートする関数。
system_pages_kstat_update(kstat_t *ksp, int rw) { kobj_stat_t kobj_stat; if (rw == KSTAT_WRITE) { return (EACCES); } kobj_stat_get(&kobj_stat); system_pages_kstat.physmem.value.ul = (ulong_t)physmem; system_pages_kstat.nalloc.value.ul = kobj_stat.nalloc; system_pages_kstat.nfree.value.ul = kobj_stat.nfree; system_pages_kstat.nalloc_calls.value.ul = kobj_stat.nalloc_calls; system_pages_kstat.nfree_calls.value.ul = kobj_stat.nfree_calls; system_pages_kstat.kernelbase.value.ul = (ulong_t)KERNELBASE; #ifdef __sparc /* * kstat should REALLY be modified to also report kmem64_base and * kmem64_end (see sun4u/os/startup.c), as the virtual address range * [ kernelbase .. econtig ] no longer is truly reflective of the * kernel's vallocs... */ system_pages_kstat.econtig.value.ul = (ulong_t)econtig32; #else /* !__sparc */ system_pages_kstat.econtig.value.ul = (ulong_t)econtig; #endif /* __sparc */ system_pages_kstat.freemem.value.ul = (ulong_t)freemem; system_pages_kstat.availrmem.value.ul = (ulong_t)availrmem; system_pages_kstat.lotsfree.value.ul = (ulong_t)lotsfree; system_pages_kstat.desfree.value.ul = (ulong_t)desfree; system_pages_kstat.minfree.value.ul = (ulong_t)minfree; system_pages_kstat.fastscan.value.ul = (ulong_t)fastscan; system_pages_kstat.slowscan.value.ul = (ulong_t)slowscan; system_pages_kstat.nscan.value.ul = (ulong_t)nscan; system_pages_kstat.desscan.value.ul = (ulong_t)desscan; system_pages_kstat.pagesfree.value.ul = (ulong_t)freemem; system_pages_kstat.pageslocked.value.ul = (ulong_t)(availrmem_initial - availrmem); system_pages_kstat.pagestotal.value.ul = (ulong_t)total_pages; /* * pp_kernel represents total pages used by the kernel since the * startup. This formula takes into account the boottime kernel * footprint and also considers the availrmem changes because of * user explicit page locking. */ system_pages_kstat.pp_kernel.value.ul = (ulong_t)(physinstalled - obp_pages - availrmem - k_anoninfo.ani_mem_resv - anon_segkp_pages_locked - pages_locked - pages_claimed - pages_useclaim); return (0); }
cpu:0:sys:
0 件のコメント:
コメントを投稿