seccheck: Initialize seccheck.Points only when needed.

This moves the initialization of `seccheck.Points` out of package-level
`init` and instead moves it to an explicit `seccheck.Initialize()` function.

On AMD64, this saves about 614KiB of heap memory that would otherwise always
be live.

PiperOrigin-RevId: 514813332
This commit is contained in:
Etienne Perot
2023-03-07 12:53:27 -08:00
committed by gVisor bot
parent 6d59ef7202
commit d9fcdc7714
10 changed files with 49 additions and 13 deletions
+1
View File
@@ -30,6 +30,7 @@ go_library(
"//pkg/sentry/platform",
"//pkg/sentry/platform/kvm",
"//pkg/sentry/platform/ptrace",
"//pkg/sentry/seccheck",
"//pkg/sentry/time",
"//pkg/sentry/vfs",
"//pkg/sync",
+3
View File
@@ -34,6 +34,7 @@ import (
"gvisor.dev/gvisor/pkg/sentry/mm"
"gvisor.dev/gvisor/pkg/sentry/pgalloc"
"gvisor.dev/gvisor/pkg/sentry/platform"
"gvisor.dev/gvisor/pkg/sentry/seccheck"
"gvisor.dev/gvisor/pkg/sentry/time"
"gvisor.dev/gvisor/pkg/sentry/vfs"
@@ -49,6 +50,8 @@ var (
// Boot initializes a new bare bones kernel for test.
func Boot() (*kernel.Kernel, error) {
seccheck.Initialize()
platformCtr, err := platform.Lookup(*platformFlag)
if err != nil {
return nil, fmt.Errorf("platform not found: %v", err)