From 8820b3bb907c5f92b3c44eb08fcbcfde594db109 Mon Sep 17 00:00:00 2001 From: Etienne Perot Date: Tue, 4 Apr 2023 12:06:49 -0700 Subject: [PATCH] Automated rollback of changelist 508491474 PiperOrigin-RevId: 521829631 --- runsc/cli/main.go | 17 +++++++++++++++++ runsc/cmd/boot.go | 17 ----------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/runsc/cli/main.go b/runsc/cli/main.go index 2f764322d..8202de7c2 100644 --- a/runsc/cli/main.go +++ b/runsc/cli/main.go @@ -250,6 +250,23 @@ func Main() { } linux.SetAFSSyscallPanic(conf.TestOnlyAFSSyscallPanic) + // pgalloc.MemoryFile (which provides application memory) sometimes briefly + // mlock(2)s ranges of memory in order to fault in a large number of pages at + // a time. Try to make RLIMIT_MEMLOCK unlimited so that it can do so. runsc + // expects to run in a memory cgroup that limits its memory usage as + // required. + var rlim unix.Rlimit + if err := unix.Getrlimit(unix.RLIMIT_MEMLOCK, &rlim); err != nil { + log.Warningf("Failed to get RLIMIT_MEMLOCK: %v", err) + } else if rlim.Cur != unix.RLIM_INFINITY || rlim.Max != unix.RLIM_INFINITY { + rlim.Cur = unix.RLIM_INFINITY + rlim.Max = unix.RLIM_INFINITY + if err := unix.Setrlimit(unix.RLIMIT_MEMLOCK, &rlim); err != nil { + // We may not have CAP_SYS_RESOURCE, so this failure may be expected. + log.Infof("Failed to set RLIMIT_MEMLOCK: %v", err) + } + } + // Call the subcommand and pass in the configuration. var ws unix.WaitStatus subcmdCode := subcommands.Execute(context.Background(), conf, &ws) diff --git a/runsc/cmd/boot.go b/runsc/cmd/boot.go index 140ee5b64..6a99000f4 100644 --- a/runsc/cmd/boot.go +++ b/runsc/cmd/boot.go @@ -196,23 +196,6 @@ func (b *Boot) Execute(_ context.Context, f *flag.FlagSet, args ...any) subcomma // Set traceback level debug.SetTraceback(conf.Traceback) - // pgalloc.MemoryFile (which provides application memory) sometimes briefly - // mlock(2)s ranges of memory in order to fault in a large number of pages at - // a time. Try to make RLIMIT_MEMLOCK unlimited so that it can do so. runsc - // expects to run in a memory cgroup that limits its memory usage as - // required. - var rlim unix.Rlimit - if err := unix.Getrlimit(unix.RLIMIT_MEMLOCK, &rlim); err != nil { - log.Warningf("Failed to get RLIMIT_MEMLOCK: %v", err) - } else if rlim.Cur != unix.RLIM_INFINITY || rlim.Max != unix.RLIM_INFINITY { - rlim.Cur = unix.RLIM_INFINITY - rlim.Max = unix.RLIM_INFINITY - if err := unix.Setrlimit(unix.RLIMIT_MEMLOCK, &rlim); err != nil { - // We may not have CAP_SYS_RESOURCE, so this failure may be expected. - log.Infof("Failed to set RLIMIT_MEMLOCK: %v", err) - } - } - // Initialize CPUID information. cpuid.Initialize()