runsc: Remove syscall number from the unimplemented syscall counter.

Doing so has performance implications which need to be fixed before this can
be added back.

PiperOrigin-RevId: 524125147
This commit is contained in:
Etienne Perot
2023-04-13 15:55:14 -07:00
committed by gVisor bot
parent 1c2908c37c
commit ca4626f24f
2 changed files with 12 additions and 18 deletions
+4 -13
View File
@@ -16,7 +16,6 @@ package kernel
import (
"fmt"
"strconv"
"google.golang.org/protobuf/proto"
"gvisor.dev/gvisor/pkg/abi"
@@ -391,13 +390,8 @@ func RegisterSyscallTable(s *SyscallTable) {
}
allSyscallTables = append(allSyscallTables, s)
unimplementedSyscallCounterInit.Do(func() {
allowedValues := make([]string, maxSyscallNum+2)
unimplementedSyscallNumbers = make(map[uintptr]string, len(allowedValues))
for i := uintptr(0); i <= maxSyscallNum; i++ {
s := strconv.Itoa(int(i))
allowedValues[i] = s
unimplementedSyscallNumbers[i] = s
}
allowedValues := make([]string, 1)
// TODO(b/278108862): Add all other syscall numbers once doing so is possible.
allowedValues[len(allowedValues)-1] = outOfRangeSyscallNumber
unimplementedSyscallCounter = metric.MustCreateNewUint64Metric("unimplemented_syscalls", true, "Number of times the application tried to call an unimplemented syscall, broken down by syscall number", metric.NewField("sysno", allowedValues))
})
@@ -499,9 +493,6 @@ type SyscallInfo struct {
//
//go:nosplit
func IncrementUnimplementedSyscallCounter(sysno uintptr) {
s, found := unimplementedSyscallNumbers[sysno]
if !found {
s = outOfRangeSyscallNumber
}
unimplementedSyscallCounter.Increment(s)
// TODO(b/278108862): Use the real syscall number once doing so is possible.s, found := unimplementedSyscallNumbers[sysno]
unimplementedSyscallCounter.Increment(outOfRangeSyscallNumber)
}
+8 -5
View File
@@ -859,26 +859,29 @@ func TestMetricServerDoesNotExportZeroValueCounters(t *testing.T) {
for _, test := range []struct {
cont *Container
sysno uintptr
sysno int
wantExistence bool
}{
{unimpl1, 1337, true},
{unimpl1, 1338, false},
{unimpl2, 1337, false},
// TODO(b/278108862): Uncomment this: {unimpl1, 1338, false},
// TODO(b/278108862): Uncomment this: {unimpl2, 1337, false},
{unimpl2, 1338, true},
} {
// TODO(b/278108862): Undo this hack:
test.sysno = -1
t.Run(fmt.Sprintf("container %s syscall %d", test.cont.ID, test.sysno), func(t *testing.T) {
check := func() error {
got, _, err := metricDataPtr.GetPrometheusContainerInteger(metricclient.WantMetric{
Metric: "testmetric_unimplemented_syscalls",
Sandbox: test.cont.sandboxID(),
ExtraLabels: map[string]string{"sysno": strconv.Itoa(int(test.sysno))},
ExtraLabels: map[string]string{"sysno": strconv.Itoa(test.sysno)},
})
if test.wantExistence {
if err != nil {
return fmt.Errorf("cannot get unimplemented syscall metric for sysno=%d even though we expected its presence: %v", test.sysno, err)
}
if got != 1 {
if got <= 0 /* TODO(b/278108862): Revert to got != 1 */ {
return fmt.Errorf("expected counter value for unimplemented syscall %d be exactly 1, got %d", test.sysno, got)
}
} else /* !test.wantExistence */ {