Skip to content

Commit 6b73ba7

Browse files
ckennellycopybara-github
authored andcommitted
On deallocation overflow, use the virtual CPU ID if present.
When using a virtual CPU IDs, __rseq_abi.cpu_id corresponds to a different ID. The overflow path will attempt to grow the cache on the real CPU ID slab, but subsequent deallocations still using the virtual CPU ID will continue to overflow. PiperOrigin-RevId: 318500444 Change-Id: Iabb719be0ffed9acce88c2b592a59c2d7d7e27ef
1 parent 73dfa9b commit 6b73ba7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

tcmalloc/internal/percpu_tcmalloc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ static inline ABSL_ATTRIBUTE_ALWAYS_INLINE int TcmallocSlab_Push(
347347
// As of 3/2020, LLVM's asm goto (even with output constraints) only provides
348348
// values for the fallthrough path. The values on the taken branches are
349349
// undefined.
350-
int cpu = __rseq_abi.cpu_id;
350+
int cpu = VirtualRseqCpuId();
351351
return f(cpu, cl, item);
352352
}
353353
#endif // defined(__x86_64__)

tcmalloc/internal/percpu_tcmalloc_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ TEST_P(TcmallocSlabTest, Unit) {
295295
__rseq_abi.cpu_id = cpu;
296296

297297
if (UsingFlatVirtualCpus()) {
298-
__rseq_abi.vcpu_id = cpu;
298+
__rseq_abi.vcpu_id = cpu ^ 1;
299+
cpu = cpu ^ 1;
299300
}
300301
#endif
301302
current_cpu_ = cpu;

0 commit comments

Comments
 (0)