diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-07-22 11:55:47 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-07-25 13:12:57 +0000 |
| commit | e02ef79b9ce5bc23eac00a1919746a36a308a4ae (patch) | |
| tree | cc548e17f574b9d34ef0f8d04afef58ec65bd6b3 | |
| parent | 32fcf98fda0484949d799e870d7ac9945c695932 (diff) | |
pkg/fuzzer/queue: move common fuzzing stats
These stats will be needed for snapshot mode that does not use rpcserver.
Move them from pkg/rpcserver to pkg/fuzzer/queue.
| -rw-r--r-- | pkg/fuzzer/queue/stats.go | 20 | ||||
| -rw-r--r-- | pkg/rpcserver/rpcserver.go | 29 | ||||
| -rw-r--r-- | syz-manager/manager.go | 4 |
3 files changed, 32 insertions, 21 deletions
diff --git a/pkg/fuzzer/queue/stats.go b/pkg/fuzzer/queue/stats.go new file mode 100644 index 000000000..3097ca2d6 --- /dev/null +++ b/pkg/fuzzer/queue/stats.go @@ -0,0 +1,20 @@ +// Copyright 2024 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package queue + +import "github.com/google/syzkaller/pkg/stat" + +// Common stats related to fuzzing that are updated/read by different parts of the system. +var ( + StatExecs = stat.New("exec total", "Total test program executions", + stat.Console, stat.Rate{}, stat.Prometheus("syz_exec_total")) + StatNumFuzzing = stat.New("fuzzing VMs", "Number of VMs that are currently fuzzing", + stat.Console, stat.Link("/vms")) + StatNoExecRequests = stat.New("no exec requests", + "Number of times fuzzer was stalled with no exec requests", stat.Rate{}) + StatNoExecDuration = stat.New("no exec duration", + "Total duration fuzzer was stalled with no exec requests (ns/sec)", stat.Rate{}) + StatExecBufferTooSmall = stat.New("buffer too small", + "Program serialization overflowed exec buffer", stat.NoGraph) +) diff --git a/pkg/rpcserver/rpcserver.go b/pkg/rpcserver/rpcserver.go index b371785d4..8e6f813bb 100644 --- a/pkg/rpcserver/rpcserver.go +++ b/pkg/rpcserver/rpcserver.go @@ -57,9 +57,7 @@ type Manager interface { } type Server struct { - Port int - StatExecs *stat.Val - StatNumFuzzing *stat.Val + Port int cfg *Config mgr Manager @@ -144,27 +142,20 @@ func newImpl(ctx context.Context, cfg *Config, mgr Manager) (*Server, error) { baseSource: baseSource, execSource: queue.Retry(baseSource), - StatExecs: stat.New("exec total", "Total test program executions", - stat.Console, stat.Rate{}, stat.Prometheus("syz_exec_total")), - StatNumFuzzing: stat.New("fuzzing VMs", "Number of VMs that are currently fuzzing", - stat.Console, stat.Link("/vms")), statVMRestarts: stat.New("vm restarts", "Total number of VM starts", stat.Rate{}, stat.NoGraph), runnerStats: &runnerStats{ statExecRetries: stat.New("exec retries", "Number of times a test program was restarted because the first run failed", - stat.Rate{}, stat.Graph("executor")), - statExecutorRestarts: stat.New("executor restarts", - "Number of times executor process was restarted", stat.Rate{}, stat.Graph("executor")), - statExecBufferTooSmall: stat.New("buffer too small", - "Program serialization overflowed exec buffer", stat.NoGraph), - statNoExecRequests: stat.New("no exec requests", - "Number of times fuzzer was stalled with no exec requests", stat.Rate{}), - statNoExecDuration: stat.New("no exec duration", - "Total duration fuzzer was stalled with no exec requests (ns/sec)", stat.Rate{}), + stats.Rate{}, stats.Graph("executor")), + statExecutorRestarts: stats.Create("executor restarts", + "Number of times executor process was restarted", stats.Rate{}, stats.Graph("executor")), + statExecBufferTooSmall: queue.StatExecBufferTooSmall, + statExecs: queue.StatExecs, + statNoExecRequests: queue.StatNoExecRequests, + statNoExecDuration: queue.StatNoExecDuration, }, } - serv.runnerStats.statExecs = serv.StatExecs s, err := flatrpc.ListenAndServe(cfg.RPC, serv.handleConn) if err != nil { return nil, err @@ -304,8 +295,8 @@ func (serv *Server) connectionLoop(runner *Runner) error { } } - serv.StatNumFuzzing.Add(1) - defer serv.StatNumFuzzing.Add(-1) + queue.StatNumFuzzing.Add(1) + defer queue.StatNumFuzzing.Add(-1) return runner.ConnectionLoop() } diff --git a/syz-manager/manager.go b/syz-manager/manager.go index 52d50109e..354a0b256 100644 --- a/syz-manager/manager.go +++ b/syz-manager/manager.go @@ -336,7 +336,7 @@ func (mgr *Manager) heartbeatLoop() { if mgr.firstConnect.Load() == 0 { continue } - mgr.statFuzzingTime.Add(diff * mgr.serv.StatNumFuzzing.Val()) + mgr.statFuzzingTime.Add(diff * queue.StatNumFuzzing.Val()) buf := new(bytes.Buffer) for _, stat := range stat.Collect(stat.Console) { fmt.Fprintf(buf, "%v=%v ", stat.Name, stat.Value) @@ -1582,7 +1582,7 @@ func (mgr *Manager) dashboardReporter() { FuzzingTime: time.Duration(mgr.statFuzzingTime.Val()) - lastFuzzingTime, Crashes: uint64(mgr.statCrashes.Val()) - lastCrashes, SuppressedCrashes: uint64(mgr.statSuppressed.Val()) - lastSuppressedCrashes, - Execs: uint64(mgr.serv.StatExecs.Val()) - lastExecs, + Execs: uint64(queue.StatExecs.Val()) - lastExecs, } if mgr.phase >= phaseTriagedCorpus && !triageInfoSent { triageInfoSent = true |
