File: userspace_swap.mojom

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (62 lines) | stat: -rw-r--r-- 2,968 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module userspace_swap.mojom;

struct MemoryRegion {
  uint64 address;
  uint64 length;
};

// The UserspaceSwapInitialization interface is used for the renderer to
// negotiate userspace swap with the browser.
interface UserspaceSwapInitialization {
  // TransferUserfaultFD is called from the renderer to hand over the
  // userfaultfd it created or to provide an error for why a userfaultfd
  // could not be created. |swap_area| is a memory region which was created
  // with PROT_NONE at a random address which can be used as a destination
  // for MovePtes.
  [Sync]
  TransferUserfaultFD(uint64 uffd_error, handle<platform> uffd_handle,
                      uint64 mmap_error, MemoryRegion swap_area) => ();
};

// The UserspaceSwap interface are the messages the browser will send to a
// renderer to prepare for and complete userspace swap.
interface UserspaceSwap {
  // The MovePTEsLeavingMapping message tells the renderer to move the
  // region located at the region |src| to |dest|. The renderer
  // will move the page table entries leaving the source |address| mapped.
  //
  // CAUTION: There is an inherent race condition that exists when using
  // this message. It's entirely possible that a mapping may be unmapped
  // and an unrelated one remapped at this same address. This situation
  // which can be detected (by use of userfaultfd) cannot be avoided. The
  // expectation is that this message will only be used on mappings which
  // should never be unmapped. As a result detected unmaps or failures
  // to perform the remap will result in the receiver of this message
  // being killed.
  MovePTEsLeavingMapping(MemoryRegion src, uint64 dest);

  // The MapArea message tells the renderer to mmap an area as PROT_NONE.
  // The primary use of this is to cause memory to be dropped without being
  // recounted. It's possible to use MADV_DONTNEED to accomplish the same;
  // however, that's less than ideal as it not reset the VMA itself. When
  // using MMAP_FIXED the result is unmapping what is at that location
  // first while holding the mm semaphore in write mode. This mapping will
  // be created (MAP_ANONYMOUS | MAP_FIXED) with PROT_NONE protections.
  //
  // Ultimately we need to discard the remapped memory, unregister with
  // userfaultfd, and mark a region as PROT_NONE so it can be merged
  // with it's neighboring previously split VMAs. A single mmap(2)
  // can accomplish all of these things.
  MapArea(MemoryRegion area);

  // GetPartitionAllocAreasUsed will return ranges of memory which are in
  // use and also in core. The memory will be tested using mincore(2) before
  // being included. |max_superpages| can be used to limited the number of
  // items returned.
  GetPartitionAllocSuperPagesUsed(int32 max_superpages)
    => (array<MemoryRegion> superpages);
};