]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-112532: Tag mimalloc heaps and pages (#113742)
authorSam Gross <colesbury@gmail.com>
Fri, 5 Jan 2024 20:08:50 +0000 (15:08 -0500)
committerGitHub <noreply@github.com>
Fri, 5 Jan 2024 20:08:50 +0000 (12:08 -0800)
commit0b7476080b58ea2ee71c6c1229994a3bb62fe4fa
tree75b3715234152987c28c3a6f9879f45029dc43ef
parenteb53750757062255b1793969ca4cb12ef82b91c6
gh-112532: Tag mimalloc heaps and pages (#113742)

* gh-112532: Tag mimalloc heaps and pages

Mimalloc pages are data structures that contain contiguous allocations
of the same block size. Note that they are distinct from operating
system pages. Mimalloc pages are contained in segments.

When a thread exits, it abandons any segments and contained pages that
have live allocations. These segments and pages may be later reclaimed
by another thread. To support GC and certain thread-safety guarantees in
free-threaded builds, we want pages to only be reclaimed by the
corresponding heap in the claimant thread. For example, we want pages
containing GC objects to only be claimed by GC heaps.

This allows heaps and pages to be tagged with an integer tag that is
used to ensure that abandoned pages are only claimed by heaps with the
same tag. Heaps can be initialized with a tag (0-15); any page allocated
by that heap copies the corresponding tag.

* Fix conversion warning
Include/internal/mimalloc/mimalloc/internal.h
Include/internal/mimalloc/mimalloc/types.h
Objects/mimalloc/heap.c
Objects/mimalloc/init.c
Objects/mimalloc/page.c
Objects/mimalloc/segment.c
Python/pystate.c