cpuinfo:   CPU Information
1 Introduction
2 Interface
parse-proc-cpuinfo
get-cpuinfo
cpuinfo->english
cpuinfo-kvm-support
3 Known Issues
4 History
5 Legal
2:1

cpuinfo: CPU Information🔗ℹ

Neil Van Dyke

 (require cpuinfo) package: cpuinfo

1 Introduction🔗ℹ

The cpuinfo package makes it easy to get particular information about the host machine CPUs from Racket, such as an English description of the models of CPU and their configuration (of physical processors, cores, and hyperthreading), and what virtualization method the CPUs support.
This package uses the "/proc/cpuinfo" interface, such as in Linux.
Examples are sensitive to what machine get-cpuinfo in run on, so imagine you are using the laptop on which the author of this package is typing this documentation, when we do:

> (define my-cpuinfo (get-cpuinfo))

my-cpuinfo now contains the information gotten from the "/proc/cpuinfo" kernel interface. We can ask for an English language summary:

> (cpuinfo->english my-cpuinfo)

  "single-processor (Intel Core Duo T2500 2.00GHz), dual-core"
This package tries to distinguish physical processors, cores, and hyperthreading correctly, so, on a different machine, you might see a result more like:

> (cpuinfo->english my-cpuinfo)

  "dual-processor (Intel Xeon 3.60GHz), dual-core total, plus hyperthreading"
For more information how this package determines whether hyperthreading is in use, see Richweb’s Understanding Linux /proc/cpuinfo.
Back to our original example machine, we can also ask what support the processor has for KVM virtualization:

> (cpuinfo-kvm-support my-cpuinfo)

  intel-vt-x
Finally, we can access the raw cpuinfo info, as a list of alists of symbols to strings:

> my-cpuinfo

  (((processor . "0")
    (vendor-id . "GenuineIntel")
    (cpu-family . "6")
    (model . "14")
    (model-name . "Intel(R) Core(TM) Duo CPU T2500 @ 2.00GHz")
    (stepping . "12")
    (cpu-mhz . "1333.000")
    (cache-size . "2048 KB")
    (physical-id . "0")
    (siblings . "2")
    (core-id . "0")
    (cpu-cores . "2")
    (apicid . "0")
    (initial-apicid . "0")
    (fdiv-bug . "no")
    (hlt-bug . "no")
    (f00f-bug . "no")
    (coma-bug . "no")
    (fpu . "yes")
    (fpu-exception . "yes")
    (cpuid-level . "10")
    (wp . "yes")
    (flags
  
   . "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx constant_tsc arch_perfmon bts aperfmperf pni monitor vmx est tm2 xtpr pdcm")
    (bogomips . "3990.15")
    (clflush-size . "64")
    (cache-alignment . "64")
    (address-sizes . "32 bits physical, 32 bits virtual")
    (power-management . ""))
   ((processor . "1")
    (vendor-id . "GenuineIntel")
    (cpu-family . "6")
    (model . "14")
    (model-name . "Intel(R) Core(TM) Duo CPU T2500 @ 2.00GHz")
    (stepping . "12")
    (cpu-mhz . "2000.000")
    (cache-size . "2048 KB")
    (physical-id . "0")
    (siblings . "2")
    (core-id . "1")
    (cpu-cores . "2")
    (apicid . "1")
    (initial-apicid . "1")
    (fdiv-bug . "no")
    (hlt-bug . "no")
    (f00f-bug . "no")
    (coma-bug . "no")
    (fpu . "yes")
    (fpu-exception . "yes")
    (cpuid-level . "10")
    (wp . "yes")
    (flags
  
   . "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx constant_tsc arch_perfmon bts aperfmperf pni monitor vmx est tm2 xtpr pdcm")
    (bogomips . "3990.07")
    (clflush-size . "64")
    (cache-alignment . "64")
    (address-sizes . "32 bits physical, 32 bits virtual")
    (power-management . "")))
This package was originally written for the About box of RackOut, since processor arrangement might be important for video decoding performance.

2 Interface🔗ℹ

procedure

(parse-proc-cpuinfo in)  cpuinfo?

  in : input-port?
Parse cpuinfo from input port. This is useful if the input is not coming directly from file "/proc/cpuinfo" on the host machine; otherwise, you would normally just use get-cpuinfo instead.

procedure

(get-cpuinfo)  cpuinfo?

Get the cpuinfo for the host machine.

procedure

(cpuinfo->english cpuinfo)  string?

  cpuinfo : cpuinfo?
Yield an English language summary of cpuinfo. This is useful for a human to understand pertinent information about their CPUs, such as in the About box of an application program. The exact format of this message is subject to change in future versions of this package.

procedure

(cpuinfo-kvm-support cpuinfo)  (or/c #f  'amd-v 'intel-vt-x)

  cpuinfo : cpuinfo?
Returns a symbol for the kind of Linux KVM virtualization support at least one processor in cpuinfo has, or #f if none could be determined. See Linux KVM hardware support page.

3 Known Issues🔗ℹ

4 History🔗ℹ

5 Legal🔗ℹ

Copyright 2012, 2013, 2016 Neil Van Dyke. This program is Free Software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See http://www.gnu.org/licenses/ for details. For other licenses and consulting, please contact the author.