@@ -395,29 +395,7 @@ static void DumpStats(TCMalloc_Printer* out, int level) {
395395 }
396396
397397 if (tcmalloc::UsePerCpuCache ()) {
398- out->printf (" ------------------------------------------------\n " );
399- out->printf (
400- " Bytes in per-CPU caches (per cpu limit: %" PRIu64 " bytes)\n " ,
401- Static::cpu_cache ()->CacheLimit ());
402- out->printf (" ------------------------------------------------\n " );
403-
404- cpu_set_t allowed_cpus;
405- if (sched_getaffinity (0 , sizeof (allowed_cpus), &allowed_cpus) != 0 ) {
406- CPU_ZERO (&allowed_cpus);
407- }
408-
409- for (int cpu = 0 , num_cpus = absl::base_internal::NumCPUs ();
410- cpu < num_cpus; ++cpu) {
411- uint64_t rbytes = Static::cpu_cache ()->UsedBytes (cpu);
412- bool populated = Static::cpu_cache ()->HasPopulated (cpu);
413- uint64_t unallocated = Static::cpu_cache ()->Unallocated (cpu);
414- out->printf (" cpu %3d: %12" PRIu64
415- " bytes (%7.1f MiB) with"
416- " %12" PRIu64 " bytes unallocated %s%s\n " ,
417- cpu, rbytes, rbytes / MiB, unallocated,
418- CPU_ISSET (cpu, &allowed_cpus) ? " active" : " " ,
419- populated ? " populated" : " " );
420- }
398+ Static::cpu_cache ()->Print (out);
421399 }
422400
423401 Static::page_allocator ()->Print (out, /* tagged=*/ false );
@@ -514,23 +492,7 @@ namespace {
514492 }
515493
516494 if (tcmalloc::UsePerCpuCache ()) {
517- cpu_set_t allowed_cpus;
518- if (sched_getaffinity (0 , sizeof (allowed_cpus), &allowed_cpus) != 0 ) {
519- CPU_ZERO (&allowed_cpus);
520- }
521-
522- for (int cpu = 0 , num_cpus = absl::base_internal::NumCPUs ();
523- cpu < num_cpus; ++cpu) {
524- PbtxtRegion entry = region.CreateSubRegion (" cpu_cache" );
525- uint64_t rbytes = Static::cpu_cache ()->UsedBytes (cpu);
526- bool populated = Static::cpu_cache ()->HasPopulated (cpu);
527- uint64_t unallocated = Static::cpu_cache ()->Unallocated (cpu);
528- entry.PrintI64 (" cpu" , uint64_t (cpu));
529- entry.PrintI64 (" used" , rbytes);
530- entry.PrintI64 (" unused" , unallocated);
531- entry.PrintBool (" active" , CPU_ISSET (cpu, &allowed_cpus));
532- entry.PrintBool (" populated" , populated);
533- }
495+ Static::cpu_cache ()->PrintInPbtxt (®ion);
534496 }
535497 }
536498 Static::page_allocator ()->PrintInPbtxt (®ion, /* tagged=*/ false );
0 commit comments