MCPcopy Create free account
hub / github.com/F-Stack/f-stack / memstat_kvm_malloc

Function memstat_kvm_malloc

tools/libmemstat/memstat_malloc.c:323–451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321}
322
323int
324memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle)
325{
326 struct memory_type *mtp;
327 void *kmemstatistics;
328 int hint_dontsearch, j, mp_maxcpus, mp_ncpus, ret;
329 char name[MEMTYPE_MAXNAME];
330 struct malloc_type_stats mts;
331 struct malloc_type_internal *mtip;
332 struct malloc_type type, *typep;
333 kvm_t *kvm;
334
335 kvm = (kvm_t *)kvm_handle;
336
337 hint_dontsearch = LIST_EMPTY(&list->mtl_list);
338
339 if (kvm_nlist(kvm, namelist) != 0) {
340 list->mtl_error = MEMSTAT_ERROR_KVM;
341 return (-1);
342 }
343
344 if (namelist[X_KMEMSTATISTICS].n_type == 0 ||
345 namelist[X_KMEMSTATISTICS].n_value == 0) {
346 list->mtl_error = MEMSTAT_ERROR_KVM_NOSYMBOL;
347 return (-1);
348 }
349
350 ret = kread_symbol(kvm, X_MP_MAXCPUS, &mp_maxcpus,
351 sizeof(mp_maxcpus), 0);
352 if (ret != 0) {
353 list->mtl_error = ret;
354 return (-1);
355 }
356
357 ret = kread_symbol(kvm, X_KMEMSTATISTICS, &kmemstatistics,
358 sizeof(kmemstatistics), 0);
359 if (ret != 0) {
360 list->mtl_error = ret;
361 return (-1);
362 }
363
364 ret = memstat_malloc_zone_init_kvm(kvm);
365 if (ret != 0) {
366 list->mtl_error = ret;
367 return (-1);
368 }
369
370 mp_ncpus = kvm_getncpus(kvm);
371
372 for (typep = kmemstatistics; typep != NULL; typep = type.ks_next) {
373 ret = kread(kvm, typep, &type, sizeof(type), 0);
374 if (ret != 0) {
375 _memstat_mtl_empty(list);
376 list->mtl_error = ret;
377 return (-1);
378 }
379 ret = kread_string(kvm, (void *)type.ks_shortdesc, name,
380 MEMTYPE_MAXNAME);

Callers 1

memstat_kvm_allFunction · 0.85

Calls 10

_memstat_mtl_emptyFunction · 0.85
memstat_mtl_findFunction · 0.85
_memstat_mt_allocateFunction · 0.85
_memstat_mt_reset_statsFunction · 0.85
kread_zpcpuFunction · 0.85
bzeroFunction · 0.85
kread_symbolFunction · 0.70
kreadFunction · 0.70
kread_stringFunction · 0.70

Tested by

no test coverage detected