Skip to content

Propagate per-CPU cache size updates in CpuCache::SetCacheLimit. - #1283

Draft
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_993486849
Draft

copybara-service[bot] wants to merge 1 commit into
masterfrom
test_993486849

Conversation

@copybara-service

Copy link
Copy Markdown

Propagate per-CPU cache size updates in CpuCache::SetCacheLimit.

When CpuCache::SetCacheLimit or TCMalloc_Internal_SetMaxPerCpuCacheSize is
called after per-CPU caches are activated, update each CPU's capacity and
available bytes under resize_lock_ and resize_[cpu].lock, draining populated
cores via DrainLocksHeld when the new limit shrinks below unallocated slack.

Hold resize_[cpu].lock across the available-byte exchange and restore in
ResizeCpuSizeClasses so available bytes are never hidden in a local variable
while resize_[cpu].lock is held, and increment capacity before available in
StealFromOtherCache so available <= capacity always holds. Check
subtle::percpu::IsFastNoInit() in UseBackingShardedTransferCache so draining a
core from a thread without rseq registered falls back to the unsharded transfer
cache.

When CpuCache::SetCacheLimit or TCMalloc_Internal_SetMaxPerCpuCacheSize is
called after per-CPU caches are activated, update each CPU's capacity and
available bytes under resize_lock_ and resize_[cpu].lock, draining populated
cores via DrainLocksHeld when the new limit shrinks below unallocated slack.

Hold resize_[cpu].lock across the available-byte exchange and restore in
ResizeCpuSizeClasses so available bytes are never hidden in a local variable
while resize_[cpu].lock is held, and increment capacity before available in
StealFromOtherCache so available <= capacity always holds. Check
subtle::percpu::IsFastNoInit() in UseBackingShardedTransferCache so draining a
core from a thread without rseq registered falls back to the unsharded transfer
cache.
PiperOrigin-RevId: 993486849

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant