Skip to content

Commit cfe5106

Browse files
ckennellycopybara-github
authored andcommitted
Exercise stress test against the virtual CPU ID, if applicable.
* The Unsafe form is acceptable, since we've checked IsFast at the start of the test. We will always have an initialized CPU ID. * Since Grow/Shrink rely on CompareAndSwap against the current CPU ID, we need to be in the same CPU ID space. PiperOrigin-RevId: 318540571 Change-Id: If7e5829c35bb31f3c47093b1ad65eabefaa4039f
1 parent 6631c87 commit cfe5106

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tcmalloc/internal/percpu_tcmalloc_test.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,13 +575,14 @@ static void StressThread(size_t thread_id, TcmallocSlab* slab,
575575
}
576576
}
577577
if (n != 0) {
578-
size_t res = slab->Grow(GetCurrentCpu(), cl, n, kStressCapacity);
578+
size_t res =
579+
slab->Grow(GetCurrentVirtualCpuUnsafe(), cl, n, kStressCapacity);
579580
EXPECT_LE(res, n);
580581
capacity->fetch_add(n - res);
581582
}
582583
} else if (what < 60) {
583584
size_t n =
584-
slab->Shrink(GetCurrentCpu(), cl,
585+
slab->Shrink(GetCurrentVirtualCpuUnsafe(), cl,
585586
absl::Uniform<int32_t>(rnd, 0, kStressCapacity) + 1);
586587
capacity->fetch_add(n);
587588
} else if (what < 70) {

0 commit comments

Comments
 (0)