Skip to content

Commit

Permalink
Fix stepping extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
gballet committed Jun 22, 2020
1 parent 877e0a6 commit baec973
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions cpu/cpu_dragonfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

var ClocksPerSec = float64(128)
var cpuMatch = regexp.MustCompile(`^CPU:`)
var originMatch = regexp.MustCompile(`Origin\s*=\s*"(.+)"\s+Id\s*=\s*(.+)\s+Family\s*=\s*(.+)\s+Model\s*=\s*(.+)\s+Stepping\s*=\s*(.+)`)
var originMatch = regexp.MustCompile(`Origin\s*=\s*"(.+)"\s+Id\s*=\s*(.+)\s+Stepping\s*=\s*(.+)`)
var featuresMatch = regexp.MustCompile(`Features=.+<(.+)>`)
var featuresMatch2 = regexp.MustCompile(`Features2=[a-f\dx]+<(.+)>`)
var cpuEnd = regexp.MustCompile(`^Trying to mount root`)
Expand Down Expand Up @@ -110,11 +110,11 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
c.Mhz = float64(u32)

var num int
var buf []byte
if buf, err = unix.SysctlRaw("hw.cpu_topology.tree"); err != nil {
var buf string
if buf, err = unix.Sysctl("hw.cpu_topology.tree"); err != nil {
return nil, err
}
num = strings.Count(string(buf), "CHIP")
num = strings.Count(buf, "CHIP")
c.Cores = int32(strings.Count(string(buf), "CORE") / num)

if c.ModelName, err = unix.Sysctl("hw.model"); err != nil {
Expand All @@ -137,11 +137,9 @@ func parseDmesgBoot(fileName string) (InfoStat, error) {
break
} else if matches := originMatch.FindStringSubmatch(line); matches != nil {
c.VendorID = matches[1]
c.Family = matches[3]
c.Model = matches[4]
t, err := strconv.ParseInt(matches[5], 10, 32)
t, err := strconv.ParseInt(matches[2], 10, 32)
if err != nil {
return c, fmt.Errorf("unable to parse FreeBSD CPU stepping information from %q: %v", line, err)
return c, fmt.Errorf("unable to parse DragonflyBSD CPU stepping information from %q: %v", line, err)
}
c.Stepping = int32(t)
} else if matches := featuresMatch.FindStringSubmatch(line); matches != nil {
Expand Down

0 comments on commit baec973

Please sign in to comment.