diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-08-02 16:44:21 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-08-02 16:57:32 +0200 |
| commit | 976e4de0480dff760fdc9bd1b21cbe81e46625e5 (patch) | |
| tree | c674e2bb09392030fb02ccc74e2f6271d40a2ba4 /syz-manager/stats.go | |
| parent | fbedd425b575868124577640fe02c9c0a73c4be3 (diff) | |
syz-manager: refactor work with hub
Move work with hub into a separate file and fully separate
its state from the rest of the manager state.
First step towards splitting manager into managable parts.
This also required to rework stats as they are used throughout the code.
Update #538
Update #605
Diffstat (limited to 'syz-manager/stats.go')
| -rw-r--r-- | syz-manager/stats.go | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/syz-manager/stats.go b/syz-manager/stats.go new file mode 100644 index 000000000..c6098b832 --- /dev/null +++ b/syz-manager/stats.go @@ -0,0 +1,56 @@ +// Copyright 2018 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 main + +import ( + "sync/atomic" +) + +type Stat uint64 + +type Stats struct { + crashes Stat + crashTypes Stat + crashSuppressed Stat + vmRestarts Stat + newInputs Stat + execTotal Stat + hubSendProgAdd Stat + hubSendProgDel Stat + hubSendRepro Stat + hubRecvProg Stat + hubRecvProgDrop Stat + hubRecvRepro Stat + hubRecvReproDrop Stat +} + +func (stats *Stats) all() map[string]uint64 { + return map[string]uint64{ + "crashes": stats.crashes.get(), + "crash types": stats.crashTypes.get(), + "suppressed": stats.crashSuppressed.get(), + "vm restarts": stats.vmRestarts.get(), + "manager new inputs": stats.newInputs.get(), + "exec total": stats.execTotal.get(), + "hub: send prog add": stats.hubSendProgAdd.get(), + "hub: send prog del": stats.hubSendProgDel.get(), + "hub: send repro": stats.hubSendRepro.get(), + "hub: recv prog": stats.hubRecvProg.get(), + "hub: recv prog drop": stats.hubRecvProgDrop.get(), + "hub: recv repro": stats.hubRecvRepro.get(), + "hub: recv repro drop": stats.hubRecvReproDrop.get(), + } +} + +func (s *Stat) get() uint64 { + return atomic.LoadUint64((*uint64)(s)) +} + +func (s *Stat) inc() { + s.add(1) +} + +func (s *Stat) add(v int) { + atomic.AddUint64((*uint64)(s), uint64(v)) +} |
