diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-07-24 12:08:49 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-07-24 14:39:45 +0000 |
| commit | 49e6369fe732c0f81e5b03b36e345afbf3c79a15 (patch) | |
| tree | 651e322e41a8084abd6f2c80e4f9b7ff50a1dfe9 /syz-manager | |
| parent | 1f032c27c8158e44723253179928104813d45cdc (diff) | |
pkg/stat: rename package name to singular form
Go package names should generally be singular form:
https://go.dev/blog/package-names
https://rakyll.org/style-packages
https://groups.google.com/g/golang-nuts/c/buBwLar1gNw
Diffstat (limited to 'syz-manager')
| -rw-r--r-- | syz-manager/http.go | 10 | ||||
| -rw-r--r-- | syz-manager/hub.go | 30 | ||||
| -rw-r--r-- | syz-manager/manager.go | 12 | ||||
| -rw-r--r-- | syz-manager/repro.go | 14 | ||||
| -rw-r--r-- | syz-manager/stats.go | 48 |
5 files changed, 57 insertions, 57 deletions
diff --git a/syz-manager/http.go b/syz-manager/http.go index f51014667..60be016ac 100644 --- a/syz-manager/http.go +++ b/syz-manager/http.go @@ -24,7 +24,7 @@ import ( "github.com/google/syzkaller/pkg/html/pages" "github.com/google/syzkaller/pkg/log" "github.com/google/syzkaller/pkg/osutil" - "github.com/google/syzkaller/pkg/stats" + "github.com/google/syzkaller/pkg/stat" "github.com/google/syzkaller/pkg/vcs" "github.com/google/syzkaller/prog" "github.com/google/syzkaller/vm/dispatcher" @@ -84,11 +84,11 @@ func (mgr *Manager) httpSummary(w http.ResponseWriter, r *http.Request) { Log: log.CachedLogOutput(), } - level := stats.Simple + level := stat.Simple if mgr.expertMode { - level = stats.All + level = stat.All } - for _, stat := range stats.Collect(level) { + for _, stat := range stat.Collect(level) { data.Stats = append(data.Stats, UIStat{ Name: stat.Name, Value: stat.Value, @@ -157,7 +157,7 @@ func (mgr *Manager) httpSyscalls(w http.ResponseWriter, r *http.Request) { } func (mgr *Manager) httpStats(w http.ResponseWriter, r *http.Request) { - data, err := stats.RenderHTML() + data, err := stat.RenderHTML() if err != nil { log.Logf(0, "failed to execute template: %v", err) http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/syz-manager/hub.go b/syz-manager/hub.go index 216927a98..2b8d21be5 100644 --- a/syz-manager/hub.go +++ b/syz-manager/hub.go @@ -18,7 +18,7 @@ import ( "github.com/google/syzkaller/pkg/report" "github.com/google/syzkaller/pkg/report/crash" "github.com/google/syzkaller/pkg/rpctype" - "github.com/google/syzkaller/pkg/stats" + "github.com/google/syzkaller/pkg/stat" "github.com/google/syzkaller/prog" ) @@ -50,13 +50,13 @@ func (mgr *Manager) hubSyncLoop(keyGet keyGetter) { hubReproQueue: mgr.externalReproQueue, keyGet: keyGet, - statSendProgAdd: stats.New("hub send prog add", "", stats.Graph("hub progs")), - statSendProgDel: stats.New("hub send prog del", "", stats.Graph("hub progs")), - statRecvProg: stats.New("hub recv prog", "", stats.Graph("hub progs")), - statRecvProgDrop: stats.New("hub recv prog drop", "", stats.NoGraph), - statSendRepro: stats.New("hub send repro", "", stats.Graph("hub repros")), - statRecvRepro: stats.New("hub recv repro", "", stats.Graph("hub repros")), - statRecvReproDrop: stats.New("hub recv repro drop", "", stats.NoGraph), + statSendProgAdd: stat.New("hub send prog add", "", stat.Graph("hub progs")), + statSendProgDel: stat.New("hub send prog del", "", stat.Graph("hub progs")), + statRecvProg: stat.New("hub recv prog", "", stat.Graph("hub progs")), + statRecvProgDrop: stat.New("hub recv prog drop", "", stat.NoGraph), + statSendRepro: stat.New("hub send repro", "", stat.Graph("hub repros")), + statRecvRepro: stat.New("hub recv repro", "", stat.Graph("hub repros")), + statRecvReproDrop: stat.New("hub recv repro drop", "", stat.NoGraph), } if mgr.cfg.Reproduce && mgr.dash != nil { // Request reproducers from hub only if there is nothing else to reproduce. @@ -79,13 +79,13 @@ type HubConnector struct { needMoreRepros func() bool keyGet keyGetter - statSendProgAdd *stats.Val - statSendProgDel *stats.Val - statRecvProg *stats.Val - statRecvProgDrop *stats.Val - statSendRepro *stats.Val - statRecvRepro *stats.Val - statRecvReproDrop *stats.Val + statSendProgAdd *stat.Val + statSendProgDel *stat.Val + statRecvProg *stat.Val + statRecvProgDrop *stat.Val + statSendRepro *stat.Val + statRecvRepro *stat.Val + statRecvReproDrop *stat.Val } // HubManagerView restricts interface between HubConnector and Manager. diff --git a/syz-manager/manager.go b/syz-manager/manager.go index 5bb17b58d..367ade170 100644 --- a/syz-manager/manager.go +++ b/syz-manager/manager.go @@ -41,7 +41,7 @@ import ( "github.com/google/syzkaller/pkg/rpcserver" "github.com/google/syzkaller/pkg/runtest" "github.com/google/syzkaller/pkg/signal" - "github.com/google/syzkaller/pkg/stats" + "github.com/google/syzkaller/pkg/stat" "github.com/google/syzkaller/pkg/vminfo" "github.com/google/syzkaller/prog" "github.com/google/syzkaller/sys/targets" @@ -116,7 +116,7 @@ type Manager struct { assetStorage *asset.Storage - bootTime stats.AverageValue[time.Duration] + bootTime stat.AverageValue[time.Duration] reproMgr *reproManager @@ -338,7 +338,7 @@ func (mgr *Manager) heartbeatLoop() { } mgr.statFuzzingTime.Add(diff * mgr.serv.StatNumFuzzing.Val()) buf := new(bytes.Buffer) - for _, stat := range stats.Collect(stats.Console) { + for _, stat := range stat.Collect(stat.Console) { fmt.Fprintf(buf, "%v=%v ", stat.Name, stat.Value) } log.Logf(0, "%s", buf.String()) @@ -365,7 +365,7 @@ func (mgr *Manager) writeBench() { mgr.benchMu.Lock() defer mgr.benchMu.Unlock() vals := make(map[string]int) - for _, stat := range stats.Collect(stats.All) { + for _, stat := range stat.Collect(stat.All) { vals[stat.Name] = stat.V } data, err := json.MarshalIndent(vals, "", " ") @@ -1329,8 +1329,8 @@ func (mgr *Manager) MachineChecked(features flatrpc.Feature, enabledSyscalls map mgr.enabledFeatures = features mgr.targetEnabledSyscalls = enabledSyscalls mgr.firstConnect.Store(time.Now().Unix()) - statSyscalls := stats.New("syscalls", "Number of enabled syscalls", - stats.Simple, stats.NoGraph, stats.Link("/syscalls")) + statSyscalls := stat.New("syscalls", "Number of enabled syscalls", + stat.Simple, stat.NoGraph, stat.Link("/syscalls")) statSyscalls.Add(len(enabledSyscalls)) corpus := mgr.loadCorpus() mgr.phase = phaseLoadedCorpus diff --git a/syz-manager/repro.go b/syz-manager/repro.go index e03eaeb73..11812b83b 100644 --- a/syz-manager/repro.go +++ b/syz-manager/repro.go @@ -10,7 +10,7 @@ import ( "sync" "github.com/google/syzkaller/pkg/log" - "github.com/google/syzkaller/pkg/stats" + "github.com/google/syzkaller/pkg/stat" ) type reproManagerView interface { @@ -22,8 +22,8 @@ type reproManagerView interface { type reproManager struct { Done chan *ReproResult - statNumReproducing *stats.Val - statPending *stats.Val + statNumReproducing *stat.Val + statPending *stat.Val onlyOnce bool mgr reproManagerView @@ -49,14 +49,14 @@ func newReproManager(mgr reproManagerView, reproVMs int, onlyOnce bool) *reproMa pingQueue: make(chan struct{}, 1), attempted: map[string]bool{}, } - ret.statNumReproducing = stats.New("reproducing", "Number of crashes being reproduced", - stats.Console, stats.NoGraph, func() int { + ret.statNumReproducing = stat.New("reproducing", "Number of crashes being reproduced", + stat.Console, stat.NoGraph, func() int { ret.mu.Lock() defer ret.mu.Unlock() return len(ret.reproducing) }) - ret.statPending = stats.New("pending", "Number of pending repro tasks", - stats.Console, stats.NoGraph, func() int { + ret.statPending = stat.New("pending", "Number of pending repro tasks", + stat.Console, stat.NoGraph, func() int { ret.mu.Lock() defer ret.mu.Unlock() return len(ret.queue) diff --git a/syz-manager/stats.go b/syz-manager/stats.go index 4fbc7d657..f096e4423 100644 --- a/syz-manager/stats.go +++ b/syz-manager/stats.go @@ -9,29 +9,29 @@ import ( "time" "github.com/google/syzkaller/pkg/image" - "github.com/google/syzkaller/pkg/stats" + "github.com/google/syzkaller/pkg/stat" ) type Stats struct { - statCrashes *stats.Val - statCrashTypes *stats.Val - statSuppressed *stats.Val - statUptime *stats.Val - statFuzzingTime *stats.Val - statAvgBootTime *stats.Val - statCoverFiltered *stats.Val + statCrashes *stat.Val + statCrashTypes *stat.Val + statSuppressed *stat.Val + statUptime *stat.Val + statFuzzingTime *stat.Val + statAvgBootTime *stat.Val + statCoverFiltered *stat.Val } func (mgr *Manager) initStats() { - mgr.statCrashes = stats.New("crashes", "Total number of VM crashes", - stats.Simple, stats.Prometheus("syz_crash_total")) - mgr.statCrashTypes = stats.New("crash types", "Number of unique crashes types", - stats.Simple, stats.NoGraph) - mgr.statSuppressed = stats.New("suppressed", "Total number of suppressed VM crashes", - stats.Simple, stats.Graph("crashes")) - mgr.statFuzzingTime = stats.New("fuzzing", "Total fuzzing time in all VMs (seconds)", - stats.NoGraph, func(v int, period time.Duration) string { return fmt.Sprintf("%v sec", v/1e9) }) - mgr.statUptime = stats.New("uptime", "Total uptime (seconds)", stats.Simple, stats.NoGraph, + mgr.statCrashes = stat.New("crashes", "Total number of VM crashes", + stat.Simple, stat.Prometheus("syz_crash_total")) + mgr.statCrashTypes = stat.New("crash types", "Number of unique crashes types", + stat.Simple, stat.NoGraph) + mgr.statSuppressed = stat.New("suppressed", "Total number of suppressed VM crashes", + stat.Simple, stat.Graph("crashes")) + mgr.statFuzzingTime = stat.New("fuzzing", "Total fuzzing time in all VMs (seconds)", + stat.NoGraph, func(v int, period time.Duration) string { return fmt.Sprintf("%v sec", v/1e9) }) + mgr.statUptime = stat.New("uptime", "Total uptime (seconds)", stat.Simple, stat.NoGraph, func() int { firstConnect := mgr.firstConnect.Load() if firstConnect == 0 { @@ -41,8 +41,8 @@ func (mgr *Manager) initStats() { }, func(v int, period time.Duration) string { return fmt.Sprintf("%v sec", v) }) - mgr.statAvgBootTime = stats.New("instance restart", "Average VM restart time (sec)", - stats.NoGraph, + mgr.statAvgBootTime = stat.New("instance restart", "Average VM restart time (sec)", + stat.NoGraph, func() int { return int(mgr.bootTime.Value().Seconds()) }, @@ -50,7 +50,7 @@ func (mgr *Manager) initStats() { return fmt.Sprintf("%v sec", v) }) - stats.New("heap", "Process heap size (bytes)", stats.Graph("memory"), + stat.New("heap", "Process heap size (bytes)", stat.Graph("memory"), func() int { var ms runtime.MemStats runtime.ReadMemStats(&ms) @@ -58,7 +58,7 @@ func (mgr *Manager) initStats() { }, func(v int, period time.Duration) string { return fmt.Sprintf("%v MB", v>>20) }) - stats.New("VM", "Process VM size (bytes)", stats.Graph("memory"), + stat.New("VM", "Process VM size (bytes)", stat.Graph("memory"), func() int { var ms runtime.MemStats runtime.ReadMemStats(&ms) @@ -66,15 +66,15 @@ func (mgr *Manager) initStats() { }, func(v int, period time.Duration) string { return fmt.Sprintf("%v MB", v>>20) }) - stats.New("images memory", "Uncompressed images memory (bytes)", stats.Graph("memory"), + stat.New("images memory", "Uncompressed images memory (bytes)", stat.Graph("memory"), func() int { return int(image.StatMemory.Load()) }, func(v int, period time.Duration) string { return fmt.Sprintf("%v MB", v>>20) }) - stats.New("uncompressed images", "Total number of uncompressed images in memory", + stat.New("uncompressed images", "Total number of uncompressed images in memory", func() int { return int(image.StatImages.Load()) }) - mgr.statCoverFiltered = stats.New("filtered coverage", "", stats.NoGraph) + mgr.statCoverFiltered = stat.New("filtered coverage", "", stat.NoGraph) } |
