Set kernel.applicationCores to the number of processor on the host

The right number to use is the number of processors assigned to the cgroup. But until
we make the sandbox join the respective cgroup, just use the number of processors on
the host.

Closes #65, closes #66

PiperOrigin-RevId: 200725483
Change-Id: I34a566b1a872e26c66f56fa6e3100f42aaf802b1
This commit is contained in:
Fabricio Voznika
2018-06-15 09:19:04 -07:00
committed by Shentubot
parent 119a302ceb
commit ef5dd4df9b
2 changed files with 10 additions and 5 deletions
+6 -4
View File
@@ -18,6 +18,7 @@ package boot
import (
"fmt"
"math/rand"
"runtime"
"sync/atomic"
"syscall"
gtime "time"
@@ -171,10 +172,11 @@ func New(spec *specs.Spec, conf *Config, controllerFD int, ioFDs []int, console
Timekeeper: tk,
RootUserNamespace: creds.UserNamespace,
NetworkStack: networkStack,
ApplicationCores: 8,
Vdso: vdso,
RootUTSNamespace: utsns,
RootIPCNamespace: ipcns,
// TODO: use number of logical processors from cgroups.
ApplicationCores: uint(runtime.NumCPU()),
Vdso: vdso,
RootUTSNamespace: utsns,
RootIPCNamespace: ipcns,
}); err != nil {
return nil, fmt.Errorf("error initializing kernel: %v", err)
}
+4 -1
View File
@@ -15,7 +15,9 @@
package boot
import (
"fmt"
"io/ioutil"
"math/rand"
"os"
"sync"
"testing"
@@ -29,6 +31,7 @@ import (
func init() {
log.SetLevel(log.Debug)
rand.Seed(time.Now().UnixNano())
}
// testSpec returns a simple spec that can be used in tests.
@@ -46,7 +49,7 @@ func testSpec() *specs.Spec {
}
func createLoader() (*Loader, error) {
fd, err := server.CreateSocket(ControlSocketAddr("123"))
fd, err := server.CreateSocket(ControlSocketAddr(fmt.Sprintf("%010d", rand.Int())[:10]))
if err != nil {
return nil, err
}