Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions tcmalloc/cpu_cache_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class TestStaticForwarder : private Parameters {
numa_topology_.Init();

absl::base_internal::SpinLockHolder l(vma_name_mu_);
vma_name_calls_.reserve(10);
vma_name_calls_.reserve(4096);
}

void InitializeShardedManager(int num_shards) {
Expand Down Expand Up @@ -215,11 +215,13 @@ class TestStaticForwarder : private Parameters {
TC_CHECK(name.has_value());
{
absl::base_internal::SpinLockHolder l(vma_name_mu_);
auto& elem = vma_name_calls_.emplace_back();
elem.ptr = ptr;
elem.size = size;
memcpy(elem.name, name->data(),
std::min(name->size(), sizeof(elem.name) - 1));
if (vma_name_calls_.size() < vma_name_calls_.capacity()) {
auto& elem = vma_name_calls_.emplace_back();
elem.ptr = ptr;
elem.size = size;
memcpy(elem.name, name->data(),
std::min(name->size(), sizeof(elem.name) - 1));
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions tcmalloc/internal/cpu_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#ifndef TCMALLOC_INTERNAL_CPU_UTILS_H_
#define TCMALLOC_INTERNAL_CPU_UTILS_H_

#ifdef __linux__

#include <sched.h>

#include <array>
Expand Down Expand Up @@ -81,4 +83,6 @@ class CpuSet {
} // namespace tcmalloc
GOOGLE_MALLOC_SECTION_END

#endif // __linux__

#endif // TCMALLOC_INTERNAL_CPU_UTILS_H_
2 changes: 2 additions & 0 deletions tcmalloc/internal/sysinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
#include "absl/strings/numbers.h"
#include "absl/strings/string_view.h"
#include "tcmalloc/internal/config.h"
#if __linux__
#include "tcmalloc/internal/cpu_utils.h"
#endif
#include "tcmalloc/internal/util.h"

GOOGLE_MALLOC_SECTION_BEGIN
Expand Down
2 changes: 2 additions & 0 deletions tcmalloc/internal/sysinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
#include "absl/base/call_once.h"
#include "absl/functional/function_ref.h"
#include "tcmalloc/internal/config.h"
#if __linux__
#include "tcmalloc/internal/cpu_utils.h"
#endif
#include "tcmalloc/internal/logging.h"

GOOGLE_MALLOC_SECTION_BEGIN
Expand Down
Loading