diff options
author | Jamie Liu <jamieliu@google.com> | 2019-03-29 16:24:29 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-03-29 16:25:33 -0700 |
commit | 26e8d9981fcf6d08199a9fd9c609d9715c3cf37e (patch) | |
tree | bcf90e47301f46a6d702e8c7fdccf3428ab038bf /pkg/sentry/kernel/task.go | |
parent | dcf66133314712b9ba042dbbb289c29d00a2497a (diff) |
Use kernel.Task.CopyScratchBuffer in syscalls/linux where possible.
PiperOrigin-RevId: 241072126
Change-Id: Ib4d9f58f550732ac4c5153d3cf159a5b1a9749da
Diffstat (limited to 'pkg/sentry/kernel/task.go')
-rw-r--r-- | pkg/sentry/kernel/task.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/pkg/sentry/kernel/task.go b/pkg/sentry/kernel/task.go index f958aba26..9c365e781 100644 --- a/pkg/sentry/kernel/task.go +++ b/pkg/sentry/kernel/task.go @@ -550,17 +550,16 @@ func (t *Task) afterLoad() { t.futexWaiter = futex.NewWaiter() } -// copyScratchBufferLen is the length of the copyScratchBuffer field of the Task -// struct. -const copyScratchBufferLen = 52 +// copyScratchBufferLen is the length of Task.copyScratchBuffer. +const copyScratchBufferLen = 144 // sizeof(struct stat) // CopyScratchBuffer returns a scratch buffer to be used in CopyIn/CopyOut // functions. It must only be used within those functions and can only be used // by the task goroutine; it exists to improve performance and thus // intentionally lacks any synchronization. // -// Callers should pass a constant value as an argument, which will allow the -// compiler to inline and optimize out the if statement below. +// Callers should pass a constant value as an argument if possible, which will +// allow the compiler to inline and optimize out the if statement below. func (t *Task) CopyScratchBuffer(size int) []byte { if size > copyScratchBufferLen { return make([]byte, size) |