From 73f4b821a1696a215590417549fbea03fe07a8f5 Mon Sep 17 00:00:00 2001 From: Lucas Manning Date: Thu, 14 Sep 2023 14:50:25 -0700 Subject: [PATCH] Change namespace cloning so that it clones mounts depth-first. This saves on allocations. This change is a subset of the changes in cl/563529897 and cl/563752003. Committing this change in more discrete parts will help narrow down the causes of b/299603749. PiperOrigin-RevId: 565484026 --- pkg/sentry/vfs/namespace.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/sentry/vfs/namespace.go b/pkg/sentry/vfs/namespace.go index 131193fff..0b1f9ac50 100644 --- a/pkg/sentry/vfs/namespace.go +++ b/pkg/sentry/vfs/namespace.go @@ -180,8 +180,8 @@ func (vfs *VirtualFilesystem) CloneMountNamespace( queue := []cloneEntry{cloneEntry{ns.root, newns.root}} for len(queue) != 0 { - p := queue[0] - queue = queue[1:] + p := queue[len(queue)-1] + queue = queue[:len(queue)-1] for c := range p.prevMount.children { m := vfs.cloneMount(c, c.root, nil) vd := VirtualDentry{