Remove TID from task start

This was used to map kernel.Task to goroutines before
kernel.Task.GoroutineID was available. It's not needed anymore.

PiperOrigin-RevId: 445452190
This commit is contained in:
Fabricio Voznika
2022-04-29 10:32:08 -07:00
committed by gVisor bot
parent 76023bd2ad
commit a1aa00f922
4 changed files with 8 additions and 22 deletions
+3 -5
View File
@@ -1090,9 +1090,7 @@ func (k *Kernel) CreateProcess(args CreateProcessArgs) (*ThreadGroup, ThreadID,
// StartProcess starts running a process that was created with CreateProcess.
func (k *Kernel) StartProcess(tg *ThreadGroup) {
t := tg.Leader()
tid := k.tasks.Root.IDOfTask(t)
t.Start(tid)
tg.Leader().Start()
}
// Start starts execution of all tasks in k.
@@ -1122,8 +1120,8 @@ func (k *Kernel) Start() error {
// Start task goroutines.
k.tasks.mu.RLock()
defer k.tasks.mu.RUnlock()
for t, tid := range k.tasks.Root.tids {
t.Start(tid)
for t := range k.tasks.Root.tids {
t.Start()
}
return nil
}
+2 -3
View File
@@ -243,8 +243,7 @@ func (t *Task) Clone(args *linux.CloneArgs) (ThreadID, *SyscallControl, error) {
// This has to happen last, because e.g. ptraceClone may send a SIGSTOP to
// nt that it must receive before its task goroutine starts running.
tid := nt.k.tasks.Root.IDOfTask(nt)
defer nt.Start(tid)
defer nt.Start()
if args.Flags&linux.CLONE_THREAD == 0 && seccheck.Global.Enabled(seccheck.PointCloneProcess) {
mask, info := getCloneSeccheckInfo(t, nt)
@@ -288,7 +287,7 @@ func (t *Task) Clone(args *linux.CloneArgs) (ThreadID, *SyscallControl, error) {
ntid.CopyOut(t, hostarch.Addr(args.ParentTID))
}
t.traceCloneEvent(tid)
t.traceCloneEvent(nt.k.tasks.Root.IDOfTask(nt))
kind := ptraceCloneKindClone
if args.Flags&linux.CLONE_VFORK != 0 {
kind = ptraceCloneKindVfork
+1 -7
View File
@@ -51,11 +51,7 @@ type taskRunState interface {
}
// run runs the task goroutine.
//
// threadID a dummy value set to the task's TID in the root PID namespace to
// make it visible in stack dumps. A goroutine for a given task can be identified
// searching for Task.run()'s argument value.
func (t *Task) run(threadID uintptr) {
func (t *Task) run() {
t.goid.Store(goid.Get())
// Construct t.blockingTimer here. We do this here because we can't
@@ -103,8 +99,6 @@ func (t *Task) run(threadID uintptr) {
// Deferring this store triggers a false positive in the race
// detector (https://github.com/golang/go/issues/42599).
t.goid.Store(0)
// Keep argument alive because stack trace for dead variables may not be correct.
runtime.KeepAlive(threadID)
return
}
}
+2 -7
View File
@@ -347,11 +347,7 @@ func (ns *PIDNamespace) allocateTID() (ThreadID, error) {
// Start starts the task goroutine. Start must be called exactly once for each
// task returned by NewTask.
//
// 'tid' must be the task's TID in the root PID namespace and it's used for
// debugging purposes only (set as parameter to Task.run to make it visible
// in stack dumps).
func (t *Task) Start(tid ThreadID) {
func (t *Task) Start() {
// If the task was restored, it may be "starting" after having already exited.
if t.runState == nil {
return
@@ -364,6 +360,5 @@ func (t *Task) Start(tid ThreadID) {
// Task is now running in system mode.
t.accountTaskGoroutineLeave(TaskGoroutineNonexistent)
// Use the task's TID in the root PID namespace to make it visible in stack dumps.
go t.run(uintptr(tid)) // S/R-SAFE: synchronizes with saving through stops
go t.run() // S/R-SAFE: synchronizes with saving through stops
}