sentry: pending signals S/R optimization.

Almost all of the hundreds of pending signal queues are empty upon save.

PiperOrigin-RevId: 201380318
Change-Id: I40747072435299de681d646e0862efac0637e172
This commit is contained in:
Zhaozhong Ni
2018-06-20 11:02:41 -07:00
committed by Shentubot
parent 5397963b5d
commit 4e9f0e91d7
3 changed files with 45 additions and 4 deletions
+6 -2
View File
@@ -13,7 +13,7 @@ go_stateify(
"ipc_namespace.go",
"kernel.go",
"pending_signals.go",
"pending_signals_list.go",
"pending_signals_state.go",
"process_group_list.go",
"ptrace.go",
"rseq.go",
@@ -46,7 +46,10 @@ go_stateify(
"version.go",
],
out = "kernel_state.go",
imports = ["gvisor.googlesource.com/gvisor/pkg/sentry/kernel/kdefs"],
imports = [
"gvisor.googlesource.com/gvisor/pkg/sentry/arch",
"gvisor.googlesource.com/gvisor/pkg/sentry/kernel/kdefs",
],
package = "kernel",
)
@@ -117,6 +120,7 @@ go_library(
"kernel_state.go",
"pending_signals.go",
"pending_signals_list.go",
"pending_signals_state.go",
"process_group_list.go",
"ptrace.go",
"rseq.go",
+2 -2
View File
@@ -44,11 +44,11 @@ type pendingSignals struct {
// Note that signals is zero-indexed, but signal 1 is the first valid
// signal, so signals[0] contains signals with signo 1 etc. This offset is
// usually handled by using Signal.index().
signals [linux.SignalMaximum]pendingSignalQueue
signals [linux.SignalMaximum]pendingSignalQueue `state:".([]*arch.SignalInfo)"`
// Bit i of pendingSet is set iff there is at least one signal with signo
// i+1 pending.
pendingSet linux.SignalSet
pendingSet linux.SignalSet `state:"manual"`
}
// pendingSignalQueue holds a pendingSignalList for a single signal number.
@@ -0,0 +1,37 @@
// Copyright 2018 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package kernel
import (
"gvisor.googlesource.com/gvisor/pkg/sentry/arch"
)
// saveSignals is invoked by stateify.
func (p *pendingSignals) saveSignals() []*arch.SignalInfo {
var pending []*arch.SignalInfo
for _, q := range p.signals {
for ps := q.pendingSignalList.Front(); ps != nil; ps = ps.Next() {
pending = append(pending, ps.SignalInfo)
}
}
return pending
}
// loadSignals is invoked by stateify.
func (p *pendingSignals) loadSignals(pending []*arch.SignalInfo) {
for _, si := range pending {
p.enqueue(si)
}
}