gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/pkg/sentry/pgalloc/BUILD (about)

     1  load("//pkg/sync/locking:locking.bzl", "declare_mutex")
     2  load("//tools:defs.bzl", "go_library", "go_test")
     3  load("//tools/go_generics:defs.bzl", "go_template_instance")
     4  
     5  package(
     6      default_applicable_licenses = ["//:license"],
     7      licenses = ["notice"],
     8  )
     9  
    10  declare_mutex(
    11      name = "memory_file_mutex",
    12      out = "memory_file_mutex.go",
    13      package = "pgalloc",
    14      prefix = "memoryFile",
    15  )
    16  
    17  declare_mutex(
    18      name = "mappings_mutex",
    19      out = "mappings_mutex.go",
    20      package = "pgalloc",
    21      prefix = "mappings",
    22  )
    23  
    24  go_template_instance(
    25      name = "evictable_range",
    26      out = "evictable_range.go",
    27      package = "pgalloc",
    28      prefix = "Evictable",
    29      template = "//pkg/segment:generic_range",
    30      types = {
    31          "T": "uint64",
    32      },
    33  )
    34  
    35  go_template_instance(
    36      name = "evictable_range_set",
    37      out = "evictable_range_set.go",
    38      package = "pgalloc",
    39      prefix = "evictableRange",
    40      template = "//pkg/segment:generic_set",
    41      types = {
    42          "Key": "uint64",
    43          "Range": "EvictableRange",
    44          "Value": "evictableRangeSetValue",
    45          "Functions": "evictableRangeSetFunctions",
    46      },
    47  )
    48  
    49  go_template_instance(
    50      name = "usage_set",
    51      out = "usage_set.go",
    52      consts = {
    53          "minDegree": "10",
    54          "trackGaps": "1",
    55      },
    56      imports = {
    57          "memmap": "gvisor.dev/gvisor/pkg/sentry/memmap",
    58      },
    59      package = "pgalloc",
    60      prefix = "usage",
    61      template = "//pkg/segment:generic_set",
    62      types = {
    63          "Key": "uint64",
    64          "Range": "memmap.FileRange",
    65          "Value": "usageInfo",
    66          "Functions": "usageSetFunctions",
    67      },
    68  )
    69  
    70  go_template_instance(
    71      name = "reclaim_set",
    72      out = "reclaim_set.go",
    73      consts = {
    74          "minDegree": "10",
    75      },
    76      imports = {
    77          "memmap": "gvisor.dev/gvisor/pkg/sentry/memmap",
    78      },
    79      package = "pgalloc",
    80      prefix = "reclaim",
    81      template = "//pkg/segment:generic_set",
    82      types = {
    83          "Key": "uint64",
    84          "Range": "memmap.FileRange",
    85          "Value": "reclaimSetValue",
    86          "Functions": "reclaimSetFunctions",
    87      },
    88  )
    89  
    90  go_library(
    91      name = "pgalloc",
    92      srcs = [
    93          "context.go",
    94          "evictable_range.go",
    95          "evictable_range_set.go",
    96          "mappings_mutex.go",
    97          "memory_file_mutex.go",
    98          "pgalloc.go",
    99          "pgalloc_unsafe.go",
   100          "reclaim_set.go",
   101          "save_restore.go",
   102          "usage_set.go",
   103      ],
   104      visibility = ["//pkg/sentry:internal"],
   105      deps = [
   106          "//pkg/abi/linux",
   107          "//pkg/atomicbitops",
   108          "//pkg/context",
   109          "//pkg/errors/linuxerr",
   110          "//pkg/hostarch",
   111          "//pkg/log",
   112          "//pkg/memutil",
   113          "//pkg/safemem",
   114          "//pkg/sentry/arch",
   115          "//pkg/sentry/hostmm",
   116          "//pkg/sentry/memmap",
   117          "//pkg/sentry/usage",
   118          "//pkg/state",
   119          "//pkg/state/statefile",
   120          "//pkg/state/wire",
   121          "//pkg/sync",
   122          "//pkg/sync/locking",
   123          "//pkg/usermem",
   124          "@org_golang_x_sys//unix:go_default_library",
   125      ],
   126  )
   127  
   128  go_test(
   129      name = "pgalloc_test",
   130      size = "small",
   131      srcs = ["pgalloc_test.go"],
   132      library = ":pgalloc",
   133      deps = ["//pkg/hostarch"],
   134  )