Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 731007338146aeb164ca1964688e59ff838364f4
      
https://github.com/WebKit/WebKit/commit/731007338146aeb164ca1964688e59ff838364f4
  Author: Dan Hecht <[email protected]>
  Date:   2024-07-16 (Tue, 16 Jul 2024)

  Changed paths:
    M Source/bmalloc/libpas/src/libpas/pas_bitfit_heap.c
    M Source/bmalloc/libpas/src/libpas/pas_segregated_heap.c
    M Source/bmalloc/libpas/src/test/BmallocTests.cpp

  Log Message:
  -----------
  [libpas] handle overlapping segregated directories when maintaining indexes
https://bugs.webkit.org/show_bug.cgi?id=276432
rdar://131476542

Reviewed by Yusuke Suzuki.

The previous attempt (280317@main) at handling this situation violated
a constraint that some pages have due to the object size not being
aligned properly. See that commit for why other approaches to
preventing overlapping directories don't work well.

Also, overlapping directories are less rare with directories in the
small index compared to medium, and can occur when allocating with
alignment, even without disabling segregated pages (which is the only
case we've seen this occur for directories in the medium index).

So, rather than trying to prevent overlapping directories, fix up the
small and medium indexing code to handle them in a determinstic way.

The small index code already had a strategy in place for handling
overlapping directories: a directory is installed only up to the
index preceding the min_index of the next directory. See the existing
code with comment:

/* Install this result in all indices starting with this one that don't already 
have a
   size class and where this size class would be big enough. */

(emphasis on: "that don't already have a size class").

This change uses the same strategy for medium indexes, which fixes
the issue that the assert in check_medium_directories() is complaining
about.

It turns out that although there was code to handle this case when
updating the small index, the code that verifies (and rematerializes,
though I'm not sure if that code ever executes) was incorrect
for indices in the small index. This is only noticible when PAS_TESTING
is enabled, which only happens for the "testing" variant of the pas tests.
And the pas tests apparently do not have any coverage of these corner
cases. So this bug has always been there but never noticed.

So, the code to verify (and rematerialize) both the small and medium
indexes is updated to traverse the directories in order (previously
this was done only for medium directories) and the same rule is applied:
the current directory is indexed only up (but not including) the start
of the next directory's min_index.

Also add test cases to cover more of these corner cases.

* Source/bmalloc/libpas/src/libpas/pas_bitfit_heap.c:
(pas_bitfit_heap_select_variant):
* Source/bmalloc/libpas/src/libpas/pas_segregated_heap.c:
(size_directory_min_heap_compare):
(recompute_size_lookup):
(pas_segregated_heap_ensure_size_directory_for_size):
* Source/bmalloc/libpas/src/test/BmallocTests.cpp:
(std::testBmallocForceBitfitAfterAlloc):
(std::testBmallocX):
(addBmallocTests):

Canonical link: https://commits.webkit.org/281012@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to