[webkit-changes] [WebKit/WebKit] 8e655f: [PlayStation] Add libpas implementation which don'...

Basuke Suzuki noreply at github.com
Fri May 17 16:59:25 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8e655f85359dd1ef174c38b09e5b5cab458c74b3
      https://github.com/WebKit/WebKit/commit/8e655f85359dd1ef174c38b09e5b5cab458c74b3
  Author: Basuke Suzuki <basuke.suzuki at sony.com>
  Date:   2024-05-17 (Fri, 17 May 2024)

  Changed paths:
    M Source/bmalloc/PlatformPlayStation.cmake
    M Source/bmalloc/libpas/src/libpas/pas_compact_heap_reservation.c

  Log Message:
  -----------
  [PlayStation] Add libpas implementation which don't map huge vss region.
https://bugs.webkit.org/show_bug.cgi?id=274234

Reviewed by Yusuke Suzuki.

libpas allocate memory region called `compact heap reservation` in its very early stage of
its life cycle. The area is used by libpas's management object to achieve several heaps
managed by libpas system. The point is that they never been deallocated and even more, they
never been decommitted. So only action to the memory region is allocation. This means that
we don't need to patch every mmap usage with vss library but only this usage. Much simpler.

This reservation heap is designed for mmpa's behavior called *demand paging*, that the
kernel never assign physical memory to the page until actual write is happened. So the heap
is as is from the beginning to the end without any further memory calls such as madvise or
munmap. But when some are is allowed to be used for some object, the first write to that
page will be used to assign physical memory to that region.

This is smart but not good for our platform. We need precise reserve / commit management.
So in this PR, we add some code in `pas_compact_heap_reservation_try_allocate()` to switch
current implementation and ours and manage commit when region is actually allocated.

Compact heap reservation is used from lower address to higher address by order or request.
They don't care page boundary when the region is used. Just the requested alignment is
cared. For instance, say the request is coming like following order:

- 84 bytes with 1 byte alignment
- 64 bytes with 16 bytes alignment
- 1M bytes with 1M bytes alignment

then allocation and unused padding is like this:

| request 1   | padding | request 2      | padding   | request 3      | ...
| 84 bytes    | 12      | 64 bytes       | 1,048,416 | 1M bytes       |
| 1 byte alin | bytes   | 16 bytes align | bytes     | 1M bytes align |

See the second padding is pretty huge and sounds very inefficient. But it is okay because
actual region is never touched and no page is consumed for the padding region. And 128MB
of addresses are enough big for the libpas usage.

FYI: The purpose of this reservation is to represent 64 bit address with compact size
(3 bytes in actual configuration). The client of compact heap reservation uses the fact
that the assigned address fits in the range of reservation start and end so it can be
represented as the index from the start.

Testing is done on Speedometer 3.0 using MiniBrowser

* Source/bmalloc/PlatformPlayStation.cmake:
* Source/bmalloc/libpas/src/libpas/pas_compact_heap_reservation.c:
(pas_compact_heap_reservation_try_allocate):

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list