Skip to content
Merged
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
5 changes: 3 additions & 2 deletions tcmalloc/huge_page_filler.h
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,8 @@ class HugePageFiller {

// Utility function to handle a non-hugepage backed `page_tracker` and
// mark its unmapped pages appropriately.
Length HandleUnbackedHugePage(PageTracker* page_tracker, PageBitmap unbacked)
Length HandleUnbackedHugePage(PageTracker* page_tracker,
const PageBitmap& unbacked)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(pageheap_lock);

private:
Expand Down Expand Up @@ -1935,7 +1936,7 @@ inline void HugePageFiller<TrackerType>::OnCollapseSuccess(TrackerType* pt) {

template <class TrackerType>
inline Length HugePageFiller<TrackerType>::HandleUnbackedHugePage(
PageTracker* tracker, PageBitmap unbacked) {
PageTracker* tracker, const PageBitmap& unbacked) {
RemoveFromFillerList(tracker);
Length unmapped_length = tracker->MarkSubreleased(unbacked);
subrelease_stats_.total_pages_subreleased += unmapped_length;
Expand Down
2 changes: 1 addition & 1 deletion tcmalloc/huge_page_filler_fuzz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ void TreatTrackers::Perform(State& state) const {
}
for (PageTracker* pt : state.trackers) {
HugePage hp = pt->location();
PageBitmap rel = pt->released_by_page();
const PageBitmap& rel = pt->released_by_page();
for (size_t i = 0; i < kPagesPerHugePage.raw_num(); ++i) {
PageId p = hp.first_page() + Length(i);
if (rel.GetBit(i)) {
Expand Down
23 changes: 13 additions & 10 deletions tcmalloc/huge_page_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,16 @@ class PageTracker : public TList<PageTracker>::Elem {
Length ReleaseFree(MemoryModifyFunction& unback)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(pageheap_lock);

Length MarkSubreleased(PageBitmap unbacked)
Length MarkSubreleased(const PageBitmap& unbacked)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(pageheap_lock);

[[nodiscard]] PageBitmap released_by_page() const {
[[nodiscard]] const PageBitmap& released_by_page() const
ABSL_EXCLUSIVE_LOCKS_REQUIRED(pageheap_lock) {
return released_by_page_;
}

[[nodiscard]] PageBitmap allocated_pages_bitmap() const {
[[nodiscard]] const PageBitmap& allocated_pages_bitmap() const
ABSL_EXCLUSIVE_LOCKS_REQUIRED(pageheap_lock) {
return free_.bits();
}

Expand Down Expand Up @@ -326,9 +328,9 @@ class PageTracker : public TList<PageTracker>::Elem {
size_t n_used_stale;
};

HardwarePageResidencyInfo CountInfoInHugePage(PageBitmap unbacked,
PageBitmap swapped,
PageBitmap stale) const;
HardwarePageResidencyInfo CountInfoInHugePage(const PageBitmap& unbacked,
const PageBitmap& swapped,
const PageBitmap& stale) const;

private:
HugePage location_;
Expand Down Expand Up @@ -427,7 +429,8 @@ inline void PageTracker::SetAnonVmaName(MemoryTagFunction& set_anon_vma_name,
}

inline PageTracker::HardwarePageResidencyInfo PageTracker::CountInfoInHugePage(
PageBitmap unbacked, PageBitmap swapped, PageBitmap stale) const {
const PageBitmap& unbacked, const PageBitmap& swapped,
const PageBitmap& stale) const {
// TODO(b/424551232): Add support for the scenario when native page size is
// larger than TCMalloc page size.
const size_t kHardwarePagesInHugePage = kHugePageSize / GetPageSize();
Expand All @@ -436,7 +439,7 @@ inline PageTracker::HardwarePageResidencyInfo PageTracker::CountInfoInHugePage(
}
TC_ASSERT_LE(kHardwarePagesInHugePage, kMaxResidencyBits);

const PageBitmap free = free_.bits();
const PageBitmap& free = free_.bits();

TC_ASSERT_EQ(kHardwarePagesInHugePage % kPagesPerHugePage.raw_num(), 0);
const int shift = kHardwarePagesInHugePage / kPagesPerHugePage.raw_num();
Expand Down Expand Up @@ -521,8 +524,8 @@ inline Length PageTracker::ReleaseFree(MemoryModifyFunction& unback) {
return Length(count);
}

inline Length PageTracker::MarkSubreleased(PageBitmap unbacked) {
PageBitmap free = free_.bits();
inline Length PageTracker::MarkSubreleased(const PageBitmap& unbacked) {
const PageBitmap& free = free_.bits();

// TODO(b/525422238): The residency bitmap was captured outside of the
// lock. So, in a rare case, it's possible that the page was allocated,
Expand Down
4 changes: 2 additions & 2 deletions tcmalloc/internal/range_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class RangeTracker {

void Clear();

Bitmap<N> bits() const;
const Bitmap<N>& bits() const;

private:
Bitmap<N> bits_;
Expand Down Expand Up @@ -319,7 +319,7 @@ inline void RangeTracker<N>::Unmark(size_t index, size_t n) {
}

template <size_t N>
inline Bitmap<N> RangeTracker<N>::bits() const {
inline const Bitmap<N>& RangeTracker<N>::bits() const {
return bits_;
}

Expand Down
Loading