Lines Matching refs:tp
420 static int build_cpu_topo(struct cpu_topo *tp, int cpu) in build_cpu_topo() argument
444 for (i = 0; i < tp->core_sib; i++) { in build_cpu_topo()
445 if (!strcmp(buf, tp->core_siblings[i])) in build_cpu_topo()
448 if (i == tp->core_sib) { in build_cpu_topo()
449 tp->core_siblings[i] = buf; in build_cpu_topo()
450 tp->core_sib++; in build_cpu_topo()
469 for (i = 0; i < tp->thread_sib; i++) { in build_cpu_topo()
470 if (!strcmp(buf, tp->thread_siblings[i])) in build_cpu_topo()
473 if (i == tp->thread_sib) { in build_cpu_topo()
474 tp->thread_siblings[i] = buf; in build_cpu_topo()
475 tp->thread_sib++; in build_cpu_topo()
486 static void free_cpu_topo(struct cpu_topo *tp) in free_cpu_topo() argument
490 if (!tp) in free_cpu_topo()
493 for (i = 0 ; i < tp->core_sib; i++) in free_cpu_topo()
494 zfree(&tp->core_siblings[i]); in free_cpu_topo()
496 for (i = 0 ; i < tp->thread_sib; i++) in free_cpu_topo()
497 zfree(&tp->thread_siblings[i]); in free_cpu_topo()
499 free(tp); in free_cpu_topo()
504 struct cpu_topo *tp; in build_cpu_topology() local
519 addr = calloc(1, sizeof(*tp) + 2 * sz); in build_cpu_topology()
523 tp = addr; in build_cpu_topology()
524 tp->cpu_nr = nr; in build_cpu_topology()
525 addr += sizeof(*tp); in build_cpu_topology()
526 tp->core_siblings = addr; in build_cpu_topology()
528 tp->thread_siblings = addr; in build_cpu_topology()
531 ret = build_cpu_topo(tp, i); in build_cpu_topology()
536 free_cpu_topo(tp); in build_cpu_topology()
537 tp = NULL; in build_cpu_topology()
539 return tp; in build_cpu_topology()
545 struct cpu_topo *tp; in write_cpu_topology() local
549 tp = build_cpu_topology(); in write_cpu_topology()
550 if (!tp) in write_cpu_topology()
553 ret = do_write(fd, &tp->core_sib, sizeof(tp->core_sib)); in write_cpu_topology()
557 for (i = 0; i < tp->core_sib; i++) { in write_cpu_topology()
558 ret = do_write_string(fd, tp->core_siblings[i]); in write_cpu_topology()
562 ret = do_write(fd, &tp->thread_sib, sizeof(tp->thread_sib)); in write_cpu_topology()
566 for (i = 0; i < tp->thread_sib; i++) { in write_cpu_topology()
567 ret = do_write_string(fd, tp->thread_siblings[i]); in write_cpu_topology()
587 free_cpu_topo(tp); in write_cpu_topology()